auto-task-v4

赠Key站自动任务

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.6-Beta
  5. // @description 赠Key站自动任务
  6. // @author HCLonely
  7. // @license MIT
  8. // @run-at document-start
  9. // @homepage https://auto-task-doc.js.org/
  10. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  11.  
  12. // @include *://freeanywhere.net/*
  13. // @include *://giveaway.su/giveaway/view/*
  14. // @include *://givee.club/*/event/*
  15. // @include *://givekey.ru/giveaway/*
  16. // @include *://www.indiedb.com/giveaways*
  17. // @include *://key-hub.eu/giveaway/*
  18. // @include *://keylol.com/*
  19. // @include *://www.opiumpulses.com/giveaways
  20. // @include *://prys.revadike.com/giveaway/?id=*
  21. // @include *://opquests.com/quests/*
  22. // @include *://gleam.io/*
  23. // @include *://sweepwidget.com/view/*
  24. // @include *://discord.com/*
  25. // @include *://www.twitch.tv/*
  26. // @include *://www.youtube.com/*
  27. // @include *://*.reddit.com/*
  28. // @include *://twitter.com/settings/account?k*
  29. // @include https://auto-task-v4.hclonely.com/setting.html
  30. // @include https://auto-task-v4.hclonely.com/history.html
  31.  
  32. // @grant GM_setValue
  33. // @grant GM_getValue
  34. // @grant GM_listValues
  35. // @grant GM_deleteValue
  36. // @grant GM_addStyle
  37. // @grant GM_xmlhttpRequest
  38. // @grant GM_registerMenuCommand
  39. // @grant GM_info
  40. // @grant GM_openInTab
  41. // @grant GM_setClipboard
  42. // @grant unsafeWindow
  43. // @grant window.close
  44. // @grant window.localStorage
  45.  
  46. // @connect cdn.jsdelivr.net
  47. // @connect store.steampowered.com
  48. // @connect steamcommunity.com
  49. // @connect twitter.com
  50. // @connect api.twitter.com
  51. // @connect youtube.com
  52. // @connect www.youtube.com
  53. // @connect facebook.com
  54. // @connect instagram.com
  55. // @connect vk.com
  56. // @connect twitch.tv
  57. // @connect www.twitch.tv
  58. // @connect gql.twitch.tv
  59. // @connect github.com
  60. // @connect discordapp.com
  61. // @connect discord.gg
  62. // @connect discord.com
  63. // @connect www.reddit.com
  64. // @connect oauth.reddit.com
  65. // @connect raw.githubusercontent.com
  66. // @connect t.me
  67. // @connect bit.ly
  68. // @connect giveaway.su
  69. // @connect google.com
  70. // @connect www.vloot.io
  71. // @connect givee.club
  72. // @connect auto-task-v4.hclonely.com
  73. // @connect *
  74. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  75. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  76. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  77. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  78. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  79. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  80. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  81.  
  82. // @compatible Tampermonkey Only
  83. // @noframes
  84. // ==/UserScript==
  85.  
  86. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  87.  
  88. (function() {
  89. var __webpack_modules__ = {
  90. 514: function(__unused_webpack_module, exports) {
  91. !function(e, n) {
  92. true ? n(exports) : 0;
  93. }(this, function(e) {
  94. 'use strict';
  95. var t = function() {
  96. return (t = Object.assign || function(e) {
  97. for (var n, o = 1, t = arguments.length; o < t; o++) {
  98. for (var r in n = arguments[o]) {
  99. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  100. }
  101. }
  102. return e;
  103. }).apply(this, arguments);
  104. };
  105. function r(e, n, o) {
  106. if (o || 2 === arguments.length) {
  107. for (var t, r = 0, i = n.length; r < i; r++) {
  108. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  109. }
  110. }
  111. return e.concat(t || Array.prototype.slice.call(n));
  112. }
  113. function d(e) {
  114. return '[object Object]' === n(e);
  115. }
  116. function l(e, n) {
  117. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  118. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  119. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  120. });
  121. }
  122. var n = function(e) {
  123. return Object.prototype.toString.call(e);
  124. };
  125. var o = (i.prototype.init = function() {
  126. try {
  127. this.getSystemName(), this.getBrowserName();
  128. } catch (e) {
  129. console.warn('[UA formatter error] '.concat(e));
  130. }
  131. }, i.prototype.getEngine = function() {
  132. var e = this.agent;
  133. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  134. }, i.prototype.getSystemName = function() {
  135. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  136. try {
  137. var o = '';
  138. if (/Windows/i.test(n)) {
  139. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  140. switch (this.info.os = 'Windows', t) {
  141. case '6.3':
  142. o = '8.1';
  143. break;
  144.  
  145. case '6.2':
  146. o = '8';
  147. break;
  148.  
  149. case '6.1':
  150. o = '7';
  151. break;
  152.  
  153. case '5.2':
  154. case '5.1':
  155. o = 'XP';
  156. break;
  157.  
  158. default:
  159. o = t;
  160. }
  161. return this.info.device = 'PC', void (this.info.osVersion = o);
  162. }
  163. if (/^Macintosh/i.test(n)) {
  164. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  165. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  166. }
  167. if (/^iPad/i.test(n)) {
  168. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  169. void (this.info.osVersion = o.replace(/_/g, '.'));
  170. }
  171. if (/^iPhone/i.test(n)) {
  172. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  173. void (this.info.osVersion = o.replace(/_/g, '.'));
  174. }
  175. if (-1 !== n.indexOf('Android')) {
  176. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  177. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  178. }
  179. if (/Linux\s[a-z\d_]+/.test(n)) {
  180. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  181. }
  182. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  183. } catch (e) {
  184. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  185. }
  186. }, i.prototype.getBrowserName = function() {
  187. var e = Object.keys(this.browserNameMap).map(function(e) {
  188. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  189. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  190. return -1 !== e.findIndex(function(e) {
  191. return e.test(n);
  192. });
  193. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  194. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  195. }, i.prototype._formatBrowserVersion = function(e) {
  196. var n, o, t, r;
  197. try {
  198. 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++) {
  199. var d = u[f], l = d[0], h = d[1];
  200. if (new RegExp(l).test(s)) {
  201. c = h;
  202. break;
  203. }
  204. }
  205. var p = {
  206. browserVersion: null != a ? a : 'Unknown',
  207. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  208. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  209. };
  210. return 'Trident' === s && (p.browserVersion = {
  211. '4.0': 8,
  212. '5.0': 9,
  213. '6.0': 10,
  214. '7.0': 11
  215. }[a]), p;
  216. } catch (e) {
  217. return console.warn('[UA formatter error] '.concat(e)), {
  218. browser: 'Unknown',
  219. browserVersion: 'Unknown'
  220. };
  221. }
  222. }, i);
  223. function i(e) {
  224. this.agent = '', this.info = {
  225. browser: '',
  226. browserZH: '',
  227. browserVersion: '',
  228. os: '',
  229. osVersion: '',
  230. device: 'Unknown',
  231. engine: 'WebKit'
  232. }, this.browserNameMap = {
  233. MicroMessenger: {
  234. en: 'MicroMessenger',
  235. zh: '微信'
  236. },
  237. MetaSr: {
  238. en: 'MetaSr',
  239. zh: '搜狗浏览器'
  240. },
  241. 'QQ(Browser)?': {
  242. en: 'QQBrowser',
  243. zh: 'QQ浏览器'
  244. },
  245. UCBrowser: {
  246. en: 'UCBrowser',
  247. zh: 'UC浏览器'
  248. },
  249. '2345Explorer': {
  250. en: '2345Explorer',
  251. zh: '2345极速浏览器'
  252. },
  253. Mb2345Browser: {
  254. en: 'Mb2345Browser',
  255. zh: '2345手机浏览器'
  256. },
  257. Trident: {
  258. en: 'Internet Explorer'
  259. },
  260. 'Edge?': {
  261. en: 'Edge'
  262. },
  263. OPR: {
  264. en: 'Opera'
  265. },
  266. Vivaldi: {
  267. en: 'Vivaldi'
  268. },
  269. Firefox: {
  270. en: 'Firefox'
  271. },
  272. Chrome: {
  273. en: 'Chrome'
  274. },
  275. Safari: {
  276. en: 'Safari'
  277. }
  278. }, this.agent = e, this.init();
  279. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  280. this.info = t(t({}, this.info), {
  281. engine: this.getEngine(),
  282. browserVersion: 'Safari' === o ? n : e
  283. });
  284. }
  285. function s() {
  286. this.cookies = {}, this.init();
  287. }
  288. var a = new (s.prototype.init = function() {
  289. var o = {};
  290. document.cookie.split(/;\s/).forEach(function(e) {
  291. var n = e.split(/=/), e = n[0], n = n[1];
  292. o[e] = n;
  293. }), this.cookies = o;
  294. }, s.prototype.getItem = function(e) {
  295. return this.cookies[e];
  296. }, s.prototype.getAllItems = function() {
  297. return this.cookies;
  298. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  299. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  300. }, s)();
  301. e.countDown = function e(n, o, t, r) {
  302. if (!window) {
  303. throw new Error('window is not defind.');
  304. }
  305. if (0 < n) {
  306. return r && r(), n--, window[o] = window.setTimeout(function() {
  307. e(n, o, t, r);
  308. }, 1e3), function() {
  309. return clearTimeout(window[o]);
  310. };
  311. }
  312. clearTimeout(window[o]), t && t();
  313. }, e.createRandomID = function(e) {
  314. void 0 === e && (e = 12);
  315. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  316. n.push(o[Math.round(Math.random() * t)]);
  317. }
  318. return n.join('');
  319. }, e.dCookie = a, e.debounce = function(o, t, r) {
  320. var i;
  321. void 0 === t && (t = 0);
  322. var s = r = void 0 === r ? !1 : r;
  323. return function() {
  324. var e = this, n = arguments;
  325. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  326. r ? s = !0 : o.apply(e, n);
  327. }, t);
  328. };
  329. }, e.deepCopy = function e(n) {
  330. if (d(n) || Array.isArray(n)) {
  331. var o, t = Array.isArray(n) ? [] : {};
  332. for (o in n) {
  333. t[o] = e(n[o]);
  334. }
  335. return t;
  336. }
  337. return n;
  338. }, e.formatQueryParams = function(e) {
  339. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  340. if (!e) {
  341. return {};
  342. }
  343. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  344. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  345. return t[n] = o, e;
  346. });
  347. }
  348. return t;
  349. }, e.formatThousandth = function(e) {
  350. 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, '$&,');
  351. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  352. }, e.generateTree = function e(n, o, t, r) {
  353. for (var i = [], s = 0; s < n.length; s++) {
  354. var a = n[s];
  355. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  356. }
  357. return i;
  358. }, e.isEmpty = function(e) {
  359. 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);
  360. }, e.isFunction = function(e) {
  361. return '[object Function]' === n(e);
  362. }, e.isImageUrl = function(e) {
  363. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  364. }, e.isObject = d, e.isRegexp = function(e) {
  365. return '[object RegExp]' === n(e);
  366. }, e.objectKeyToCamelCase = function e(n, o, t) {
  367. if (Array.isArray(n)) {
  368. for (var r = [], i = 0; i < n.length; i++) {
  369. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  370. }
  371. } else if (d(n)) {
  372. r = {};
  373. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  374. var f = (u = c[a])[0], u = u[1];
  375. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  376. }
  377. } else {
  378. r = n;
  379. }
  380. return r;
  381. }, e.realType = n, e.searchParams = function(e, n) {
  382. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  383. new URLSearchParams(e).get(n);
  384. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  385. return e.replace(/([A-Z])/g, function(e) {
  386. return '_'.concat(e.toLocaleLowerCase());
  387. });
  388. }, e.ua = function(e) {
  389. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  390. }, Object.defineProperty(e, '__esModule', {
  391. value: !0
  392. });
  393. });
  394. },
  395. 786: function(module, __webpack_exports__, __webpack_require__) {
  396. 'use strict';
  397. __webpack_require__.d(__webpack_exports__, {
  398. Z: function() {
  399. return __WEBPACK_DEFAULT_EXPORT__;
  400. }
  401. });
  402. 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);
  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___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__);
  404. 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);
  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___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__);
  406. 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());
  407. ___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}', '' ]);
  408. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  409. },
  410. 400: function(module) {
  411. 'use strict';
  412. module.exports = function(cssWithMappingToString) {
  413. var list = [];
  414. list.toString = function toString() {
  415. return this.map(function(item) {
  416. var content = '';
  417. var needLayer = typeof item[5] !== 'undefined';
  418. if (item[4]) {
  419. content += '@supports ('.concat(item[4], ') {');
  420. }
  421. if (item[2]) {
  422. content += '@media '.concat(item[2], ' {');
  423. }
  424. if (needLayer) {
  425. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  426. }
  427. content += cssWithMappingToString(item);
  428. if (needLayer) {
  429. content += '}';
  430. }
  431. if (item[2]) {
  432. content += '}';
  433. }
  434. if (item[4]) {
  435. content += '}';
  436. }
  437. return content;
  438. }).join('');
  439. };
  440. list.i = function i(modules, media, dedupe, supports, layer) {
  441. if (typeof modules === 'string') {
  442. modules = [ [ null, modules, undefined ] ];
  443. }
  444. var alreadyImportedModules = {};
  445. if (dedupe) {
  446. for (var k = 0; k < this.length; k++) {
  447. var id = this[k][0];
  448. if (id != null) {
  449. alreadyImportedModules[id] = true;
  450. }
  451. }
  452. }
  453. for (var _k = 0; _k < modules.length; _k++) {
  454. var item = [].concat(modules[_k]);
  455. if (dedupe && alreadyImportedModules[item[0]]) {
  456. continue;
  457. }
  458. if (typeof layer !== 'undefined') {
  459. if (typeof item[5] === 'undefined') {
  460. item[5] = layer;
  461. } else {
  462. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  463. item[5] = layer;
  464. }
  465. }
  466. if (media) {
  467. if (!item[2]) {
  468. item[2] = media;
  469. } else {
  470. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  471. item[2] = media;
  472. }
  473. }
  474. if (supports) {
  475. if (!item[4]) {
  476. item[4] = ''.concat(supports);
  477. } else {
  478. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  479. item[4] = supports;
  480. }
  481. }
  482. list.push(item);
  483. }
  484. };
  485. return list;
  486. };
  487. },
  488. 220: function(module) {
  489. 'use strict';
  490. module.exports = function(i) {
  491. return i[1];
  492. };
  493. }
  494. };
  495. var __webpack_module_cache__ = {};
  496. function __webpack_require__(moduleId) {
  497. var cachedModule = __webpack_module_cache__[moduleId];
  498. if (cachedModule !== undefined) {
  499. return cachedModule.exports;
  500. }
  501. var module = __webpack_module_cache__[moduleId] = {
  502. id: moduleId,
  503. exports: {}
  504. };
  505. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  506. return module.exports;
  507. }
  508. !function() {
  509. __webpack_require__.n = function(module) {
  510. var getter = module && module.__esModule ? function() {
  511. return module['default'];
  512. } : function() {
  513. return module;
  514. };
  515. __webpack_require__.d(getter, {
  516. a: getter
  517. });
  518. return getter;
  519. };
  520. }();
  521. !function() {
  522. __webpack_require__.d = function(exports, definition) {
  523. for (var key in definition) {
  524. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  525. Object.defineProperty(exports, key, {
  526. enumerable: true,
  527. get: definition[key]
  528. });
  529. }
  530. }
  531. };
  532. }();
  533. !function() {
  534. __webpack_require__.o = function(obj, prop) {
  535. return Object.prototype.hasOwnProperty.call(obj, prop);
  536. };
  537. }();
  538. var __webpack_exports__ = {};
  539. !function() {
  540. 'use strict';
  541. const external_Swal_namespaceObject = Swal;
  542. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  543. const external_Cookies_namespaceObject = Cookies;
  544. var auto_task = __webpack_require__(786);
  545. var javascript_utils_umd_min = __webpack_require__(514);
  546. const httpRequest = async function(options) {
  547. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  548. try {
  549. const result = await new Promise(resolve => {
  550. if (options.dataType) {
  551. options.responseType = options.dataType;
  552. }
  553. const requestObj = {
  554. ...{
  555. timeout: 3e4,
  556. ontimeout(data) {
  557. resolve({
  558. result: 'Error',
  559. statusText: 'Timeout',
  560. status: 601,
  561. data: data,
  562. options: options
  563. });
  564. },
  565. onabort(data) {
  566. resolve({
  567. result: 'Error',
  568. statusText: 'Aborted',
  569. status: 602,
  570. data: data,
  571. options: options
  572. });
  573. },
  574. onerror(data) {
  575. resolve({
  576. result: 'Error',
  577. statusText: 'Error',
  578. status: 603,
  579. data: data,
  580. options: options
  581. });
  582. },
  583. onload(data) {
  584. resolve({
  585. result: 'Success',
  586. statusText: 'Load',
  587. status: 600,
  588. data: data,
  589. options: options
  590. });
  591. }
  592. },
  593. ...options
  594. };
  595. GM_xmlhttpRequest(requestObj);
  596. });
  597. console.log('发送请求:', result);
  598. if (result.status !== 600 && times < 2) {
  599. return await httpRequest(options, times + 1);
  600. }
  601. return result;
  602. } catch (error) {
  603. throwError(error, 'httpRequest');
  604. console.log('发送请求:', {
  605. errorMsg: error,
  606. options: options
  607. });
  608. return {
  609. result: 'JsError',
  610. statusText: 'Error',
  611. status: 604,
  612. error: error,
  613. options: options
  614. };
  615. }
  616. };
  617. const tools_httpRequest = httpRequest;
  618. const echoLog = _ref => {
  619. let {
  620. type,
  621. text,
  622. html,
  623. id
  624. } = _ref;
  625. const emptyStatus = {
  626. success: () => emptyStatus,
  627. error: () => emptyStatus,
  628. warning: () => emptyStatus,
  629. info: () => emptyStatus,
  630. view: () => emptyStatus
  631. };
  632. try {
  633. var _ele$;
  634. let ele;
  635. if (type) {
  636. switch (type) {
  637. case 'joiningSteamGroup':
  638. case 'leavingSteamGroup':
  639. case 'gettingSteamGroupId':
  640. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  641. break;
  642.  
  643. case 'subscribingForum':
  644. case 'unsubscribingForum':
  645. case 'gettingForumId':
  646. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  647. break;
  648.  
  649. case 'followingCurator':
  650. case 'unfollowingCurator':
  651. case 'getCuratorId':
  652. 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>`);
  653. break;
  654.  
  655. case 'addingToWishlist':
  656. case 'removingFromWishlist':
  657. case 'followingGame':
  658. case 'unfollowingGame':
  659. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  660. break;
  661.  
  662. case 'favoritingWorkshop':
  663. case 'unfavoritingWorkshop':
  664. case 'gettingWorkshopAppId':
  665. case 'votingUpWorkshop':
  666. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  667. ${text}</a>...<font></font></li>`);
  668. break;
  669.  
  670. case 'gettingAnnouncementParams':
  671. case 'likingAnnouncement':
  672. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  673. ${id}</a>...<font></font></li>`);
  674. break;
  675.  
  676. case 'joiningDiscordServer':
  677. case 'gettingDiscordGuild':
  678. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  679. break;
  680.  
  681. case 'leavingDiscordServer':
  682. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  683. break;
  684.  
  685. case 'updateDiscordAuth':
  686. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  687. break;
  688.  
  689. case 'followingTwitchChannel':
  690. case 'unfollowingTwitchChannel':
  691. case 'gettingTwitchChannelId':
  692. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  693. break;
  694.  
  695. case 'gettingInsUserId':
  696. case 'followingIns':
  697. case 'unfollowingIns':
  698. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  699. break;
  700.  
  701. case 'gettingTwitterUserId':
  702. case 'followingTwitterUser':
  703. case 'unfollowingTwitterUser':
  704. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  705. break;
  706.  
  707. case 'retweetting':
  708. case 'unretweetting':
  709. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  710. break;
  711.  
  712. case 'joiningReddit':
  713. case 'leavingReddit':
  714. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  715. break;
  716.  
  717. case 'followingRedditUser':
  718. case 'unfollowingRedditUser':
  719. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  720. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  721. break;
  722.  
  723. case 'followingYtbChannel':
  724. case 'unfollowingYtbChannel':
  725. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  726. break;
  727.  
  728. case 'likingYtbVideo':
  729. case 'unlikingYtbVideo':
  730. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  731. break;
  732.  
  733. case 'gettingVkId':
  734. case 'joiningVkGroup':
  735. case 'leavingVkGroup':
  736. case 'joiningVkPublic':
  737. case 'leavingVkPublic':
  738. case 'sendingVkWall':
  739. case 'deletingVkWall':
  740. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  741. break;
  742.  
  743. case 'visitingLink':
  744. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  745. break;
  746.  
  747. case 'verifyingInsAuth':
  748. case 'text':
  749. ele = $(`<li>${i18n(text)}<font></font></li>`);
  750. break;
  751.  
  752. case 'html':
  753. ele = $(text || html);
  754. break;
  755.  
  756. case 'whiteList':
  757. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  758. break;
  759.  
  760. case 'globalOptionsSkip':
  761. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  762. break;
  763.  
  764. default:
  765. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  766. break;
  767. }
  768. } else if (text) {
  769. ele = $(`<li>${i18n(text)}<font></font></li>`);
  770. } else if (html) {
  771. ele = $(html);
  772. } else {
  773. ele = $('<li><font></font></li>');
  774. }
  775. ele.addClass('card-text');
  776. $('#auto-task-info').append(ele);
  777. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  778. const font = ele.find('font');
  779. const status = {
  780. font: font,
  781. success() {
  782. var _this$font, _this$font2, _this$font3;
  783. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  784. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  785. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  786. 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);
  787. return this;
  788. },
  789. error() {
  790. var _this$font4, _this$font5, _this$font6;
  791. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  792. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  793. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  794. 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);
  795. return this;
  796. },
  797. warning() {
  798. var _this$font7, _this$font8, _this$font9;
  799. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  800. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  801. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  802. 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);
  803. return this;
  804. },
  805. info() {
  806. var _this$font10, _this$font11, _this$font12;
  807. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  808. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  809. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  810. 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);
  811. return this;
  812. },
  813. view() {
  814. var _this$font13;
  815. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  816. return this;
  817. }
  818. };
  819. return status;
  820. } catch (error) {
  821. throwError(error, 'echoLog');
  822. return emptyStatus;
  823. }
  824. };
  825. const scripts_echoLog = echoLog;
  826. const unique = array => {
  827. try {
  828. return [ ...new Set(array) ];
  829. } catch (error) {
  830. throwError(error, 'unique');
  831. return [];
  832. }
  833. };
  834. const delay = function() {
  835. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  836. return new Promise(resolve => {
  837. setTimeout(() => {
  838. resolve(true);
  839. }, time);
  840. });
  841. };
  842. const getRedirectLink = async link => {
  843. try {
  844. if (!link) {
  845. return null;
  846. }
  847. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  848. if (redirectLinksCache[link]) {
  849. redirectLinksCache[link];
  850. }
  851. return await tools_httpRequest({
  852. url: link,
  853. method: 'GET'
  854. }).then(_ref => {
  855. let {
  856. data
  857. } = _ref;
  858. if (data !== null && data !== void 0 && data.finalUrl) {
  859. redirectLinksCache[link] = data.finalUrl;
  860. GM_setValue('redirectLinks', redirectLinksCache);
  861. return data.finalUrl;
  862. }
  863. return null;
  864. });
  865. } catch (error) {
  866. throwError(error, 'getRedirectLink');
  867. return null;
  868. }
  869. };
  870. const visitLink = async (link, options) => {
  871. try {
  872. const logStatus = scripts_echoLog({
  873. type: 'visitLink',
  874. text: link
  875. });
  876. return await tools_httpRequest({
  877. url: link,
  878. method: 'GET',
  879. ...options
  880. }).then(_ref2 => {
  881. let {
  882. result,
  883. statusText,
  884. status
  885. } = _ref2;
  886. if (result === 'Success') {
  887. logStatus.success();
  888. return true;
  889. }
  890. logStatus.error(`${result}:${statusText}(${status})`);
  891. return false;
  892. });
  893. } catch (error) {
  894. throwError(error, 'visitLink');
  895. return false;
  896. }
  897. };
  898. const getUrlQuery = url => {
  899. try {
  900. const query = {};
  901. if (url) {
  902. if (url.includes('?')) {
  903. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  904. query[key] = value;
  905. return str;
  906. });
  907. }
  908. } else {
  909. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  910. query[key] = value;
  911. return str;
  912. });
  913. }
  914. return query;
  915. } catch (error) {
  916. throwError(error, 'getUrlQuery');
  917. return {};
  918. }
  919. };
  920. const getUuid = () => {
  921. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  922. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  923. };
  924. const stringToColour = str => {
  925. try {
  926. let hash = 0;
  927. for (let i = 0; i < str.length; i++) {
  928. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  929. }
  930. let colour = '#';
  931. for (let i = 0; i < 3; i++) {
  932. const value = hash >> i * 8 & 255;
  933. colour += `00${value.toString(16)}`.slice(-2);
  934. }
  935. return colour;
  936. } catch (error) {
  937. throwError(error, 'stringToColour');
  938. return '#fff';
  939. }
  940. };
  941. const defaultGlobalOptions = {
  942. doTask: {
  943. discord: {
  944. servers: true
  945. },
  946. instagram: {
  947. users: true
  948. },
  949. twitch: {
  950. channels: true
  951. },
  952. twitter: {
  953. users: true,
  954. retweets: true
  955. },
  956. vk: {
  957. names: true
  958. },
  959. youtube: {
  960. channels: true,
  961. likes: true
  962. },
  963. reddit: {
  964. reddits: true
  965. },
  966. steam: {
  967. groups: true,
  968. wishlists: true,
  969. follows: true,
  970. forums: true,
  971. workshops: true,
  972. curators: true,
  973. workshopVotes: true,
  974. announcements: true
  975. }
  976. },
  977. undoTask: {
  978. discord: {
  979. servers: true
  980. },
  981. instagram: {
  982. users: true
  983. },
  984. twitch: {
  985. channels: true
  986. },
  987. twitter: {
  988. users: true,
  989. retweets: true
  990. },
  991. vk: {
  992. names: true
  993. },
  994. youtube: {
  995. channels: true,
  996. likes: true
  997. },
  998. reddit: {
  999. reddits: true
  1000. },
  1001. steam: {
  1002. groups: true,
  1003. wishlists: true,
  1004. follows: true,
  1005. forums: true,
  1006. workshops: true,
  1007. curators: true
  1008. }
  1009. },
  1010. position: {
  1011. buttonSideX: 'right',
  1012. buttonSideY: 'top',
  1013. buttonDistance: '15,30',
  1014. showButtonSideX: 'right',
  1015. showButtonSideY: 'top',
  1016. showButtonDistance: '15,30',
  1017. logSideX: 'right',
  1018. logSideY: 'bottom',
  1019. logDistance: '10,10'
  1020. },
  1021. hotKey: {
  1022. doTaskKey: 'alt + d',
  1023. undoTaskKey: 'alt + u',
  1024. toggleLogKey: 'alt + l'
  1025. },
  1026. other: {
  1027. twitterVerifyId: '783214',
  1028. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1029. autoUpdateSource: 'jsdelivr',
  1030. language: 'zh',
  1031. checkLogin: true,
  1032. checkLeftKey: true,
  1033. defaultShowButton: true,
  1034. defaultShowLog: true
  1035. }
  1036. };
  1037. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1038. const assignObject = (obj1, obj2) => {
  1039. try {
  1040. const newObj = {};
  1041. for (const [ key, value ] of Object.entries(obj1)) {
  1042. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1043. newObj[key] = assignObject(value, obj2[key]);
  1044. } else {
  1045. newObj[key] = obj2[key] ?? value;
  1046. }
  1047. }
  1048. return newObj;
  1049. } catch (error) {
  1050. throwError(error, 'assignObject');
  1051. return defaultGlobalOptions;
  1052. }
  1053. };
  1054. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1055. const saveData = () => {
  1056. try {
  1057. const data = {};
  1058. $('#globalOptionsForm').serializeArray().map(value => {
  1059. data[value.name] = value.value;
  1060. return value;
  1061. });
  1062. $.makeArray($('#globalOptionsForm input')).map(element => {
  1063. const name = $(element).attr('name');
  1064. const keys = name.split('.');
  1065. if (keys.length === 3) {
  1066. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1067. } else if (keys.length === 2) {
  1068. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1069. }
  1070. return element;
  1071. });
  1072. GM_setValue('globalOptions', globalOptions);
  1073. external_Swal_default().fire({
  1074. title: i18n('changeGlobalOptionsSuccess'),
  1075. icon: 'success'
  1076. });
  1077. } catch (error) {
  1078. throwError(error, 'saveData');
  1079. }
  1080. };
  1081. const changeGlobalOptions = showType => {
  1082. try {
  1083. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1084. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1085. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1086. for (const [ option, data2 ] of Object.entries(data1)) {
  1087. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1088. if (typeof data2 === 'boolean') {
  1089. 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>`;
  1090. } else {
  1091. 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>`;
  1092. }
  1093. } else {
  1094. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1095. 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>`;
  1096. }
  1097. }
  1098. }
  1099. }
  1100. globalOptionsForm += '</tbody></table></form>';
  1101. if (showType === 'swal') {
  1102. external_Swal_default().fire({
  1103. title: i18n('globalOptions'),
  1104. html: globalOptionsForm,
  1105. showConfirmButton: true,
  1106. confirmButtonText: i18n('save'),
  1107. showCancelButton: true,
  1108. cancelButtonText: i18n('close')
  1109. }).then(_ref => {
  1110. let {
  1111. isConfirmed
  1112. } = _ref;
  1113. if (isConfirmed) {
  1114. saveData();
  1115. }
  1116. });
  1117. } else {
  1118. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1119. }
  1120. } catch (error) {
  1121. throwError(error, 'changeGlobalOptions');
  1122. }
  1123. };
  1124. const data = {
  1125. website: '网站',
  1126. type: '类型',
  1127. edit: '编辑',
  1128. whiteList: '白名单',
  1129. skipTask: '跳过撤销任务',
  1130. whiteListOptions: '白名单设置',
  1131. changeWhiteListOption: '设置白名单(%0)',
  1132. whiteListNotFound: '找不到此项白名单: %0',
  1133. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1134. changeWebsiteOptions: '网站设置',
  1135. changeGlobalOptions: '全局设置',
  1136. ok: '是',
  1137. save: '保存',
  1138. close: '关闭',
  1139. return: '返回',
  1140. option: '选项',
  1141. value: '值',
  1142. websiteOptions: '当前网站设置',
  1143. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1144. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1145. needLogin: '请先登录!',
  1146. getTasksInfo: '正在获取并处理任务信息...',
  1147. gettingKey: '正在获取Key...',
  1148. verifyingTask: '正在验证任务',
  1149. notice: '自动任务脚本提醒',
  1150. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1151. giveawayEnded: '此活动已结束,是否关闭?',
  1152. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1153. confirm: '确定',
  1154. cancel: '取消',
  1155. unKnown: '未知',
  1156. unKnownTaskType: '未识别的任务',
  1157. doing: '正在做任务',
  1158. allTasksComplete: '所有任务已完成!',
  1159. getTaskIdFailed: '获取任务Id失败!',
  1160. initSuccess: '%0 初始化成功!',
  1161. initFailed: '%0 初始化失败!',
  1162. errorLink: '链接错误: %0',
  1163. needInit: '请先初始化',
  1164. verifyingAuth: '正在验证%0凭证...',
  1165. updatingAuth: '正在更新%0凭证...',
  1166. initing: '正在初始化...',
  1167. getFailed: '获取%0失败!',
  1168. checkLoginFailed: '检测登录状态失败!',
  1169. checkLeftKeyFailed: '检测剩余Key失败!',
  1170. userId: '用户Id',
  1171. joiningGiveaway: '正在加入赠Key',
  1172. needJoinGiveaway: '需要先加入赠Key',
  1173. cannotUndo: '此网站不支持取消任务',
  1174. verifyAuth: '正在验证 %0 凭证...',
  1175. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1176. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1177. visitingLink: '正在访问链接: ',
  1178. doTask: '做任务',
  1179. undoTask: '撤销任务',
  1180. verifyTask: '验证任务',
  1181. getKey: '获取Key',
  1182. selectAll: '全选',
  1183. selectNone: '全不选',
  1184. invertSelect: '反选',
  1185. doFreeTask: '加入免费赠品',
  1186. doPointTask: '加入点数赠品',
  1187. skipTaskOption: '设置中已配置跳过任务',
  1188. other: '其他',
  1189. globalOptions: '全局设置',
  1190. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1191. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1192. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214',
  1193. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q',
  1194. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1195. saveGlobalOptions: '保存全局设置',
  1196. settingPage: '设置页面',
  1197. name: '名称',
  1198. version: '版本',
  1199. scriptManager: '脚本管理器',
  1200. script: '脚本',
  1201. environment: '环境',
  1202. os: '系统',
  1203. browser: '浏览器',
  1204. getId: '获取 %0 id',
  1205. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1206. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1207. showButton: '显示按钮',
  1208. hideButton: '隐藏按钮',
  1209. showLog: '显示日志',
  1210. hideLog: '隐藏日志',
  1211. defaultShowButton: '默认显示按钮',
  1212. defaultShowLog: '默认显示日志',
  1213. position: '组件位置',
  1214. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1215. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1216. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1217. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1218. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1219. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1220. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1221. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1222. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1223. hotKey: '快捷键',
  1224. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1225. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1226. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1227. tasksHistory: '任务历史',
  1228. clearHistory: '清空历史',
  1229. clearHistoryFinished: '已清空任务历史!',
  1230. deleteTask: '删除任务',
  1231. lastChangeTime: '最后一次修改时间',
  1232. clearTaskFinished: '删除以下任务完成!',
  1233. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1234. syncData: '数据同步',
  1235. settingData: '正在上传数据...',
  1236. gettingData: '正在获取数据...',
  1237. help: '帮助',
  1238. fileName: '文件名',
  1239. upload2gist: '同步到Gist',
  1240. downloadFromGist: '从Gist同步',
  1241. saveAndTest: '保存配置并测试',
  1242. testSuccess: '测试成功!',
  1243. testFailed: '测试失败!',
  1244. saveAndTestNotice: '请先保存配置并测试!',
  1245. processingData: '正在处理数据...',
  1246. updatingData: '正在上传数据...',
  1247. syncDataSuccess: '同步数据成功!',
  1248. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1249. downloadingData: '正在下载数据...',
  1250. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1251. savingData: '正在保存数据...',
  1252. syncHistory: '同步任务历史',
  1253. checkUpdateFailed: '检测更新失败',
  1254. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1255. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1256. gistOptions: 'Gist 设置',
  1257. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1258. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1259. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1260. toGithub: '前往Github反馈',
  1261. toKeylol: '前往其乐论坛反馈',
  1262. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1263. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1264. updateText: '%0 版本更新内容:',
  1265. groups: '组',
  1266. wishlists: '愿望单',
  1267. follows: '游戏关注',
  1268. forums: '论坛',
  1269. workshops: '创意工坊收藏',
  1270. curators: '鉴赏家',
  1271. workshopVotes: '创意工坊点赞',
  1272. announcements: '社区通知',
  1273. steamCommunity: 'Steam社区',
  1274. steamStore: 'Steam商店',
  1275. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1276. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1277. joiningSteamGroup: '正在加入Steam组',
  1278. leavingSteamGroup: '正在退出Steam组',
  1279. gettingSteamGroupId: '正在获取Steam组Id',
  1280. subscribingForum: '正在订阅Steam论坛',
  1281. unsubscribingForum: '正在取消订阅Steam论坛',
  1282. gettingForumId: '正在获取Steam论坛Id',
  1283. followingCurator: '正在关注Steam鉴赏家',
  1284. unfollowingCurator: '正在取关Steam鉴赏家',
  1285. addingToWishlist: '正在添加游戏到Steam愿望单',
  1286. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1287. followingGame: '正在关注Steam游戏',
  1288. unfollowingGame: '正在取关Steam游戏',
  1289. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1290. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1291. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1292. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1293. gettingAnnouncementParams: '正在获取Steam通知信息',
  1294. likingAnnouncement: '正在点赞Steam通知',
  1295. changingArea: '正在更换Steam地区: %0...',
  1296. notNeededChangeArea: '当前地区不需要更换',
  1297. noAnotherArea: '请检测是否开启正确开启代理',
  1298. gettingAreaInfo: '正在获取Steam地区信息...',
  1299. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1300. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1301. servers: '服务器',
  1302. joiningDiscordServer: '正在加入Discord服务器',
  1303. leavingDiscordServer: '正在退出Discord服务器',
  1304. gettingDiscordGuild: '正在获取Discord服务器Id',
  1305. users: '用户',
  1306. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1307. insBanned: '您的Instagram账户已被封禁',
  1308. verifyingInsAuth: '正在验证Instagram凭证...',
  1309. gettingInsUserId: '正在获取Instagram用户Id',
  1310. followingIns: '正在关注Instagram用户',
  1311. unfollowingIns: '正在取关Instagram用户',
  1312. reddits: '社区/用户',
  1313. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1314. changingRedditVersion: '正在切换Reddit为新版页面...',
  1315. joiningReddit: '正在加入Reddit社区',
  1316. leavingReddit: '正在退出Reddit社区',
  1317. followingRedditUser: '正在关注Reddit用户',
  1318. unfollowingRedditUser: '正在取关Reddit用户',
  1319. channels: '频道',
  1320. followingTwitchChannel: '正在关注Twitch频道',
  1321. unfollowingTwitchChannel: '正在取关Twitch频道',
  1322. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1323. twitterUser: '推特用户',
  1324. retweets: '转推',
  1325. followingTwitterUser: '正在关注推特用户',
  1326. unfollowingTwitterUser: '正在取关推特用户',
  1327. retweetting: '正在转推',
  1328. unretweetting: '正在撤销转推',
  1329. names: '组/社区/动态',
  1330. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1331. gettingVkId: '正在获取Vk任务Id',
  1332. joiningVkGroup: '正在加入Vk组',
  1333. leavingVkGroup: '正在退出Vk组',
  1334. joiningVkPublic: '正在加入Vk社区',
  1335. leavingVkPublic: '正在退出Vk社区',
  1336. sendingVkWall: '正在转发Vk动态',
  1337. deletingVkWall: '正在撤销转发Vk动态',
  1338. youtubeChannel: 'YouTube频道',
  1339. likes: '点赞',
  1340. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1341. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1342. gettingYtbToken: '正在获取YouTube Token...',
  1343. followingYtbChannel: '正在订阅YouTube频道',
  1344. unfollowingYtbChannel: '正在退订YouTube频道',
  1345. likingYtbVideo: '正在点赞YouTube视频',
  1346. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1347. giveKeyNoticeBefore: '每次验证间隔15s',
  1348. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1349. noPoints: '点数不够,跳过抽奖',
  1350. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1351. joiningLottery: '正在加入抽奖',
  1352. doingGleamTask: '正在做Gleam任务...',
  1353. gettingGleamLink: '正在获取Gleam任务链接...',
  1354. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1355. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1356. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1357. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1358. };
  1359. const zh_CN = data;
  1360. const en_US_data = {
  1361. website: 'Website',
  1362. type: 'Type',
  1363. edit: 'Edit',
  1364. whiteList: 'Whitelist',
  1365. skipTask: 'Skip undo task',
  1366. whiteListOptions: 'Whitelist options',
  1367. changeWhiteListOption: 'Whitelist option(%0)',
  1368. whiteListNotFound: 'Cannot find this whitelist: %0',
  1369. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1370. changeWebsiteOptions: 'Website options',
  1371. changeGlobalOptions: 'Global options',
  1372. ok: 'OK',
  1373. save: 'Save',
  1374. close: 'Close',
  1375. return: 'Return',
  1376. option: 'Option',
  1377. value: 'Value',
  1378. websiteOptions: 'Current website settings',
  1379. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1380. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1381. needLogin: 'Please log in first!',
  1382. getTasksInfo: 'Obtaining and processing task information...',
  1383. gettingKey: 'Getting Key...',
  1384. verifyingTask: 'Verifying task',
  1385. notice: 'Automatic task script notice',
  1386. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1387. giveawayEnded: 'This event has ended, do you want to close it?',
  1388. 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?',
  1389. confirm: 'Confirm',
  1390. cancel: 'Cancel',
  1391. unKnown: 'Unknown',
  1392. unKnownTaskType: 'Unrecognized task',
  1393. doing: 'Doing a task',
  1394. allTasksComplete: 'All tasks have been completed!',
  1395. getTaskIdFailed: 'Failed to obtain task Id!',
  1396. initSuccess: '%0 was initialized successfully!',
  1397. initFailed: '%0 initialization failed!',
  1398. errorLink: 'Link error: %0',
  1399. needInit: 'Please initialize first',
  1400. verifyingAuth: 'Verifying %0 token...',
  1401. updatingAuth: 'Update %0 token...',
  1402. initing: 'Initializing...',
  1403. getFailed: 'Failed to get %0!',
  1404. checkLoginFailed: 'Failed to detect login status!',
  1405. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1406. userId: 'User Id',
  1407. joiningGiveaway: 'Joining giveaway',
  1408. needJoinGiveaway: 'Need to join the giveaway first',
  1409. cannotUndo: 'This website does not support canceling tasks',
  1410. verifyAuth: 'Verifying %0 token...',
  1411. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1412. errorReport: 'A script error is detected, do you want to report the BUG?',
  1413. visitingLink: 'Visiting link: ',
  1414. doTask: 'DoTask',
  1415. undoTask: 'UndoTask',
  1416. verifyTask: 'Verify',
  1417. getKey: 'GetKey',
  1418. selectAll: 'SelectAll',
  1419. selectNone: 'SelectNone',
  1420. invertSelect: 'InvertSelect',
  1421. doFreeTask: 'FreeTask',
  1422. doPointTask: 'PointTask',
  1423. skipTaskOption: 'Skip task has been configured in the settings',
  1424. other: 'Other',
  1425. globalOptions: 'Global Options',
  1426. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1427. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1428. twitterVerifyId: 'Verify Twitter token by trying to follow the account.</br>The default is the official Twitter account 783214.',
  1429. youtubeVerifyChannel: 'Verify YouTube token by trying to subscribe to the channel.</br>' + 'The default is the official YouTube channel UCrXUsMBcfTVqwAS7DKg9C0Q.',
  1430. 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.',
  1431. saveGlobalOptions: 'SaveSettings',
  1432. settingPage: 'Setting Page',
  1433. name: 'Name',
  1434. version: 'Version',
  1435. scriptManager: 'Script Manager',
  1436. script: 'Script',
  1437. environment: 'Environment',
  1438. os: 'OS',
  1439. browser: 'Browser',
  1440. getId: 'Get %0 id',
  1441. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1442. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1443. showButton: 'ShowButton',
  1444. hideButton: 'HideButton',
  1445. showLog: 'ShowLog',
  1446. hideLog: 'HideLog',
  1447. defaultShowButton: 'Default display button',
  1448. defaultShowLog: 'Display log by default',
  1449. position: 'Component position',
  1450. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1451. 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',
  1452. 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',
  1453. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1454. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1455. 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',
  1456. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1457. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1458. 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',
  1459. hotKey: 'Shortcut key',
  1460. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1461. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1462. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1463. tasksHistory: 'TasksHistory',
  1464. clearHistory: 'Clear history',
  1465. clearHistoryFinished: 'The mission history has been cleared!',
  1466. deleteTask: 'Delete task',
  1467. lastChangeTime: 'Last Change Time',
  1468. clearTaskFinished: 'Delete the following tasks completed!',
  1469. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1470. syncData: 'Data synchronization',
  1471. settingData: 'Uploading data...',
  1472. gettingData: 'Getting data...',
  1473. help: 'Help',
  1474. fileName: 'Filename',
  1475. upload2gist: 'Sync to Gist',
  1476. downloadFromGist: 'Sync from Gist',
  1477. saveAndTest: 'Save configuration and test',
  1478. testSuccess: 'Test success!',
  1479. testFailed: 'Test failed!',
  1480. saveAndTestNotice: 'Please save the configuration and test first!',
  1481. processingData: 'Processing data...',
  1482. updatingData: 'Uploading data...',
  1483. syncDataSuccess: 'Synchronized data successfully!',
  1484. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1485. downloadingData: 'Downloading data...',
  1486. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1487. savingData: 'Saving data...',
  1488. syncHistory: 'Synchronize tasks history',
  1489. checkUpdateFailed: 'Check update failed',
  1490. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1491. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1492. gistOptions: 'Gist Settings',
  1493. 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!',
  1494. 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!',
  1495. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1496. toGithub: 'Feedback(Github)',
  1497. toKeylol: 'Feedback(Keylol)',
  1498. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1499. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1500. updateText: 'Updates in version %0:',
  1501. groups: 'Group',
  1502. wishlists: 'Wishlist',
  1503. follows: 'Follow Game',
  1504. forums: 'Forum',
  1505. workshops: 'Favorite Workshop',
  1506. curators: 'Curator',
  1507. workshopVotes: 'Voteup Workshop',
  1508. announcements: 'Announcement',
  1509. steamCommunity: 'Steam Community',
  1510. steamStore: 'Steam Store',
  1511. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1512. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1513. joiningSteamGroup: 'Joining Steam Group',
  1514. leavingSteamGroup: 'Leaving Steam Group',
  1515. gettingSteamGroupId: 'Getting Steam Group Id',
  1516. subscribingForum: 'Subscribing the Steam Forum',
  1517. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1518. gettingForumId: 'Getting Steam Forum Id',
  1519. followingCurator: 'Following Steam Curator',
  1520. unfollowingCurator: 'Unfollowing Steam Curator',
  1521. addingToWishlist: 'Adding the game to the Steam wishlist',
  1522. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1523. followingGame: 'Following Steam games',
  1524. unfollowingGame: 'Unfollowing Steam games',
  1525. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1526. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1527. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1528. votingUpWorkshop: 'Liking Steam workshop items',
  1529. gettingAnnouncementParams: 'Getting Steam announcement information',
  1530. likingAnnouncement: 'Liking Steam announcement',
  1531. changingArea: 'Changing Steam area: %0...',
  1532. notNeededChangeArea: 'The current area does not need to be changed',
  1533. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1534. gettingAreaInfo: 'Getting Steam area information...',
  1535. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1536. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1537. servers: 'Server',
  1538. joiningDiscordServer: 'Joining Discord Server',
  1539. leavingDiscordServer: 'Leaving Discord Server',
  1540. gettingDiscordGuild: 'Getting Discord server Id',
  1541. users: 'User',
  1542. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1543. insBanned: 'Your Instagram account has been banned',
  1544. verifyingInsAuth: 'Verifying Instagram token...',
  1545. gettingInsUserId: 'Getting Instagram user Id',
  1546. followingIns: 'Following Instagram user',
  1547. unfollowingIns: 'Unfollowing Instagram user',
  1548. reddits: 'Reddit/User',
  1549. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1550. changingRedditVersion: 'Switching Reddit to a new version page...',
  1551. joiningReddit: 'Joining the Reddit',
  1552. leavingReddit: 'Leaving the Reddit',
  1553. followingRedditUser: 'Following Reddit User',
  1554. unfollowingRedditUser: 'Unfollowing Reddit User',
  1555. channels: 'Channel',
  1556. followingTwitchChannel: 'Following Twitch Channel',
  1557. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1558. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1559. twitterUser: 'Twitter User',
  1560. retweets: 'Retweet',
  1561. followingTwitterUser: 'Following Twitter User',
  1562. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1563. retweetting: 'Retweeting',
  1564. unretweetting: 'Unretweeting',
  1565. names: 'Group/Public/Wall',
  1566. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1567. gettingVkId: 'Getting Vk task Id',
  1568. joiningVkGroup: 'Joining Vk Group',
  1569. leavingVkGroup: 'Leaving Vk Group',
  1570. joiningVkPublic: 'Joining Vk Public',
  1571. leavingVkPublic: 'Leaving Vk Public',
  1572. sendingVkWall: 'Sending Vk Wall',
  1573. deletingVkWall: 'Deleting Vk Wall',
  1574. youtubeChannel: 'YouTube Channel',
  1575. likes: 'Like',
  1576. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1577. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1578. gettingYtbToken: 'Getting YouTube Token...',
  1579. followingYtbChannel: 'Subscribing to YouTube channel',
  1580. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1581. likingYtbVideo: 'Liking YouTube video',
  1582. unlikingYtbVideo: 'Unliking YouTube video',
  1583. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1584. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1585. noPoints: 'Not enough points, skip the lottery',
  1586. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1587. joiningLottery: 'Joining the lottery',
  1588. doingGleamTask: 'Doing Gleam Task...',
  1589. gettingGleamLink: 'Getting Gleam task link...',
  1590. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1591. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1592. 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!',
  1593. 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...'
  1594. };
  1595. const en_US = en_US_data;
  1596. const languages = {
  1597. zh: zh_CN,
  1598. en: en_US
  1599. };
  1600. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1601. const I18n = function(key) {
  1602. var _languages$language;
  1603. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1604. argvs[_key - 1] = arguments[_key];
  1605. }
  1606. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1607. return key;
  1608. }
  1609. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1610. };
  1611. const i18n = I18n;
  1612. function throwError(error, name) {
  1613. external_Swal_default().fire({
  1614. title: i18n('errorReport'),
  1615. icon: 'error',
  1616. showCancelButton: true,
  1617. confirmButtonText: i18n('toGithub'),
  1618. showDenyButton: true,
  1619. denyButtonText: i18n('toKeylol'),
  1620. cancelButtonText: i18n('close')
  1621. }).then(_ref => {
  1622. let {
  1623. isDenied,
  1624. isConfirmed
  1625. } = _ref;
  1626. if (isConfirmed) {
  1627. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1628.  
  1629. 环境:
  1630. \`\`\`
  1631. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1632. \`\`\`
  1633. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1634. 脚本版本: \`${GM_info.script.version}\`
  1635.  
  1636. 报错信息:
  1637. \`\`\`
  1638. ${error.stack}
  1639. \`\`\`
  1640.  
  1641. 执行日志:
  1642. \`\`\`
  1643. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1644. \`\`\`
  1645. `)}`, '_blank');
  1646. } else if (isDenied) {
  1647. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1648.  
  1649. 环境:
  1650.  
  1651. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1652.  
  1653. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1654. 脚本版本: ${GM_info.script.version}
  1655.  
  1656. 报错信息:
  1657. [code]${error.stack}[/code]
  1658.  
  1659. 执行日志:
  1660. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1661. GM_setClipboard(text);
  1662. external_Swal_default().fire({
  1663. title: i18n('copySuccess'),
  1664. icon: 'success',
  1665. confirmButtonText: i18n('ok')
  1666. }).then(() => {
  1667. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1668. });
  1669. }
  1670. });
  1671. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1672. }
  1673. function _defineProperty(obj, key, value) {
  1674. if (key in obj) {
  1675. Object.defineProperty(obj, key, {
  1676. value: value,
  1677. enumerable: true,
  1678. configurable: true,
  1679. writable: true
  1680. });
  1681. } else {
  1682. obj[key] = value;
  1683. }
  1684. return obj;
  1685. }
  1686. class Social {
  1687. constructor() {
  1688. _defineProperty(this, 'tasks', void 0);
  1689. }
  1690. getRealParams(name, links, doTask, link2param) {
  1691. try {
  1692. let realParams = [];
  1693. if (links.length > 0) {
  1694. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1695. }
  1696. if (!doTask && this.tasks[name].length > 0) {
  1697. realParams = [ ...realParams, ...this.tasks[name] ];
  1698. }
  1699. return unique(realParams);
  1700. } catch (error) {
  1701. throwError(error, 'Social.getRealParams');
  1702. return [];
  1703. }
  1704. }
  1705. }
  1706. const social_Social = Social;
  1707. function _classPrivateMethodInitSpec(obj, privateSet) {
  1708. _checkPrivateRedeclaration(obj, privateSet);
  1709. privateSet.add(obj);
  1710. }
  1711. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1712. _checkPrivateRedeclaration(obj, privateMap);
  1713. privateMap.set(obj, value);
  1714. }
  1715. function _checkPrivateRedeclaration(obj, privateCollection) {
  1716. if (privateCollection.has(obj)) {
  1717. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1718. }
  1719. }
  1720. function Discord_defineProperty(obj, key, value) {
  1721. if (key in obj) {
  1722. Object.defineProperty(obj, key, {
  1723. value: value,
  1724. enumerable: true,
  1725. configurable: true,
  1726. writable: true
  1727. });
  1728. } else {
  1729. obj[key] = value;
  1730. }
  1731. return obj;
  1732. }
  1733. function _classPrivateFieldSet(receiver, privateMap, value) {
  1734. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1735. _classApplyDescriptorSet(receiver, descriptor, value);
  1736. return value;
  1737. }
  1738. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1739. if (descriptor.set) {
  1740. descriptor.set.call(receiver, value);
  1741. } else {
  1742. if (!descriptor.writable) {
  1743. throw new TypeError('attempted to set read only private field');
  1744. }
  1745. descriptor.value = value;
  1746. }
  1747. }
  1748. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1749. if (!privateSet.has(receiver)) {
  1750. throw new TypeError('attempted to get private field on non-instance');
  1751. }
  1752. return fn;
  1753. }
  1754. function _classPrivateFieldGet(receiver, privateMap) {
  1755. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1756. return _classApplyDescriptorGet(receiver, descriptor);
  1757. }
  1758. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1759. if (!privateMap.has(receiver)) {
  1760. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1761. }
  1762. return privateMap.get(receiver);
  1763. }
  1764. function _classApplyDescriptorGet(receiver, descriptor) {
  1765. if (descriptor.get) {
  1766. return descriptor.get.call(receiver);
  1767. }
  1768. return descriptor.value;
  1769. }
  1770. const defaultTasks = {
  1771. servers: []
  1772. };
  1773. var _auth = new WeakMap();
  1774. var _cache = new WeakMap();
  1775. var _initialized = new WeakMap();
  1776. var _verifyAuth = new WeakSet();
  1777. var _updateAuth = new WeakSet();
  1778. var _joinServer = new WeakSet();
  1779. var _leaveServer = new WeakSet();
  1780. var _getGuild = new WeakSet();
  1781. var _setCache = new WeakSet();
  1782. class Discord extends social_Social {
  1783. constructor() {
  1784. var _GM_getValue;
  1785. super(...arguments);
  1786. _classPrivateMethodInitSpec(this, _setCache);
  1787. _classPrivateMethodInitSpec(this, _getGuild);
  1788. _classPrivateMethodInitSpec(this, _leaveServer);
  1789. _classPrivateMethodInitSpec(this, _joinServer);
  1790. _classPrivateMethodInitSpec(this, _updateAuth);
  1791. _classPrivateMethodInitSpec(this, _verifyAuth);
  1792. Discord_defineProperty(this, 'tasks', {
  1793. ...defaultTasks
  1794. });
  1795. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || {
  1796. ...defaultTasks
  1797. });
  1798. _classPrivateFieldInitSpec(this, _auth, {
  1799. writable: true,
  1800. value: GM_getValue('discordAuth') || {}
  1801. });
  1802. _classPrivateFieldInitSpec(this, _cache, {
  1803. writable: true,
  1804. value: GM_getValue('discordCache') || {}
  1805. });
  1806. _classPrivateFieldInitSpec(this, _initialized, {
  1807. writable: true,
  1808. value: false
  1809. });
  1810. }
  1811. async init() {
  1812. try {
  1813. if (_classPrivateFieldGet(this, _initialized)) {
  1814. return true;
  1815. }
  1816. if (!_classPrivateFieldGet(this, _auth).auth) {
  1817. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1818. _classPrivateFieldSet(this, _initialized, true);
  1819. return true;
  1820. }
  1821. return false;
  1822. }
  1823. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1824. if (isVerified) {
  1825. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1826. _classPrivateFieldSet(this, _initialized, true);
  1827. return true;
  1828. }
  1829. GM_setValue('discordAuth', {
  1830. auth: null
  1831. });
  1832. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1833. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1834. _classPrivateFieldSet(this, _initialized, true);
  1835. return true;
  1836. }
  1837. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1838. return false;
  1839. } catch (error) {
  1840. throwError(error, 'Discord.init');
  1841. return false;
  1842. }
  1843. }
  1844. async toggle(_ref) {
  1845. let {
  1846. doTask = true,
  1847. serverLinks = []
  1848. } = _ref;
  1849. try {
  1850. if (!_classPrivateFieldGet(this, _initialized)) {
  1851. scripts_echoLog({
  1852. text: i18n('needInit')
  1853. });
  1854. return false;
  1855. }
  1856. const prom = [];
  1857. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1858. scripts_echoLog({
  1859. type: 'globalOptionsSkip',
  1860. text: 'discord.servers'
  1861. });
  1862. } else {
  1863. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1864. var _link$match;
  1865. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1866. });
  1867. if (realServers.length > 0) {
  1868. for (const server of realServers) {
  1869. if (doTask) {
  1870. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1871. } else {
  1872. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1873. }
  1874. await delay(1e3);
  1875. }
  1876. }
  1877. }
  1878. return await Promise.all(prom).then(() => true);
  1879. } catch (error) {
  1880. throwError(error, 'Discord.toggleServers');
  1881. return false;
  1882. }
  1883. }
  1884. }
  1885. async function _verifyAuth2() {
  1886. try {
  1887. const logStatus = scripts_echoLog({
  1888. text: i18n('verifyingAuth', 'Discord')
  1889. });
  1890. const {
  1891. result,
  1892. statusText,
  1893. status,
  1894. data
  1895. } = await tools_httpRequest({
  1896. url: 'https://discord.com/api/v6/users/@me',
  1897. method: 'HEAD',
  1898. headers: {
  1899. authorization: _classPrivateFieldGet(this, _auth).auth
  1900. }
  1901. });
  1902. if (result === 'Success') {
  1903. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1904. logStatus.success();
  1905. return true;
  1906. }
  1907. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1908. return false;
  1909. }
  1910. logStatus.error(`${result}:${statusText}(${status})`);
  1911. return false;
  1912. } catch (error) {
  1913. throwError(error, 'Discord.verifyAuth');
  1914. return false;
  1915. }
  1916. }
  1917. async function _updateAuth2() {
  1918. try {
  1919. const logStatus = scripts_echoLog({
  1920. text: i18n('updatingAuth', 'Discord')
  1921. });
  1922. return await new Promise(resolve => {
  1923. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1924. active: true,
  1925. insert: true,
  1926. setParent: true
  1927. });
  1928. newTab.onclose = async () => {
  1929. var _GM_getValue2;
  1930. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1931. if (auth) {
  1932. _classPrivateFieldSet(this, _auth, {
  1933. auth: auth
  1934. });
  1935. logStatus.success();
  1936. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1937. } else {
  1938. logStatus.error('Error: Update discord auth failed!');
  1939. resolve(false);
  1940. }
  1941. };
  1942. });
  1943. } catch (error) {
  1944. throwError(error, 'Discord.updateAuth');
  1945. return false;
  1946. }
  1947. }
  1948. async function _joinServer2(inviteId) {
  1949. try {
  1950. const logStatus = scripts_echoLog({
  1951. type: 'joiningDiscordServer',
  1952. text: inviteId
  1953. });
  1954. const {
  1955. result,
  1956. statusText,
  1957. status,
  1958. data
  1959. } = await tools_httpRequest({
  1960. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1961. method: 'POST',
  1962. dataType: 'json',
  1963. headers: {
  1964. authorization: _classPrivateFieldGet(this, _auth).auth
  1965. }
  1966. });
  1967. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1968. var _data$response, _data$response$guild;
  1969. logStatus.success();
  1970. 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);
  1971. if (guild) {
  1972. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1973. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1974. }
  1975. return true;
  1976. }
  1977. logStatus.error(`${result}:${statusText}(${status})`);
  1978. return false;
  1979. } catch (error) {
  1980. throwError(error, 'Discord.joinServer');
  1981. return false;
  1982. }
  1983. }
  1984. async function _leaveServer2(inviteId) {
  1985. try {
  1986. if (this.whiteList.servers.includes(inviteId)) {
  1987. scripts_echoLog({
  1988. type: 'whiteList',
  1989. text: 'Discord.leaveServer',
  1990. id: inviteId
  1991. });
  1992. return true;
  1993. }
  1994. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  1995. if (!guild) {
  1996. return false;
  1997. }
  1998. const logStatus = scripts_echoLog({
  1999. type: 'leavingDiscordServer',
  2000. text: guild
  2001. });
  2002. const {
  2003. result,
  2004. statusText,
  2005. status,
  2006. data
  2007. } = await tools_httpRequest({
  2008. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2009. method: 'DELETE',
  2010. headers: {
  2011. authorization: _classPrivateFieldGet(this, _auth).auth
  2012. }
  2013. });
  2014. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2015. logStatus.success();
  2016. return true;
  2017. }
  2018. logStatus.error(`${result}:${statusText}(${status})`);
  2019. return false;
  2020. } catch (error) {
  2021. throwError(error, 'Discord.leaveServer');
  2022. return false;
  2023. }
  2024. }
  2025. async function _getGuild2(inviteId) {
  2026. try {
  2027. const logStatus = scripts_echoLog({
  2028. type: 'gettingDiscordGuild',
  2029. text: inviteId
  2030. });
  2031. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2032. if (guild) {
  2033. logStatus.success();
  2034. return guild;
  2035. }
  2036. const {
  2037. result,
  2038. statusText,
  2039. status,
  2040. data
  2041. } = await tools_httpRequest({
  2042. url: `https://discord.com/invite/${inviteId}`,
  2043. method: 'GET'
  2044. });
  2045. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2046. var _data$responseText$ma;
  2047. 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];
  2048. if (guild) {
  2049. logStatus.success();
  2050. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2051. return guild;
  2052. }
  2053. logStatus.error(`${result}:${statusText}(${status})`);
  2054. return false;
  2055. }
  2056. logStatus.error(`${result}:${statusText}(${status})`);
  2057. return false;
  2058. } catch (error) {
  2059. throwError(error, 'Discord.getGuild');
  2060. return false;
  2061. }
  2062. }
  2063. function _setCache2(inviteId, guild) {
  2064. try {
  2065. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2066. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2067. } catch (error) {
  2068. throwError(error, 'Discord.setCache');
  2069. }
  2070. }
  2071. const social_Discord = Discord;
  2072. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2073. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2074. privateSet.add(obj);
  2075. }
  2076. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2077. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2078. privateMap.set(obj, value);
  2079. }
  2080. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2081. if (privateCollection.has(obj)) {
  2082. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2083. }
  2084. }
  2085. function Instagram_defineProperty(obj, key, value) {
  2086. if (key in obj) {
  2087. Object.defineProperty(obj, key, {
  2088. value: value,
  2089. enumerable: true,
  2090. configurable: true,
  2091. writable: true
  2092. });
  2093. } else {
  2094. obj[key] = value;
  2095. }
  2096. return obj;
  2097. }
  2098. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2099. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2100. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2101. return value;
  2102. }
  2103. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2104. if (descriptor.set) {
  2105. descriptor.set.call(receiver, value);
  2106. } else {
  2107. if (!descriptor.writable) {
  2108. throw new TypeError('attempted to set read only private field');
  2109. }
  2110. descriptor.value = value;
  2111. }
  2112. }
  2113. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2114. if (!privateSet.has(receiver)) {
  2115. throw new TypeError('attempted to get private field on non-instance');
  2116. }
  2117. return fn;
  2118. }
  2119. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2120. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2121. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2122. }
  2123. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2124. if (!privateMap.has(receiver)) {
  2125. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2126. }
  2127. return privateMap.get(receiver);
  2128. }
  2129. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2130. if (descriptor.get) {
  2131. return descriptor.get.call(receiver);
  2132. }
  2133. return descriptor.value;
  2134. }
  2135. const Instagram_defaultTasks = {
  2136. users: []
  2137. };
  2138. var Instagram_cache = new WeakMap();
  2139. var Instagram_auth = new WeakMap();
  2140. var Instagram_initialized = new WeakMap();
  2141. var _getUserInfo = new WeakSet();
  2142. var _followUser = new WeakSet();
  2143. var _unfollowUser = new WeakSet();
  2144. var Instagram_setCache = new WeakSet();
  2145. class Instagram extends social_Social {
  2146. constructor() {
  2147. var _GM_getValue;
  2148. super(...arguments);
  2149. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2150. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2151. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2152. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2153. Instagram_defineProperty(this, 'tasks', {
  2154. ...Instagram_defaultTasks
  2155. });
  2156. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || {
  2157. ...Instagram_defaultTasks
  2158. });
  2159. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2160. writable: true,
  2161. value: GM_getValue('instagramCache') || {}
  2162. });
  2163. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2164. writable: true,
  2165. value: {}
  2166. });
  2167. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2168. writable: true,
  2169. value: false
  2170. });
  2171. }
  2172. async init() {
  2173. try {
  2174. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2175. return true;
  2176. }
  2177. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2178. if (isVerified) {
  2179. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2180. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2181. return true;
  2182. }
  2183. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2184. return false;
  2185. } catch (error) {
  2186. throwError(error, 'Instagram.init');
  2187. return false;
  2188. }
  2189. }
  2190. async toggle(_ref) {
  2191. let {
  2192. doTask = true,
  2193. userLinks = []
  2194. } = _ref;
  2195. try {
  2196. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2197. scripts_echoLog({
  2198. text: i18n('needInit')
  2199. });
  2200. return false;
  2201. }
  2202. const prom = [];
  2203. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2204. scripts_echoLog({
  2205. type: 'globalOptionsSkip',
  2206. text: 'instagram.users'
  2207. });
  2208. } else {
  2209. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2210. var _link$match;
  2211. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2212. });
  2213. if (realUsers.length > 0) {
  2214. for (const username of realUsers) {
  2215. if (doTask) {
  2216. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2217. } else {
  2218. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2219. }
  2220. await delay(1e3);
  2221. }
  2222. }
  2223. }
  2224. return await Promise.all(prom).then(() => true);
  2225. } catch (error) {
  2226. throwError(error, 'Instagram.toggleUsers');
  2227. return false;
  2228. }
  2229. }
  2230. }
  2231. async function _getUserInfo2() {
  2232. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2233. try {
  2234. const logStatus = scripts_echoLog({
  2235. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2236. text: name
  2237. });
  2238. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2239. if (userId && name !== 'instagram') {
  2240. logStatus.success();
  2241. return userId;
  2242. }
  2243. const {
  2244. result,
  2245. statusText,
  2246. status,
  2247. data
  2248. } = await tools_httpRequest({
  2249. url: `https://www.instagram.com/${name}/`,
  2250. method: 'GET'
  2251. });
  2252. if (result === 'Success') {
  2253. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2254. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2255. return false;
  2256. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2257. logStatus.error(`Error:${i18n('insBanned')}`);
  2258. return false;
  2259. }
  2260. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2261. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2262. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2263. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2264. if (name === 'instagram') {
  2265. if (csrftoken && hash) {
  2266. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2267. csrftoken: csrftoken,
  2268. hash: hash
  2269. });
  2270. return true;
  2271. }
  2272. return false;
  2273. }
  2274. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2275. if (id) {
  2276. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2277. logStatus.success();
  2278. return id;
  2279. }
  2280. logStatus.error('Error: Get ins data error!');
  2281. return false;
  2282. }
  2283. logStatus.error(`${result}:${statusText}(${status})`);
  2284. return false;
  2285. }
  2286. return false;
  2287. } catch (error) {
  2288. throwError(error, 'Instagram.getUserInfo');
  2289. return false;
  2290. }
  2291. }
  2292. async function _followUser2(name) {
  2293. try {
  2294. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2295. if (!id) {
  2296. return false;
  2297. }
  2298. const logStatus = scripts_echoLog({
  2299. type: 'followingIns',
  2300. text: name
  2301. });
  2302. const {
  2303. result,
  2304. statusText,
  2305. status,
  2306. data
  2307. } = await tools_httpRequest({
  2308. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2309. method: 'POST',
  2310. dataType: 'json',
  2311. headers: {
  2312. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2313. origin: 'https://www.instagram.com',
  2314. referer: `https://www.instagram.com/${name}/`,
  2315. 'content-type': 'application/x-www-form-urlencoded',
  2316. 'sec-fetch-site': 'same-origin',
  2317. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2318. }
  2319. });
  2320. if (result === 'Success') {
  2321. var _data$response, _data$response2;
  2322. 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') {
  2323. logStatus.success();
  2324. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2325. return true;
  2326. }
  2327. 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})`}`);
  2328. return false;
  2329. }
  2330. logStatus.error(`${result}:${statusText}(${status})`);
  2331. return false;
  2332. } catch (error) {
  2333. throwError(error, 'Instagram.followUser');
  2334. return false;
  2335. }
  2336. }
  2337. async function _unfollowUser2(name) {
  2338. try {
  2339. if (this.whiteList.users.includes(name)) {
  2340. scripts_echoLog({
  2341. type: 'whiteList',
  2342. text: 'Instagram.unfollowUser',
  2343. id: name
  2344. });
  2345. return true;
  2346. }
  2347. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2348. if (!id) {
  2349. return false;
  2350. }
  2351. const logStatus = scripts_echoLog({
  2352. type: 'unfollowingIns',
  2353. text: name
  2354. });
  2355. const {
  2356. result,
  2357. statusText,
  2358. status,
  2359. data
  2360. } = await tools_httpRequest({
  2361. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2362. method: 'POST',
  2363. dataType: 'json',
  2364. headers: {
  2365. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2366. origin: 'https://www.instagram.com',
  2367. referer: `https://www.instagram.com/${name}/`,
  2368. 'content-type': 'application/x-www-form-urlencoded',
  2369. 'sec-fetch-site': 'same-origin',
  2370. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2371. }
  2372. });
  2373. if (result === 'Success') {
  2374. var _data$response3;
  2375. 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') {
  2376. logStatus.success();
  2377. return true;
  2378. }
  2379. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2380. return false;
  2381. }
  2382. logStatus.error(`${result}:${statusText}(${status})`);
  2383. return false;
  2384. } catch (error) {
  2385. throwError(error, 'Instagram.unfollowUser');
  2386. return false;
  2387. }
  2388. }
  2389. function Instagram_setCache2(name, id) {
  2390. try {
  2391. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2392. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2393. } catch (error) {
  2394. throwError(error, 'Instagram.setCache');
  2395. }
  2396. }
  2397. const social_Instagram = Instagram;
  2398. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2399. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2400. privateSet.add(obj);
  2401. }
  2402. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2403. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2404. privateMap.set(obj, value);
  2405. }
  2406. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2407. if (privateCollection.has(obj)) {
  2408. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2409. }
  2410. }
  2411. function Reddit_defineProperty(obj, key, value) {
  2412. if (key in obj) {
  2413. Object.defineProperty(obj, key, {
  2414. value: value,
  2415. enumerable: true,
  2416. configurable: true,
  2417. writable: true
  2418. });
  2419. } else {
  2420. obj[key] = value;
  2421. }
  2422. return obj;
  2423. }
  2424. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2425. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2426. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2427. return value;
  2428. }
  2429. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2430. if (descriptor.set) {
  2431. descriptor.set.call(receiver, value);
  2432. } else {
  2433. if (!descriptor.writable) {
  2434. throw new TypeError('attempted to set read only private field');
  2435. }
  2436. descriptor.value = value;
  2437. }
  2438. }
  2439. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2440. if (!privateSet.has(receiver)) {
  2441. throw new TypeError('attempted to get private field on non-instance');
  2442. }
  2443. return fn;
  2444. }
  2445. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2446. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2447. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2448. }
  2449. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2450. if (!privateMap.has(receiver)) {
  2451. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2452. }
  2453. return privateMap.get(receiver);
  2454. }
  2455. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2456. if (descriptor.get) {
  2457. return descriptor.get.call(receiver);
  2458. }
  2459. return descriptor.value;
  2460. }
  2461. const Reddit_defaultTasks = {
  2462. reddits: []
  2463. };
  2464. var Reddit_auth = new WeakMap();
  2465. var Reddit_initialized = new WeakMap();
  2466. var _useBeta = new WeakSet();
  2467. var Reddit_updateAuth = new WeakSet();
  2468. class Reddit extends social_Social {
  2469. constructor() {
  2470. var _GM_getValue;
  2471. super(...arguments);
  2472. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2473. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2474. Reddit_defineProperty(this, 'tasks', {
  2475. ...Reddit_defaultTasks
  2476. });
  2477. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || {
  2478. ...Reddit_defaultTasks
  2479. });
  2480. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2481. writable: true,
  2482. value: void 0
  2483. });
  2484. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2485. writable: true,
  2486. value: false
  2487. });
  2488. }
  2489. async init() {
  2490. try {
  2491. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2492. return true;
  2493. }
  2494. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2495. if (isVerified) {
  2496. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2497. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2498. return true;
  2499. }
  2500. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2501. return false;
  2502. } catch (error) {
  2503. throwError(error, 'Reddit.init');
  2504. return false;
  2505. }
  2506. }
  2507. async toggleTask(_ref) {
  2508. let {
  2509. name,
  2510. doTask = true
  2511. } = _ref;
  2512. try {
  2513. if (!doTask && this.whiteList.reddits.includes(name)) {
  2514. scripts_echoLog({
  2515. type: 'whiteList',
  2516. text: 'Reddit.undoTask',
  2517. id: name
  2518. });
  2519. return true;
  2520. }
  2521. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2522. if (/^u_/.test(name)) {
  2523. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2524. }
  2525. const logStatus = scripts_echoLog({
  2526. type: type,
  2527. text: name
  2528. });
  2529. const {
  2530. result,
  2531. statusText,
  2532. status,
  2533. data
  2534. } = await tools_httpRequest({
  2535. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2536. method: 'POST',
  2537. headers: {
  2538. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2539. 'content-type': 'application/x-www-form-urlencoded'
  2540. },
  2541. data: $.param({
  2542. action: doTask ? 'sub' : 'unsub',
  2543. sr_name: name,
  2544. api_type: 'json'
  2545. })
  2546. });
  2547. if (result === 'Success') {
  2548. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2549. logStatus.success();
  2550. if (doTask) {
  2551. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2552. }
  2553. return true;
  2554. }
  2555. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2556. return false;
  2557. }
  2558. logStatus.error(`${result}:${statusText}(${status})`);
  2559. return false;
  2560. } catch (error) {
  2561. throwError(error, 'Reddit.toggleTask');
  2562. return false;
  2563. }
  2564. }
  2565. async toggle(_ref2) {
  2566. let {
  2567. doTask = true,
  2568. redditLinks = []
  2569. } = _ref2;
  2570. try {
  2571. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2572. scripts_echoLog({
  2573. text: i18n('needInit')
  2574. });
  2575. return false;
  2576. }
  2577. const prom = [];
  2578. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2579. scripts_echoLog({
  2580. type: 'globalOptionsSkip',
  2581. text: 'reddit.reddits'
  2582. });
  2583. } else {
  2584. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2585. var _link$match, _link$match2;
  2586. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2587. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2588. if (userName) {
  2589. return name || userName;
  2590. }
  2591. return name;
  2592. });
  2593. if (realReddits.length > 0) {
  2594. for (const name of realReddits) {
  2595. prom.push(this.toggleTask({
  2596. name: name,
  2597. doTask: doTask
  2598. }));
  2599. await delay(1e3);
  2600. }
  2601. }
  2602. }
  2603. return await Promise.all(prom).then(() => true);
  2604. } catch (error) {
  2605. throwError(error, 'Reddit.toggle');
  2606. return false;
  2607. }
  2608. }
  2609. }
  2610. async function _useBeta2() {
  2611. try {
  2612. const logStatus = scripts_echoLog({
  2613. text: i18n('changingRedditVersion')
  2614. });
  2615. GM_setValue('redditAuth', null);
  2616. return await new Promise(resolve => {
  2617. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2618. active: true,
  2619. insert: true,
  2620. setParent: true
  2621. });
  2622. newTab.onclose = async () => {
  2623. logStatus.success();
  2624. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2625. };
  2626. });
  2627. } catch (error) {
  2628. throwError(error, 'Reddit.useBeta');
  2629. return false;
  2630. }
  2631. }
  2632. async function Reddit_updateAuth2() {
  2633. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2634. try {
  2635. const logStatus = scripts_echoLog({
  2636. text: i18n('updatingAuth', 'Reddit')
  2637. });
  2638. const {
  2639. result,
  2640. statusText,
  2641. status,
  2642. data
  2643. } = await tools_httpRequest({
  2644. url: 'https://www.reddit.com/',
  2645. method: 'GET',
  2646. nochche: true,
  2647. headers: {
  2648. 'Cache-Control': 'no-cache'
  2649. }
  2650. });
  2651. if (result === 'Success') {
  2652. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2653. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2654. return false;
  2655. }
  2656. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2657. var _data$responseText$ma;
  2658. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2659. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2660. }
  2661. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2662. if (accessToken) {
  2663. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2664. token: accessToken
  2665. });
  2666. logStatus.success();
  2667. return true;
  2668. }
  2669. logStatus.error('Error: Parameter "accessToken" not found!');
  2670. return false;
  2671. }
  2672. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2673. return false;
  2674. }
  2675. logStatus.error(`${result}:${statusText}(${status})`);
  2676. return false;
  2677. } catch (error) {
  2678. throwError(error, 'Reddit.updateAuth');
  2679. return false;
  2680. }
  2681. }
  2682. const social_Reddit = Reddit;
  2683. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2684. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2685. privateSet.add(obj);
  2686. }
  2687. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2688. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2689. privateMap.set(obj, value);
  2690. }
  2691. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2692. if (privateCollection.has(obj)) {
  2693. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2694. }
  2695. }
  2696. function Twitch_defineProperty(obj, key, value) {
  2697. if (key in obj) {
  2698. Object.defineProperty(obj, key, {
  2699. value: value,
  2700. enumerable: true,
  2701. configurable: true,
  2702. writable: true
  2703. });
  2704. } else {
  2705. obj[key] = value;
  2706. }
  2707. return obj;
  2708. }
  2709. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2710. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2711. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2712. return value;
  2713. }
  2714. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2715. if (descriptor.set) {
  2716. descriptor.set.call(receiver, value);
  2717. } else {
  2718. if (!descriptor.writable) {
  2719. throw new TypeError('attempted to set read only private field');
  2720. }
  2721. descriptor.value = value;
  2722. }
  2723. }
  2724. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2725. if (!privateSet.has(receiver)) {
  2726. throw new TypeError('attempted to get private field on non-instance');
  2727. }
  2728. return fn;
  2729. }
  2730. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2731. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2732. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2733. }
  2734. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2735. if (!privateMap.has(receiver)) {
  2736. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2737. }
  2738. return privateMap.get(receiver);
  2739. }
  2740. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2741. if (descriptor.get) {
  2742. return descriptor.get.call(receiver);
  2743. }
  2744. return descriptor.value;
  2745. }
  2746. const Twitch_defaultTasks = {
  2747. channels: []
  2748. };
  2749. var Twitch_auth = new WeakMap();
  2750. var Twitch_cache = new WeakMap();
  2751. var Twitch_initialized = new WeakMap();
  2752. var Twitch_verifyAuth = new WeakSet();
  2753. var Twitch_updateAuth = new WeakSet();
  2754. var _toggleChannel = new WeakSet();
  2755. var _getChannelId = new WeakSet();
  2756. var Twitch_setCache = new WeakSet();
  2757. class Twitch extends social_Social {
  2758. constructor() {
  2759. var _GM_getValue;
  2760. super(...arguments);
  2761. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2762. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2763. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2764. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2765. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2766. Twitch_defineProperty(this, 'tasks', {
  2767. ...Twitch_defaultTasks
  2768. });
  2769. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || {
  2770. ...Twitch_defaultTasks
  2771. });
  2772. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2773. writable: true,
  2774. value: GM_getValue('twitchAuth') || {}
  2775. });
  2776. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2777. writable: true,
  2778. value: GM_getValue('twitchCache') || {}
  2779. });
  2780. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2781. writable: true,
  2782. value: false
  2783. });
  2784. }
  2785. async init() {
  2786. try {
  2787. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2788. return true;
  2789. }
  2790. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2791. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2792. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2793. return true;
  2794. }
  2795. return false;
  2796. }
  2797. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2798. if (isVerified) {
  2799. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2800. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2801. return true;
  2802. }
  2803. GM_setValue('twitchAuth', null);
  2804. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2805. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2806. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2807. return true;
  2808. }
  2809. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2810. return false;
  2811. } catch (error) {
  2812. throwError(error, 'Twitch.init');
  2813. return false;
  2814. }
  2815. }
  2816. async toggle(_ref) {
  2817. let {
  2818. doTask = true,
  2819. channelLinks = []
  2820. } = _ref;
  2821. try {
  2822. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2823. scripts_echoLog({
  2824. text: i18n('needInit')
  2825. });
  2826. return false;
  2827. }
  2828. const prom = [];
  2829. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2830. scripts_echoLog({
  2831. type: 'globalOptionsSkip',
  2832. text: 'twitch.channels'
  2833. });
  2834. } else {
  2835. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2836. var _link$match;
  2837. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2838. });
  2839. if (realChannels.length > 0) {
  2840. for (const channel of realChannels) {
  2841. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2842. name: channel,
  2843. doTask: doTask
  2844. }));
  2845. await delay(1e3);
  2846. }
  2847. }
  2848. }
  2849. return Promise.all(prom).then(() => true);
  2850. } catch (error) {
  2851. throwError(error, 'Twitch.toggle');
  2852. return false;
  2853. }
  2854. }
  2855. }
  2856. async function Twitch_verifyAuth2() {
  2857. try {
  2858. const logStatus = scripts_echoLog({
  2859. text: i18n('verifyingAuth', 'Twitch')
  2860. });
  2861. const {
  2862. result,
  2863. statusText,
  2864. status,
  2865. data
  2866. } = await tools_httpRequest({
  2867. url: 'https://gql.twitch.tv/gql',
  2868. method: 'POST',
  2869. dataType: 'json',
  2870. headers: {
  2871. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2872. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2873. },
  2874. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2875. });
  2876. if (result === 'Success') {
  2877. var _data$response, _data$response$, _data$response$$data;
  2878. 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) {
  2879. logStatus.success();
  2880. return true;
  2881. }
  2882. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2883. return false;
  2884. }
  2885. logStatus.error(`${result}:${statusText}(${status})`);
  2886. return false;
  2887. } catch (error) {
  2888. throwError(error, 'Twitch.verifyAuth');
  2889. return false;
  2890. }
  2891. }
  2892. async function Twitch_updateAuth2() {
  2893. try {
  2894. const logStatus = scripts_echoLog({
  2895. text: i18n('updatingAuth', 'Twitch')
  2896. });
  2897. return await new Promise(resolve => {
  2898. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2899. active: true,
  2900. insert: true,
  2901. setParent: true
  2902. });
  2903. newTab.onclose = async () => {
  2904. const auth = GM_getValue('twitchAuth');
  2905. if (auth) {
  2906. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2907. logStatus.success();
  2908. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2909. } else {
  2910. logStatus.error('Error: Update twitch auth failed!');
  2911. resolve(false);
  2912. }
  2913. };
  2914. });
  2915. } catch (error) {
  2916. throwError(error, 'Twitch.updateAuth');
  2917. return false;
  2918. }
  2919. }
  2920. async function _toggleChannel2(_ref2) {
  2921. let {
  2922. name,
  2923. doTask = true
  2924. } = _ref2;
  2925. try {
  2926. if (!doTask && this.whiteList.channels.includes(name)) {
  2927. scripts_echoLog({
  2928. type: 'whiteList',
  2929. text: 'Twitch.unfollowChannel',
  2930. id: name
  2931. });
  2932. return true;
  2933. }
  2934. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2935. if (!channelId) {
  2936. return false;
  2937. }
  2938. const logStatus = scripts_echoLog({
  2939. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2940. text: name
  2941. });
  2942. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2943. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2944. const {
  2945. result,
  2946. statusText,
  2947. status,
  2948. data
  2949. } = await tools_httpRequest({
  2950. url: 'https://gql.twitch.tv/gql',
  2951. method: 'POST',
  2952. dataType: 'json',
  2953. headers: {
  2954. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2955. },
  2956. data: doTask ? followData : unfollowData
  2957. });
  2958. if (result === 'Success') {
  2959. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2960. logStatus.success();
  2961. if (doTask) {
  2962. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2963. }
  2964. return true;
  2965. }
  2966. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2967. return false;
  2968. }
  2969. logStatus.error(`${result}:${statusText}(${status})`);
  2970. return false;
  2971. } catch (error) {
  2972. throwError(error, 'Twitch.toggleChannel');
  2973. return false;
  2974. }
  2975. }
  2976. async function _getChannelId2(name) {
  2977. try {
  2978. const logStatus = scripts_echoLog({
  2979. type: 'gettingTwitchChannelId',
  2980. text: name
  2981. });
  2982. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  2983. if (channelId) {
  2984. logStatus.success();
  2985. return channelId;
  2986. }
  2987. const {
  2988. result,
  2989. statusText,
  2990. status,
  2991. data
  2992. } = await tools_httpRequest({
  2993. url: 'https://gql.twitch.tv/gql',
  2994. method: 'POST',
  2995. headers: {
  2996. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2997. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2998. },
  2999. responseType: 'json',
  3000. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3001. });
  3002. if (result === 'Success') {
  3003. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3004. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3005. 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);
  3006. if (channelId) {
  3007. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3008. logStatus.success();
  3009. return channelId;
  3010. }
  3011. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3012. return false;
  3013. }
  3014. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3015. return false;
  3016. }
  3017. logStatus.error(`${result}:${statusText}(${status})`);
  3018. return false;
  3019. } catch (error) {
  3020. throwError(error, 'Twitch.getChannelId');
  3021. return false;
  3022. }
  3023. }
  3024. function Twitch_setCache2(name, id) {
  3025. try {
  3026. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3027. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3028. } catch (error) {
  3029. throwError(error, 'Twitch.setCache');
  3030. }
  3031. }
  3032. const social_Twitch = Twitch;
  3033. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3034. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3035. privateSet.add(obj);
  3036. }
  3037. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3038. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3039. privateMap.set(obj, value);
  3040. }
  3041. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3042. if (privateCollection.has(obj)) {
  3043. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3044. }
  3045. }
  3046. function Twitter_defineProperty(obj, key, value) {
  3047. if (key in obj) {
  3048. Object.defineProperty(obj, key, {
  3049. value: value,
  3050. enumerable: true,
  3051. configurable: true,
  3052. writable: true
  3053. });
  3054. } else {
  3055. obj[key] = value;
  3056. }
  3057. return obj;
  3058. }
  3059. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3060. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3061. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3062. return value;
  3063. }
  3064. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3065. if (descriptor.set) {
  3066. descriptor.set.call(receiver, value);
  3067. } else {
  3068. if (!descriptor.writable) {
  3069. throw new TypeError('attempted to set read only private field');
  3070. }
  3071. descriptor.value = value;
  3072. }
  3073. }
  3074. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3075. if (!privateSet.has(receiver)) {
  3076. throw new TypeError('attempted to get private field on non-instance');
  3077. }
  3078. return fn;
  3079. }
  3080. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3081. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3082. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3083. }
  3084. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3085. if (!privateMap.has(receiver)) {
  3086. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3087. }
  3088. return privateMap.get(receiver);
  3089. }
  3090. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3091. if (descriptor.get) {
  3092. return descriptor.get.call(receiver);
  3093. }
  3094. return descriptor.value;
  3095. }
  3096. const Twitter_defaultTasks = {
  3097. users: [],
  3098. retweets: [],
  3099. likes: []
  3100. };
  3101. var _verifyId = new WeakMap();
  3102. var Twitter_auth = new WeakMap();
  3103. var Twitter_cache = new WeakMap();
  3104. var Twitter_initialized = new WeakMap();
  3105. var Twitter_verifyAuth = new WeakSet();
  3106. var Twitter_updateAuth = new WeakSet();
  3107. var _toggleUser = new WeakSet();
  3108. var _toggleRetweet = new WeakSet();
  3109. var Twitter_setCache = new WeakSet();
  3110. class Twitter extends social_Social {
  3111. constructor() {
  3112. var _GM_getValue;
  3113. super(...arguments);
  3114. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3115. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3116. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3117. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3118. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3119. Twitter_defineProperty(this, 'tasks', {
  3120. ...Twitter_defaultTasks
  3121. });
  3122. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || {
  3123. ...Twitter_defaultTasks
  3124. });
  3125. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3126. writable: true,
  3127. value: globalOptions.other.twitterVerifyId
  3128. });
  3129. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3130. writable: true,
  3131. value: GM_getValue('twitterAuth') || {}
  3132. });
  3133. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3134. writable: true,
  3135. value: GM_getValue('twitterCache') || {}
  3136. });
  3137. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3138. writable: true,
  3139. value: false
  3140. });
  3141. }
  3142. async init() {
  3143. try {
  3144. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3145. return true;
  3146. }
  3147. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3148. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3149. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3150. return true;
  3151. }
  3152. return false;
  3153. }
  3154. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3155. if (isVerified) {
  3156. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3157. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3158. return true;
  3159. }
  3160. GM_setValue('twitterAuth', null);
  3161. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3162. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3163. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3164. return true;
  3165. }
  3166. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3167. return false;
  3168. } catch (error) {
  3169. throwError(error, 'Twitter.init');
  3170. return false;
  3171. }
  3172. }
  3173. async userName2id(name) {
  3174. try {
  3175. const logStatus = scripts_echoLog({
  3176. type: 'gettingTwitterUserId',
  3177. text: name
  3178. });
  3179. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3180. if (userId) {
  3181. logStatus.success();
  3182. return userId;
  3183. }
  3184. const {
  3185. result,
  3186. statusText,
  3187. status,
  3188. data
  3189. } = await tools_httpRequest({
  3190. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3191. method: 'GET',
  3192. headers: {
  3193. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3194. 'content-type': 'application/json'
  3195. },
  3196. responseType: 'json',
  3197. anonymous: true
  3198. });
  3199. if (result === 'Success') {
  3200. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3201. var _response, _response$data, _response$data$user;
  3202. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3203. if (!response) {
  3204. try {
  3205. response = JSON.parse(data.responseText);
  3206. } catch (error) {
  3207. response = null;
  3208. }
  3209. }
  3210. 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);
  3211. if (userId) {
  3212. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3213. logStatus.success();
  3214. return userId;
  3215. }
  3216. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3217. return false;
  3218. }
  3219. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3220. return false;
  3221. }
  3222. logStatus.error(`${result}:${statusText}(${status})`);
  3223. return false;
  3224. } catch (error) {
  3225. throwError(error, 'Twitter.getUserId');
  3226. return false;
  3227. }
  3228. }
  3229. async toggle(_ref) {
  3230. let {
  3231. doTask = true,
  3232. userLinks = [],
  3233. retweetLinks = []
  3234. } = _ref;
  3235. try {
  3236. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3237. scripts_echoLog({
  3238. text: i18n('needInit')
  3239. });
  3240. return false;
  3241. }
  3242. const prom = [];
  3243. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3244. scripts_echoLog({
  3245. type: 'globalOptionsSkip',
  3246. text: 'twitter.users'
  3247. });
  3248. } else {
  3249. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3250. var _link$match;
  3251. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3252. });
  3253. if (realUsers.length > 0) {
  3254. for (const user of realUsers) {
  3255. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3256. name: user,
  3257. doTask: doTask
  3258. }));
  3259. await delay(1e3);
  3260. }
  3261. }
  3262. }
  3263. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3264. scripts_echoLog({
  3265. type: 'globalOptionsSkip',
  3266. text: 'twitter.retweets'
  3267. });
  3268. } else {
  3269. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3270. var _link$match2;
  3271. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3272. });
  3273. if (realRetweets.length > 0) {
  3274. for (const retweet of realRetweets) {
  3275. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3276. retweetId: retweet,
  3277. doTask: doTask
  3278. }));
  3279. await delay(1e3);
  3280. }
  3281. }
  3282. }
  3283. return Promise.all(prom).then(() => true);
  3284. } catch (error) {
  3285. throwError(error, 'Twitter.toggle');
  3286. return false;
  3287. }
  3288. }
  3289. }
  3290. async function Twitter_verifyAuth2() {
  3291. try {
  3292. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3293. name: 'verify',
  3294. doTask: true,
  3295. verify: true
  3296. });
  3297. } catch (error) {
  3298. throwError(error, 'Twitter.verifyAuth');
  3299. return false;
  3300. }
  3301. }
  3302. async function Twitter_updateAuth2() {
  3303. try {
  3304. const logStatus = scripts_echoLog({
  3305. text: i18n('updatingAuth', 'Twitter')
  3306. });
  3307. return await new Promise(resolve => {
  3308. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3309. active: true,
  3310. insert: true,
  3311. setParent: true
  3312. });
  3313. newTab.onclose = async () => {
  3314. const auth = GM_getValue('twitterAuth');
  3315. if (auth) {
  3316. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3317. logStatus.success();
  3318. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3319. } else {
  3320. logStatus.error('Error: Update twitter auth failed!');
  3321. resolve(false);
  3322. }
  3323. };
  3324. });
  3325. } catch (error) {
  3326. throwError(error, 'Twitter.updateToken');
  3327. return false;
  3328. }
  3329. }
  3330. async function _toggleUser2(_ref2) {
  3331. let {
  3332. name,
  3333. doTask = true,
  3334. verify = false
  3335. } = _ref2;
  3336. try {
  3337. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3338. scripts_echoLog({
  3339. type: 'whiteList',
  3340. text: 'Twitter.unfollowUser',
  3341. id: name
  3342. });
  3343. return true;
  3344. }
  3345. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3346. if (!userId) {
  3347. return false;
  3348. }
  3349. const logStatus = verify ? scripts_echoLog({
  3350. text: i18n('verifyingAuth', 'Twitter')
  3351. }) : scripts_echoLog({
  3352. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3353. text: name
  3354. });
  3355. const {
  3356. result,
  3357. statusText,
  3358. status,
  3359. data
  3360. } = await tools_httpRequest({
  3361. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3362. method: 'POST',
  3363. headers: {
  3364. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3365. 'Content-Type': 'application/x-www-form-urlencoded',
  3366. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3367. },
  3368. responseType: 'json',
  3369. data: $.param({
  3370. include_profile_interstitial_type: 1,
  3371. include_blocking: 1,
  3372. include_blocked_by: 1,
  3373. include_followed_by: 1,
  3374. include_want_retweets: 1,
  3375. include_mute_edge: 1,
  3376. include_can_dm: 1,
  3377. include_can_media_tag: 1,
  3378. skip_status: 1,
  3379. id: userId
  3380. })
  3381. });
  3382. if (result === 'Success') {
  3383. var _data$response, _data$response$errors, _data$response$errors2;
  3384. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3385. logStatus.success();
  3386. if (doTask && !verify) {
  3387. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3388. }
  3389. return true;
  3390. }
  3391. 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) {
  3392. logStatus.success();
  3393. return true;
  3394. }
  3395. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3396. return false;
  3397. }
  3398. logStatus.error(`${result}:${statusText}(${status})`);
  3399. return false;
  3400. } catch (error) {
  3401. throwError(error, 'Twitter.toggleUser');
  3402. return false;
  3403. }
  3404. }
  3405. async function _toggleRetweet2(_ref3) {
  3406. let {
  3407. retweetId,
  3408. doTask = true
  3409. } = _ref3;
  3410. try {
  3411. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3412. scripts_echoLog({
  3413. type: 'whiteList',
  3414. text: 'Twitter.unretweet',
  3415. id: retweetId
  3416. });
  3417. return true;
  3418. }
  3419. const logStatus = scripts_echoLog({
  3420. type: `${doTask ? '' : 'un'}retweetting`,
  3421. text: retweetId
  3422. });
  3423. const {
  3424. result,
  3425. statusText,
  3426. status,
  3427. data
  3428. } = await tools_httpRequest({
  3429. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3430. method: 'POST',
  3431. headers: {
  3432. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3433. 'Content-Type': 'application/x-www-form-urlencoded',
  3434. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3435. },
  3436. data: $.param({
  3437. tweet_mode: 'extended',
  3438. id: retweetId
  3439. }),
  3440. responseType: 'json'
  3441. });
  3442. if (result === 'Success') {
  3443. var _data$response2, _data$response2$error, _data$response2$error2;
  3444. 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) {
  3445. logStatus.success();
  3446. if (doTask) {
  3447. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3448. }
  3449. return true;
  3450. }
  3451. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3452. return false;
  3453. }
  3454. logStatus.error(`${result}:${statusText}(${status})`);
  3455. return false;
  3456. } catch (error) {
  3457. throwError(error, 'Twitter.toggleRetweet');
  3458. return false;
  3459. }
  3460. }
  3461. function Twitter_setCache2(name, id) {
  3462. try {
  3463. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3464. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3465. } catch (error) {
  3466. throwError(error, 'Twitter.setCache');
  3467. }
  3468. }
  3469. const social_Twitter = Twitter;
  3470. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3471. Vk_checkPrivateRedeclaration(obj, privateSet);
  3472. privateSet.add(obj);
  3473. }
  3474. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3475. Vk_checkPrivateRedeclaration(obj, privateMap);
  3476. privateMap.set(obj, value);
  3477. }
  3478. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3479. if (privateCollection.has(obj)) {
  3480. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3481. }
  3482. }
  3483. function Vk_defineProperty(obj, key, value) {
  3484. if (key in obj) {
  3485. Object.defineProperty(obj, key, {
  3486. value: value,
  3487. enumerable: true,
  3488. configurable: true,
  3489. writable: true
  3490. });
  3491. } else {
  3492. obj[key] = value;
  3493. }
  3494. return obj;
  3495. }
  3496. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3497. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3498. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3499. return value;
  3500. }
  3501. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3502. if (descriptor.set) {
  3503. descriptor.set.call(receiver, value);
  3504. } else {
  3505. if (!descriptor.writable) {
  3506. throw new TypeError('attempted to set read only private field');
  3507. }
  3508. descriptor.value = value;
  3509. }
  3510. }
  3511. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3512. if (!privateSet.has(receiver)) {
  3513. throw new TypeError('attempted to get private field on non-instance');
  3514. }
  3515. return fn;
  3516. }
  3517. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3518. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3519. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3520. }
  3521. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3522. if (!privateMap.has(receiver)) {
  3523. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3524. }
  3525. return privateMap.get(receiver);
  3526. }
  3527. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3528. if (descriptor.get) {
  3529. return descriptor.get.call(receiver);
  3530. }
  3531. return descriptor.value;
  3532. }
  3533. const Vk_defaultTasks = {
  3534. names: []
  3535. };
  3536. var _username = new WeakMap();
  3537. var Vk_cache = new WeakMap();
  3538. var Vk_initialized = new WeakMap();
  3539. var Vk_verifyAuth = new WeakSet();
  3540. var _toggleGroup = new WeakSet();
  3541. var _togglePublic = new WeakSet();
  3542. var _sendWall = new WeakSet();
  3543. var _deleteWall = new WeakSet();
  3544. var _getId = new WeakSet();
  3545. var _toggleVk = new WeakSet();
  3546. var Vk_setCache = new WeakSet();
  3547. class Vk extends social_Social {
  3548. constructor() {
  3549. var _GM_getValue;
  3550. super(...arguments);
  3551. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3552. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3553. Vk_classPrivateMethodInitSpec(this, _getId);
  3554. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3555. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3556. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3557. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3558. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3559. Vk_defineProperty(this, 'tasks', {
  3560. ...Vk_defaultTasks
  3561. });
  3562. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || {
  3563. ...Vk_defaultTasks
  3564. });
  3565. Vk_classPrivateFieldInitSpec(this, _username, {
  3566. writable: true,
  3567. value: ''
  3568. });
  3569. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3570. writable: true,
  3571. value: GM_getValue('vkCache') || {}
  3572. });
  3573. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3574. writable: true,
  3575. value: false
  3576. });
  3577. }
  3578. async init() {
  3579. try {
  3580. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3581. return true;
  3582. }
  3583. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3584. if (isVerified) {
  3585. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3586. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3587. return true;
  3588. }
  3589. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3590. return false;
  3591. } catch (error) {
  3592. throwError(error, 'Vk.init');
  3593. return false;
  3594. }
  3595. }
  3596. async toggle(_ref) {
  3597. let {
  3598. doTask = true,
  3599. nameLinks = []
  3600. } = _ref;
  3601. try {
  3602. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3603. scripts_echoLog({
  3604. text: i18n('needInit')
  3605. });
  3606. return false;
  3607. }
  3608. const prom = [];
  3609. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3610. scripts_echoLog({
  3611. type: 'globalOptionsSkip',
  3612. text: 'vk.names'
  3613. });
  3614. } else {
  3615. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3616. var _link$match;
  3617. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3618. });
  3619. if (realNames.length > 0) {
  3620. for (const name of realNames) {
  3621. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3622. name: name,
  3623. doTask: doTask
  3624. }));
  3625. await delay(1e3);
  3626. }
  3627. }
  3628. }
  3629. return Promise.all(prom).then(() => true);
  3630. } catch (error) {
  3631. throwError(error, 'Vk.toggle');
  3632. return false;
  3633. }
  3634. }
  3635. }
  3636. async function Vk_verifyAuth2() {
  3637. try {
  3638. const logStatus = scripts_echoLog({
  3639. text: i18n('verifyAuth', 'Vk')
  3640. });
  3641. const {
  3642. result,
  3643. statusText,
  3644. status,
  3645. data
  3646. } = await tools_httpRequest({
  3647. url: 'https://vk.com/im',
  3648. method: 'GET'
  3649. });
  3650. if (result === 'Success') {
  3651. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3652. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3653. return false;
  3654. }
  3655. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3656. var _data$responseText$ma;
  3657. 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]) || '');
  3658. logStatus.success();
  3659. return true;
  3660. }
  3661. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3662. return false;
  3663. }
  3664. logStatus.error(`${result}:${statusText}(${status})`);
  3665. return false;
  3666. } catch (error) {
  3667. throwError(error, 'Vk.verifyAuth');
  3668. return false;
  3669. }
  3670. }
  3671. async function _toggleGroup2(name, dataParam) {
  3672. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3673. try {
  3674. const logStatus = scripts_echoLog({
  3675. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3676. text: name
  3677. });
  3678. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3679. logStatus.success();
  3680. return true;
  3681. }
  3682. const reqData = {
  3683. act: doTask ? 'enter' : 'leave',
  3684. al: 1,
  3685. gid: dataParam.groupId,
  3686. hash: dataParam.groupHash
  3687. };
  3688. if (doTask) {
  3689. reqData.context = '_';
  3690. }
  3691. const {
  3692. result,
  3693. statusText,
  3694. status,
  3695. data
  3696. } = await tools_httpRequest({
  3697. url: 'https://vk.com/al_groups.php',
  3698. method: 'POST',
  3699. headers: {
  3700. origin: 'https://vk.com',
  3701. referer: `https://vk.com/${name}`,
  3702. 'content-type': 'application/x-www-form-urlencoded'
  3703. },
  3704. data: $.param(reqData)
  3705. });
  3706. if (result === 'Success') {
  3707. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3708. logStatus.success();
  3709. if (doTask) {
  3710. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3711. }
  3712. return true;
  3713. }
  3714. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3715. return false;
  3716. }
  3717. logStatus.error(`${result}:${statusText}(${status})`);
  3718. return false;
  3719. } catch (error) {
  3720. throwError(error, 'Vk.toggleGroup');
  3721. return false;
  3722. }
  3723. }
  3724. async function _togglePublic2(name, dataParam) {
  3725. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3726. try {
  3727. const logStatus = scripts_echoLog({
  3728. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3729. text: name
  3730. });
  3731. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3732. logStatus.success();
  3733. return true;
  3734. }
  3735. const {
  3736. result,
  3737. statusText,
  3738. status,
  3739. data
  3740. } = await tools_httpRequest({
  3741. url: 'https://vk.com/al_public.php',
  3742. method: 'POST',
  3743. headers: {
  3744. origin: 'https://vk.com',
  3745. referer: `https://vk.com/${name}`,
  3746. 'content-type': 'application/x-www-form-urlencoded'
  3747. },
  3748. data: $.param({
  3749. act: doTask ? 'a_enter' : 'a_leave',
  3750. al: 1,
  3751. pid: dataParam.publicPid,
  3752. hash: dataParam.publicHash
  3753. })
  3754. });
  3755. if (result === 'Success') {
  3756. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3757. logStatus.success();
  3758. if (doTask) {
  3759. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3760. }
  3761. return true;
  3762. }
  3763. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3764. return false;
  3765. }
  3766. logStatus.error(`${result}:${statusText}(${status})`);
  3767. return false;
  3768. } catch (error) {
  3769. throwError(error, 'Vk.togglePublic');
  3770. return false;
  3771. }
  3772. }
  3773. async function _sendWall2(name) {
  3774. try {
  3775. const logStatus = scripts_echoLog({
  3776. type: 'sendingVkWall',
  3777. text: name
  3778. });
  3779. const {
  3780. result,
  3781. statusText,
  3782. status,
  3783. data
  3784. } = await tools_httpRequest({
  3785. url: 'https://vk.com/like.php',
  3786. method: 'POST',
  3787. headers: {
  3788. origin: 'https://vk.com',
  3789. referer: `https://vk.com/${name}`,
  3790. 'content-type': 'application/x-www-form-urlencoded'
  3791. },
  3792. data: $.param({
  3793. act: 'publish_box',
  3794. al: 1,
  3795. object: name
  3796. })
  3797. });
  3798. if (result === 'Success') {
  3799. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3800. var _data$responseText$ma2;
  3801. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3802. if (hash) {
  3803. const {
  3804. result: resultR,
  3805. statusText: statusTextR,
  3806. status: statusR,
  3807. data: dataR
  3808. } = await tools_httpRequest({
  3809. url: 'https://vk.com/like.php',
  3810. method: 'POST',
  3811. headers: {
  3812. origin: 'https://vk.com',
  3813. referer: `https://vk.com/${name}`,
  3814. 'content-type': 'application/x-www-form-urlencoded'
  3815. },
  3816. data: $.param({
  3817. Message: '',
  3818. act: 'a_do_publish',
  3819. al: 1,
  3820. close_comments: 0,
  3821. friends_only: 0,
  3822. from: 'box',
  3823. hash: hash,
  3824. list: '',
  3825. mark_as_ads: 0,
  3826. mute_notifications: 0,
  3827. object: name,
  3828. ret_data: 1,
  3829. to: 0
  3830. })
  3831. });
  3832. if (resultR === 'Success') {
  3833. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3834. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3835. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3836. 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) {
  3837. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3838. logStatus.success();
  3839. 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);
  3840. 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);
  3841. if (postId && ownerId) {
  3842. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3843. }
  3844. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3845. return true;
  3846. }
  3847. }
  3848. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3849. return false;
  3850. }
  3851. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3852. return false;
  3853. }
  3854. logStatus.error('Error: Get "hash" failed');
  3855. return false;
  3856. }
  3857. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3858. return false;
  3859. }
  3860. logStatus.error(`${result}:${statusText}(${status})`);
  3861. return false;
  3862. } catch (error) {
  3863. throwError(error, 'Vk.sendWall');
  3864. return false;
  3865. }
  3866. }
  3867. async function _deleteWall2(name, dataParams) {
  3868. try {
  3869. const logStatus = scripts_echoLog({
  3870. type: 'deletingVkWall',
  3871. text: name
  3872. });
  3873. const {
  3874. result,
  3875. statusText,
  3876. status,
  3877. data
  3878. } = await tools_httpRequest({
  3879. url: 'https://vk.com/al_wall.php?act=delete',
  3880. method: 'POST',
  3881. headers: {
  3882. origin: 'https://vk.com',
  3883. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3884. 'content-type': 'application/x-www-form-urlencoded'
  3885. },
  3886. data: $.param({
  3887. act: 'delete',
  3888. al: 1,
  3889. confirm: 0,
  3890. from: 'wkview',
  3891. hash: dataParams.wallHash,
  3892. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3893. })
  3894. });
  3895. if (result === 'Success') {
  3896. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3897. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3898. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3899. 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]) {
  3900. logStatus.success();
  3901. return true;
  3902. }
  3903. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3904. return false;
  3905. }
  3906. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3907. return false;
  3908. }
  3909. logStatus.error(`${result}:${statusText}(${status})`);
  3910. return false;
  3911. } catch (error) {
  3912. throwError(error, 'Vk.deleteWall');
  3913. return false;
  3914. }
  3915. }
  3916. async function _getId2(name, doTask) {
  3917. try {
  3918. let url = `https://vk.com/${name}`;
  3919. if (/^wall-/.test(name)) {
  3920. if (doTask) {
  3921. return {
  3922. type: 'sendWall'
  3923. };
  3924. }
  3925. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3926. return {
  3927. type: 'unSupport'
  3928. };
  3929. }
  3930. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3931. }
  3932. const logStatus = scripts_echoLog({
  3933. type: 'gettingVkId',
  3934. text: name
  3935. });
  3936. const {
  3937. result,
  3938. statusText,
  3939. status,
  3940. data
  3941. } = await tools_httpRequest({
  3942. url: url,
  3943. method: 'GET'
  3944. });
  3945. if (result === 'Success') {
  3946. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3947. var _data$responseText$ma3, _data$responseText$ma4;
  3948. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3949. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3950. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3951. const publicJoined = !data.responseText.includes('Public.subscribe');
  3952. if (groupAct && groupId && groupHash) {
  3953. logStatus.success();
  3954. return {
  3955. groupAct: groupAct,
  3956. groupId: groupId,
  3957. groupHash: groupHash,
  3958. type: 'group'
  3959. };
  3960. } else if (publicHash && publicPid) {
  3961. logStatus.success();
  3962. return {
  3963. publicHash: publicHash,
  3964. publicPid: publicPid,
  3965. publicJoined: publicJoined,
  3966. type: 'public'
  3967. };
  3968. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3969. var _data$responseText$ma5;
  3970. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3971. if (wallHash) {
  3972. logStatus.success();
  3973. return {
  3974. type: 'deleteWall',
  3975. wallHash: wallHash
  3976. };
  3977. }
  3978. } else if (name.includes('wall') && doTask) {
  3979. logStatus.success();
  3980. return {
  3981. type: 'sendWall'
  3982. };
  3983. }
  3984. logStatus.error('Error: Parameters not found!');
  3985. return false;
  3986. }
  3987. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3988. return false;
  3989. }
  3990. logStatus.error(`${result}:${statusText}(${status})`);
  3991. return false;
  3992. } catch (error) {
  3993. throwError(error, 'Vk.getId');
  3994. return false;
  3995. }
  3996. }
  3997. async function _toggleVk2(_ref2) {
  3998. let {
  3999. name,
  4000. doTask = true
  4001. } = _ref2;
  4002. try {
  4003. if (!doTask && this.whiteList.names.includes(name)) {
  4004. scripts_echoLog({
  4005. type: 'whiteList',
  4006. text: 'Vk.undoTask',
  4007. id: name
  4008. });
  4009. return true;
  4010. }
  4011. const formatName = name.replace(/\/$/, '');
  4012. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4013. if (!data) {
  4014. return false;
  4015. }
  4016. switch (data.type) {
  4017. case 'group':
  4018. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4019.  
  4020. case 'public':
  4021. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4022.  
  4023. case 'sendWall':
  4024. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4025.  
  4026. case 'deleteWall':
  4027. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4028.  
  4029. default:
  4030. return false;
  4031. }
  4032. } catch (error) {
  4033. throwError(error, 'Vk.toggleVk');
  4034. return false;
  4035. }
  4036. }
  4037. function Vk_setCache2(name, postId) {
  4038. try {
  4039. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4040. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4041. } catch (error) {
  4042. throwError(error, 'Vk.setCache');
  4043. }
  4044. }
  4045. const social_Vk = Vk;
  4046. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4047. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4048. privateSet.add(obj);
  4049. }
  4050. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4051. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4052. privateMap.set(obj, value);
  4053. }
  4054. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4055. if (privateCollection.has(obj)) {
  4056. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4057. }
  4058. }
  4059. function Youtube_defineProperty(obj, key, value) {
  4060. if (key in obj) {
  4061. Object.defineProperty(obj, key, {
  4062. value: value,
  4063. enumerable: true,
  4064. configurable: true,
  4065. writable: true
  4066. });
  4067. } else {
  4068. obj[key] = value;
  4069. }
  4070. return obj;
  4071. }
  4072. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4073. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4074. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4075. return value;
  4076. }
  4077. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4078. if (descriptor.set) {
  4079. descriptor.set.call(receiver, value);
  4080. } else {
  4081. if (!descriptor.writable) {
  4082. throw new TypeError('attempted to set read only private field');
  4083. }
  4084. descriptor.value = value;
  4085. }
  4086. }
  4087. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4088. if (!privateSet.has(receiver)) {
  4089. throw new TypeError('attempted to get private field on non-instance');
  4090. }
  4091. return fn;
  4092. }
  4093. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4094. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4095. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4096. }
  4097. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4098. if (!privateMap.has(receiver)) {
  4099. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4100. }
  4101. return privateMap.get(receiver);
  4102. }
  4103. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4104. if (descriptor.get) {
  4105. return descriptor.get.call(receiver);
  4106. }
  4107. return descriptor.value;
  4108. }
  4109. const Youtube_defaultTasks = {
  4110. channels: [],
  4111. likes: []
  4112. };
  4113. const getInfo = async function(link, type) {
  4114. try {
  4115. const logStatus = scripts_echoLog({
  4116. text: i18n('gettingYtbToken')
  4117. });
  4118. const {
  4119. result,
  4120. statusText,
  4121. status,
  4122. data
  4123. } = await tools_httpRequest({
  4124. url: link,
  4125. method: 'GET'
  4126. });
  4127. if (result === 'Success') {
  4128. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4129. var _data$responseText$ma, _ref;
  4130. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4131. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4132. return {
  4133. needLogin: true
  4134. };
  4135. }
  4136. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4137. 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]) || '{}';
  4138. const {
  4139. client,
  4140. request
  4141. } = JSON.parse(context);
  4142. if (apiKey && client && request) {
  4143. client.hl = 'en';
  4144. if (type === 'channel') {
  4145. var _data$responseText$ma2;
  4146. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4147. if (channelId) {
  4148. logStatus.success();
  4149. return {
  4150. params: {
  4151. apiKey: apiKey,
  4152. client: client,
  4153. request: request,
  4154. channelId: channelId
  4155. }
  4156. };
  4157. }
  4158. logStatus.error('Error: Get "channelId" failed!');
  4159. return {};
  4160. } else if (type === 'likeVideo') {
  4161. var _data$responseText$ma3, _data$responseText$ma4;
  4162. 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];
  4163. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4164. if (videoId) {
  4165. logStatus.success();
  4166. return {
  4167. params: {
  4168. apiKey: apiKey,
  4169. client: client,
  4170. request: request,
  4171. videoId: videoId,
  4172. likeParams: likeParams
  4173. }
  4174. };
  4175. }
  4176. logStatus.error('Error: Get "videoId" failed!');
  4177. return {};
  4178. }
  4179. logStatus.error('Error: Unknown type');
  4180. return {};
  4181. }
  4182. logStatus.error('Error: Parameter "apiKey" not found!');
  4183. return {};
  4184. }
  4185. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4186. return {};
  4187. }
  4188. logStatus.error(`${result}:${statusText}(${status})`);
  4189. return {};
  4190. } catch (error) {
  4191. throwError(error, 'Youtube.getInfo');
  4192. return {};
  4193. }
  4194. };
  4195. var Youtube_auth = new WeakMap();
  4196. var Youtube_initialized = new WeakMap();
  4197. var _verifyChannel = new WeakMap();
  4198. var Youtube_verifyAuth = new WeakSet();
  4199. var Youtube_updateAuth = new WeakSet();
  4200. var _getInfo = new WeakSet();
  4201. var Youtube_toggleChannel = new WeakSet();
  4202. var _toggleLikeVideo = new WeakSet();
  4203. class Youtube extends social_Social {
  4204. constructor() {
  4205. var _GM_getValue;
  4206. super(...arguments);
  4207. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4208. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4209. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4210. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4211. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4212. Youtube_defineProperty(this, 'tasks', {
  4213. ...Youtube_defaultTasks
  4214. });
  4215. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || {
  4216. ...Youtube_defaultTasks
  4217. });
  4218. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4219. writable: true,
  4220. value: GM_getValue('youtubeAuth') || {}
  4221. });
  4222. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4223. writable: true,
  4224. value: false
  4225. });
  4226. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4227. writable: true,
  4228. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4229. });
  4230. }
  4231. async init() {
  4232. try {
  4233. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4234. return true;
  4235. }
  4236. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4237. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4238. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4239. return true;
  4240. }
  4241. return false;
  4242. }
  4243. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4244. if (isVerified) {
  4245. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4246. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4247. return true;
  4248. }
  4249. GM_setValue('youtubeAuth', null);
  4250. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4251. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4252. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4253. return true;
  4254. }
  4255. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4256. return false;
  4257. } catch (error) {
  4258. throwError(error, 'Youtube.init');
  4259. return false;
  4260. }
  4261. }
  4262. async toggle(_ref2) {
  4263. let {
  4264. doTask = true,
  4265. channelLinks = [],
  4266. videoLinks = []
  4267. } = _ref2;
  4268. try {
  4269. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4270. scripts_echoLog({
  4271. text: i18n('needInit')
  4272. });
  4273. return false;
  4274. }
  4275. const prom = [];
  4276. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4277. scripts_echoLog({
  4278. type: 'globalOptionsSkip',
  4279. text: 'youtube.channels'
  4280. });
  4281. } else {
  4282. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4283. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4284. var _link$match;
  4285. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4286. }
  4287. return link;
  4288. });
  4289. if (realChannels.length > 0) {
  4290. for (const channel of realChannels) {
  4291. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4292. link: channel,
  4293. doTask: doTask
  4294. }));
  4295. await delay(1e3);
  4296. }
  4297. }
  4298. }
  4299. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4300. scripts_echoLog({
  4301. type: 'globalOptionsSkip',
  4302. text: 'youtube.likes'
  4303. });
  4304. } else {
  4305. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4306. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4307. var _link$match2;
  4308. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4309. }
  4310. return link;
  4311. });
  4312. if (realLikes.length > 0) {
  4313. for (const video of realLikes) {
  4314. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4315. link: video,
  4316. doTask: doTask
  4317. }));
  4318. await delay(1e3);
  4319. }
  4320. }
  4321. }
  4322. return Promise.all(prom).then(() => true);
  4323. } catch (error) {
  4324. throwError(error, 'Youtube.toggle');
  4325. return false;
  4326. }
  4327. }
  4328. }
  4329. async function Youtube_verifyAuth2() {
  4330. try {
  4331. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4332. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4333. doTask: true,
  4334. verify: true
  4335. });
  4336. } catch (error) {
  4337. throwError(error, 'Youtube.verifyAuth');
  4338. return false;
  4339. }
  4340. }
  4341. async function Youtube_updateAuth2() {
  4342. try {
  4343. const logStatus = scripts_echoLog({
  4344. text: i18n('updatingAuth', 'Youtube')
  4345. });
  4346. return await new Promise(resolve => {
  4347. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4348. active: true,
  4349. insert: true,
  4350. setParent: true
  4351. });
  4352. newTab.onclose = async () => {
  4353. const auth = GM_getValue('youtubeAuth');
  4354. if (auth) {
  4355. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4356. logStatus.success();
  4357. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4358. resolve(result);
  4359. });
  4360. } else {
  4361. logStatus.error('Error: Update youtube auth failed!');
  4362. resolve(false);
  4363. }
  4364. };
  4365. });
  4366. } catch (error) {
  4367. throwError(error, 'Discord.updateAuth');
  4368. return false;
  4369. }
  4370. }
  4371. function _getInfo2(link, type) {
  4372. return getInfo(link, type);
  4373. }
  4374. async function Youtube_toggleChannel2(_ref3) {
  4375. let {
  4376. link,
  4377. doTask = true,
  4378. verify = false
  4379. } = _ref3;
  4380. try {
  4381. const {
  4382. params,
  4383. needLogin
  4384. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4385. const {
  4386. apiKey,
  4387. client,
  4388. request,
  4389. channelId
  4390. } = params || {};
  4391. if (needLogin) {
  4392. scripts_echoLog({
  4393. html: i18n('loginYtb')
  4394. });
  4395. return false;
  4396. }
  4397. if (!(apiKey && client && request && channelId)) {
  4398. scripts_echoLog({
  4399. text: '"getYtbToken" failed'
  4400. });
  4401. return false;
  4402. }
  4403. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4404. scripts_echoLog({
  4405. type: 'whiteList',
  4406. text: 'Youtube.unfollowChannel',
  4407. id: channelId
  4408. });
  4409. return true;
  4410. }
  4411. const logStatus = verify ? scripts_echoLog({
  4412. text: i18n('verifyingAuth', 'Youtube')
  4413. }) : scripts_echoLog({
  4414. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4415. text: channelId
  4416. });
  4417. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4418. const {
  4419. result,
  4420. statusText,
  4421. status,
  4422. data
  4423. } = await tools_httpRequest({
  4424. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4425. method: 'POST',
  4426. headers: {
  4427. origin: 'https://www.youtube.com',
  4428. referer: `https://www.youtube.com/channel/${channelId}`,
  4429. 'content-type': 'application/json',
  4430. 'x-goog-authuser': '0',
  4431. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4432. 'x-origin': 'https://www.youtube.com',
  4433. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4434. },
  4435. data: JSON.stringify({
  4436. context: {
  4437. client: client,
  4438. request: {
  4439. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4440. internalExperimentFlags: [],
  4441. consistencyTokenJars: []
  4442. },
  4443. user: {}
  4444. },
  4445. channelIds: [ channelId ],
  4446. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4447. })
  4448. });
  4449. if (result === 'Success') {
  4450. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4451. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4452. logStatus.success();
  4453. if (doTask && !verify) {
  4454. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4455. }
  4456. return true;
  4457. }
  4458. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4459. return false;
  4460. }
  4461. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4462. return false;
  4463. }
  4464. logStatus.error(`${result}:${statusText}(${status})`);
  4465. return false;
  4466. } catch (error) {
  4467. throwError(error, 'Youtube.toggleChannel');
  4468. return false;
  4469. }
  4470. }
  4471. async function _toggleLikeVideo2(_ref4) {
  4472. let {
  4473. link,
  4474. doTask = true
  4475. } = _ref4;
  4476. try {
  4477. const {
  4478. params,
  4479. needLogin
  4480. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4481. const {
  4482. apiKey,
  4483. client,
  4484. request,
  4485. videoId,
  4486. likeParams
  4487. } = params || {};
  4488. if (needLogin) {
  4489. scripts_echoLog({
  4490. html: `${i18n('loginYtb')}`
  4491. });
  4492. return false;
  4493. }
  4494. if (!(apiKey && client && request && videoId && likeParams)) {
  4495. scripts_echoLog({
  4496. text: '"getYtbToken" failed'
  4497. });
  4498. return false;
  4499. }
  4500. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4501. scripts_echoLog({
  4502. type: 'whiteList',
  4503. text: 'Youtube.unlikeVideo',
  4504. id: videoId
  4505. });
  4506. return true;
  4507. }
  4508. const logStatus = scripts_echoLog({
  4509. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4510. text: videoId
  4511. });
  4512. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4513. const likeVideoData = {
  4514. context: {
  4515. client: client,
  4516. request: {
  4517. sessionId: request.sessionId,
  4518. internalExperimentFlags: [],
  4519. consistencyTokenJars: []
  4520. },
  4521. user: {}
  4522. },
  4523. target: {
  4524. videoId: videoId
  4525. }
  4526. };
  4527. if (doTask) {
  4528. if (likeParams) {
  4529. likeVideoData.params = likeParams;
  4530. } else {
  4531. logStatus.error('Empty likeParams');
  4532. return false;
  4533. }
  4534. }
  4535. const {
  4536. result,
  4537. statusText,
  4538. status,
  4539. data
  4540. } = await tools_httpRequest({
  4541. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4542. method: 'POST',
  4543. headers: {
  4544. origin: 'https://www.youtube.com',
  4545. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4546. 'content-type': 'application/json',
  4547. 'x-goog-authuser': '0',
  4548. 'x-goog-visitor-id': client.visitorData,
  4549. 'x-origin': 'https://www.youtube.com',
  4550. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4551. },
  4552. data: JSON.stringify(likeVideoData)
  4553. });
  4554. if (result === 'Success') {
  4555. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4556. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4557. logStatus.success();
  4558. if (doTask) {
  4559. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4560. }
  4561. return true;
  4562. }
  4563. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4564. return false;
  4565. }
  4566. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4567. return false;
  4568. }
  4569. logStatus.error(`${result}:${statusText}(${status})`);
  4570. return false;
  4571. } catch (error) {
  4572. throwError(error, 'Youtube.toggleLikeVideo');
  4573. return false;
  4574. }
  4575. }
  4576. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4577. Steam_checkPrivateRedeclaration(obj, privateSet);
  4578. privateSet.add(obj);
  4579. }
  4580. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4581. Steam_checkPrivateRedeclaration(obj, privateMap);
  4582. privateMap.set(obj, value);
  4583. }
  4584. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4585. if (privateCollection.has(obj)) {
  4586. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4587. }
  4588. }
  4589. function Steam_defineProperty(obj, key, value) {
  4590. if (key in obj) {
  4591. Object.defineProperty(obj, key, {
  4592. value: value,
  4593. enumerable: true,
  4594. configurable: true,
  4595. writable: true
  4596. });
  4597. } else {
  4598. obj[key] = value;
  4599. }
  4600. return obj;
  4601. }
  4602. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4603. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4604. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4605. return value;
  4606. }
  4607. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4608. if (descriptor.set) {
  4609. descriptor.set.call(receiver, value);
  4610. } else {
  4611. if (!descriptor.writable) {
  4612. throw new TypeError('attempted to set read only private field');
  4613. }
  4614. descriptor.value = value;
  4615. }
  4616. }
  4617. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4618. if (!privateSet.has(receiver)) {
  4619. throw new TypeError('attempted to get private field on non-instance');
  4620. }
  4621. return fn;
  4622. }
  4623. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4624. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4625. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4626. }
  4627. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4628. if (!privateMap.has(receiver)) {
  4629. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4630. }
  4631. return privateMap.get(receiver);
  4632. }
  4633. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4634. if (descriptor.get) {
  4635. return descriptor.get.call(receiver);
  4636. }
  4637. return descriptor.value;
  4638. }
  4639. const Steam_defaultTasks = {
  4640. groups: [],
  4641. wishlists: [],
  4642. follows: [],
  4643. forums: [],
  4644. workshops: [],
  4645. workshopVotes: [],
  4646. curators: [],
  4647. curatorLikes: [],
  4648. announcements: []
  4649. };
  4650. var Steam_cache = new WeakMap();
  4651. var Steam_auth = new WeakMap();
  4652. var Steam_initialized = new WeakMap();
  4653. var _area = new WeakMap();
  4654. var _updateStoreAuth = new WeakSet();
  4655. var _updateCommunityAuth = new WeakSet();
  4656. var _getAreaInfo = new WeakSet();
  4657. var _changeArea = new WeakSet();
  4658. var _joinGroup = new WeakSet();
  4659. var _leaveGroup = new WeakSet();
  4660. var _getGroupId = new WeakSet();
  4661. var _addToWishlist = new WeakSet();
  4662. var _removeFromWishlist = new WeakSet();
  4663. var _toggleFollowGame = new WeakSet();
  4664. var _isFollowedGame = new WeakSet();
  4665. var _toggleForum = new WeakSet();
  4666. var _getForumId = new WeakSet();
  4667. var _toggleFavoriteWorkshop = new WeakSet();
  4668. var _getWorkshopAppId = new WeakSet();
  4669. var _voteUpWorkshop = new WeakSet();
  4670. var _toggleCurator = new WeakSet();
  4671. var _toggleCuratorLike = new WeakSet();
  4672. var _getAnnouncementParams = new WeakSet();
  4673. var _likeAnnouncement = new WeakSet();
  4674. var Steam_setCache = new WeakSet();
  4675. class Steam extends social_Social {
  4676. constructor() {
  4677. var _GM_getValue;
  4678. super(...arguments);
  4679. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4680. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4681. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4682. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4683. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4684. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4685. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4686. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4687. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4688. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4689. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4690. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4691. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4692. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4693. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4694. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4695. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4696. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4697. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4698. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4699. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4700. Steam_defineProperty(this, 'tasks', {
  4701. ...Steam_defaultTasks
  4702. });
  4703. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || {
  4704. ...Steam_defaultTasks
  4705. });
  4706. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4707. writable: true,
  4708. value: GM_getValue('steamCache') || {
  4709. group: {},
  4710. forum: {},
  4711. workshop: {},
  4712. curator: {}
  4713. }
  4714. });
  4715. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4716. writable: true,
  4717. value: {}
  4718. });
  4719. Steam_classPrivateFieldInitSpec(this, Steam_initialized, {
  4720. writable: true,
  4721. value: false
  4722. });
  4723. Steam_classPrivateFieldInitSpec(this, _area, {
  4724. writable: true,
  4725. value: 'CN'
  4726. });
  4727. }
  4728. async init() {
  4729. try {
  4730. if (Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4731. return true;
  4732. }
  4733. const isVerified = await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this) && await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this);
  4734. if (isVerified) {
  4735. Steam_classPrivateFieldSet(this, Steam_initialized, true);
  4736. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4737. return true;
  4738. }
  4739. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4740. return false;
  4741. } catch (error) {
  4742. throwError(error, 'Steam.init');
  4743. return false;
  4744. }
  4745. }
  4746. async getCuratorId(path, name) {
  4747. try {
  4748. const logStatus = scripts_echoLog({
  4749. type: 'gettingCuratorId',
  4750. text: `${path}/${name}`
  4751. });
  4752. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4753. if (curatorId) {
  4754. logStatus.success();
  4755. return curatorId;
  4756. }
  4757. const {
  4758. result,
  4759. statusText,
  4760. status,
  4761. data
  4762. } = await tools_httpRequest({
  4763. url: `https://store.steampowered.com/${path}/${name}`,
  4764. method: 'GET',
  4765. headers: {
  4766. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4767. }
  4768. });
  4769. if (result === 'Success') {
  4770. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4771. var _data$responseText$ma;
  4772. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4773. if (curatorId) {
  4774. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4775. logStatus.success();
  4776. return curatorId;
  4777. }
  4778. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4779. return false;
  4780. }
  4781. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4782. return false;
  4783. }
  4784. logStatus.error(`${result}:${statusText}(${status})`);
  4785. return false;
  4786. } catch (error) {
  4787. throwError(error, 'Steam.getCuratorID');
  4788. return false;
  4789. }
  4790. }
  4791. async toggle(_ref) {
  4792. let {
  4793. doTask = true,
  4794. groupLinks = [],
  4795. wishlistLinks = [],
  4796. followLinks = [],
  4797. forumLinks = [],
  4798. workshopLinks = [],
  4799. workshopVoteLinks = [],
  4800. curatorLinks = [],
  4801. curatorLikeLinks = [],
  4802. announcementLinks = []
  4803. } = _ref;
  4804. try {
  4805. if (!Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4806. scripts_echoLog({
  4807. text: i18n('needInit')
  4808. });
  4809. return false;
  4810. }
  4811. const prom = [];
  4812. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4813. scripts_echoLog({
  4814. type: 'globalOptionsSkip',
  4815. text: 'steam.groups'
  4816. });
  4817. } else {
  4818. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4819. var _link$match;
  4820. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4821. });
  4822. if (realGroups.length > 0) {
  4823. for (const group of realGroups) {
  4824. if (doTask) {
  4825. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4826. } else {
  4827. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4828. }
  4829. await delay(1e3);
  4830. }
  4831. }
  4832. }
  4833. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4834. scripts_echoLog({
  4835. type: 'globalOptionsSkip',
  4836. text: 'steam.wishlists'
  4837. });
  4838. } else {
  4839. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4840. var _link$match2;
  4841. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4842. });
  4843. if (realWishlists.length > 0) {
  4844. for (const game of realWishlists) {
  4845. if (doTask) {
  4846. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4847. } else {
  4848. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4849. }
  4850. await delay(1e3);
  4851. }
  4852. }
  4853. }
  4854. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4855. scripts_echoLog({
  4856. type: 'globalOptionsSkip',
  4857. text: 'steam.follows'
  4858. });
  4859. } else {
  4860. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4861. var _link$match3;
  4862. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4863. });
  4864. if (realFollows.length > 0) {
  4865. for (const game of realFollows) {
  4866. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4867. await delay(1e3);
  4868. }
  4869. }
  4870. }
  4871. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4872. scripts_echoLog({
  4873. type: 'globalOptionsSkip',
  4874. text: 'steam.forums'
  4875. });
  4876. } else {
  4877. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4878. var _link$match4;
  4879. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4880. });
  4881. if (realForums.length > 0) {
  4882. for (const forum of realForums) {
  4883. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4884. await delay(1e3);
  4885. }
  4886. }
  4887. }
  4888. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4889. scripts_echoLog({
  4890. type: 'globalOptionsSkip',
  4891. text: 'steam.workshops'
  4892. });
  4893. } else {
  4894. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4895. var _link$match5;
  4896. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4897. });
  4898. if (realWorkshops.length > 0) {
  4899. for (const workshop of realWorkshops) {
  4900. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4901. await delay(1e3);
  4902. }
  4903. }
  4904. }
  4905. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4906. scripts_echoLog({
  4907. type: 'globalOptionsSkip',
  4908. text: 'steam.workshopVotes'
  4909. });
  4910. } else {
  4911. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4912. var _link$match6;
  4913. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4914. });
  4915. if (doTask && realworkshopVotes.length > 0) {
  4916. for (const workshop of realworkshopVotes) {
  4917. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4918. await delay(1e3);
  4919. }
  4920. }
  4921. }
  4922. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4923. scripts_echoLog({
  4924. type: 'globalOptionsSkip',
  4925. text: 'steam.curators'
  4926. });
  4927. } else {
  4928. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4929. var _link$match7;
  4930. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4931. });
  4932. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4933. var _link$match8;
  4934. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4935. });
  4936. if (realCurators.length > 0) {
  4937. for (const curator of realCurators) {
  4938. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4939. await delay(1e3);
  4940. }
  4941. }
  4942. if (realCuratorLikes.length > 0) {
  4943. for (const curatorLike of realCuratorLikes) {
  4944. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4945. await delay(1e3);
  4946. }
  4947. }
  4948. }
  4949. if (doTask && !globalOptions.doTask.steam.announcements) {
  4950. scripts_echoLog({
  4951. type: 'globalOptionsSkip',
  4952. text: 'steam.announcements'
  4953. });
  4954. } else {
  4955. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  4956. var _link$match10;
  4957. if (link.includes('store.steampowered.com')) {
  4958. var _link$match9;
  4959. 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('/');
  4960. }
  4961. 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('/');
  4962. });
  4963. if (doTask && realAnnouncements.length > 0) {
  4964. for (const id of realAnnouncements) {
  4965. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  4966. await delay(1e3);
  4967. }
  4968. }
  4969. }
  4970. return Promise.all(prom).then(async () => {
  4971. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  4972. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  4973. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  4974. }
  4975. return true;
  4976. });
  4977. } catch (error) {
  4978. throwError(error, 'Steam.toggle');
  4979. return false;
  4980. }
  4981. }
  4982. }
  4983. async function _updateStoreAuth2() {
  4984. try {
  4985. const logStatus = scripts_echoLog({
  4986. text: i18n('updatingAuth', i18n('steamStore'))
  4987. });
  4988. const {
  4989. result,
  4990. statusText,
  4991. status,
  4992. data
  4993. } = await tools_httpRequest({
  4994. url: 'https://store.steampowered.com/stats/',
  4995. method: 'GET'
  4996. });
  4997. if (result === 'Success') {
  4998. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4999. var _data$responseText$ma2;
  5000. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5001. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5002. return false;
  5003. }
  5004. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5005. if (storeSessionID) {
  5006. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5007. logStatus.success();
  5008. return true;
  5009. }
  5010. logStatus.error('Error: Get "sessionID" failed');
  5011. return false;
  5012. }
  5013. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5014. return false;
  5015. }
  5016. logStatus.error(`${result}:${statusText}(${status})`);
  5017. return false;
  5018. } catch (error) {
  5019. throwError(error, 'Steam.updateStoreAuth');
  5020. return false;
  5021. }
  5022. }
  5023. async function _updateCommunityAuth2() {
  5024. try {
  5025. const logStatus = scripts_echoLog({
  5026. text: i18n('updatingAuth', i18n('steamCommunity'))
  5027. });
  5028. const {
  5029. result,
  5030. statusText,
  5031. status,
  5032. data
  5033. } = await tools_httpRequest({
  5034. url: 'https://steamcommunity.com/my',
  5035. method: 'GET'
  5036. });
  5037. if (result === 'Success') {
  5038. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5039. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5040. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5041. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5042. return false;
  5043. }
  5044. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5045. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5046. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5047. if (steam64Id) {
  5048. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5049. }
  5050. if (userName) {
  5051. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5052. }
  5053. if (communitySessionID) {
  5054. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5055. logStatus.success();
  5056. return true;
  5057. }
  5058. logStatus.error('Error: Get "sessionID" failed');
  5059. return false;
  5060. }
  5061. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5062. return false;
  5063. }
  5064. logStatus.error(`${result}:${statusText}(${status})`);
  5065. return false;
  5066. } catch (error) {
  5067. throwError(error, 'Steam.updateCommunityAuth');
  5068. return false;
  5069. }
  5070. }
  5071. async function _getAreaInfo2() {
  5072. try {
  5073. const logStatus = scripts_echoLog({
  5074. text: i18n('gettingAreaInfo')
  5075. });
  5076. const {
  5077. result,
  5078. statusText,
  5079. status,
  5080. data
  5081. } = await tools_httpRequest({
  5082. url: 'https://store.steampowered.com/cart/',
  5083. method: 'GET'
  5084. });
  5085. if (result === 'Success') {
  5086. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5087. var _data$responseText$ma6;
  5088. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5089. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5090. if (currentArea && areas.length > 0) {
  5091. Steam_classPrivateFieldSet(this, _area, currentArea);
  5092. logStatus.success();
  5093. return {
  5094. currentArea: currentArea,
  5095. areas: areas
  5096. };
  5097. }
  5098. logStatus.error('Error: get country info filed');
  5099. return {};
  5100. }
  5101. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5102. return {};
  5103. }
  5104. logStatus.error(`${result}:${statusText}(${status})`);
  5105. return {};
  5106. } catch (error) {
  5107. throwError(error, 'Steam.getAreaInfo');
  5108. return {};
  5109. }
  5110. }
  5111. async function _changeArea2(area) {
  5112. try {
  5113. let aimedArea = area;
  5114. if (!aimedArea) {
  5115. const {
  5116. currentArea,
  5117. areas
  5118. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5119. if (!currentArea || !areas) {
  5120. return false;
  5121. }
  5122. if (currentArea !== 'CN') {
  5123. scripts_echoLog({
  5124. text: 'notNeededChangeArea'
  5125. });
  5126. return 'skip';
  5127. }
  5128. const anotherArea = areas.filter(area => area && area !== 'CN');
  5129. if (!anotherArea || anotherArea.length === 0) {
  5130. scripts_echoLog({
  5131. text: 'noAnotherArea'
  5132. });
  5133. return false;
  5134. }
  5135. [ aimedArea ] = anotherArea;
  5136. }
  5137. const logStatus = scripts_echoLog({
  5138. text: i18n('changingArea', aimedArea)
  5139. });
  5140. const {
  5141. result,
  5142. statusText,
  5143. status,
  5144. data
  5145. } = await tools_httpRequest({
  5146. url: 'https://store.steampowered.com/account/setcountry',
  5147. method: 'POST',
  5148. headers: {
  5149. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5150. },
  5151. data: $.param({
  5152. cc: aimedArea,
  5153. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5154. })
  5155. });
  5156. if (result === 'Success') {
  5157. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5158. const {
  5159. currentArea
  5160. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5161. if (currentArea === aimedArea) {
  5162. logStatus.success();
  5163. return currentArea;
  5164. }
  5165. logStatus.error('Error: change country filed');
  5166. return 'CN';
  5167. }
  5168. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5169. return 'CN';
  5170. }
  5171. logStatus.error(`${result}:${statusText}(${status})`);
  5172. return 'CN';
  5173. } catch (error) {
  5174. throwError(error, 'Steam.changeArea');
  5175. return false;
  5176. }
  5177. }
  5178. async function _joinGroup2(groupName) {
  5179. try {
  5180. const logStatus = scripts_echoLog({
  5181. type: 'joiningSteamGroup',
  5182. text: groupName
  5183. });
  5184. const {
  5185. result,
  5186. statusText,
  5187. status,
  5188. data
  5189. } = await tools_httpRequest({
  5190. url: `https://steamcommunity.com/groups/${groupName}`,
  5191. method: 'POST',
  5192. headers: {
  5193. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5194. },
  5195. data: $.param({
  5196. action: 'join',
  5197. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5198. })
  5199. });
  5200. if (result === 'Success') {
  5201. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5202. logStatus.success();
  5203. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5204. return true;
  5205. }
  5206. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5207. return false;
  5208. }
  5209. logStatus.error(`${result}:${statusText}(${status})`);
  5210. return false;
  5211. } catch (error) {
  5212. throwError(error, 'Steam.joinGroup');
  5213. return false;
  5214. }
  5215. }
  5216. async function _leaveGroup2(groupName) {
  5217. try {
  5218. if (this.whiteList.groups.includes(groupName)) {
  5219. scripts_echoLog({
  5220. type: 'whiteList',
  5221. text: 'Steam.leaveGroup',
  5222. id: groupName
  5223. });
  5224. return true;
  5225. }
  5226. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5227. if (!groupId) {
  5228. return false;
  5229. }
  5230. const logStatus = scripts_echoLog({
  5231. type: 'leavingSteamGroup',
  5232. text: groupName
  5233. });
  5234. const {
  5235. result,
  5236. statusText,
  5237. status,
  5238. data
  5239. } = await tools_httpRequest({
  5240. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5241. method: 'POST',
  5242. headers: {
  5243. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5244. },
  5245. data: $.param({
  5246. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5247. action: 'leaveGroup',
  5248. groupId: groupId
  5249. })
  5250. });
  5251. if (result === 'Success') {
  5252. 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) {
  5253. logStatus.success();
  5254. return true;
  5255. }
  5256. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5257. return false;
  5258. }
  5259. logStatus.error(`${result}:${statusText}(${status})`);
  5260. return false;
  5261. } catch (error) {
  5262. throwError(error, 'Steam.leaveGroup');
  5263. return false;
  5264. }
  5265. }
  5266. async function _getGroupId2(groupName) {
  5267. try {
  5268. const logStatus = scripts_echoLog({
  5269. type: 'gettingSteamGroupId',
  5270. text: groupName
  5271. });
  5272. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5273. if (groupId) {
  5274. logStatus.success();
  5275. return groupId;
  5276. }
  5277. const {
  5278. result,
  5279. statusText,
  5280. status,
  5281. data
  5282. } = await tools_httpRequest({
  5283. url: `https://steamcommunity.com/groups/${groupName}`,
  5284. method: 'GET',
  5285. headers: {
  5286. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5287. }
  5288. });
  5289. if (result === 'Success') {
  5290. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5291. var _data$responseText$ma7;
  5292. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5293. if (groupId) {
  5294. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5295. logStatus.success();
  5296. return groupId;
  5297. }
  5298. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5299. return false;
  5300. }
  5301. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5302. return false;
  5303. }
  5304. logStatus.error(`${result}:${statusText}(${status})`);
  5305. return false;
  5306. } catch (error) {
  5307. throwError(error, 'Steam.getGroupID');
  5308. return false;
  5309. }
  5310. }
  5311. async function _addToWishlist2(gameId) {
  5312. try {
  5313. var _data$response;
  5314. const logStatus = scripts_echoLog({
  5315. type: 'addingToWishlist',
  5316. text: gameId
  5317. });
  5318. const {
  5319. result,
  5320. data
  5321. } = await tools_httpRequest({
  5322. url: 'https://store.steampowered.com/api/addtowishlist',
  5323. method: 'POST',
  5324. headers: {
  5325. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5326. },
  5327. data: $.param({
  5328. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5329. appid: gameId
  5330. }),
  5331. dataType: 'json'
  5332. });
  5333. 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) {
  5334. logStatus.success();
  5335. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5336. return true;
  5337. }
  5338. const {
  5339. result: resultR,
  5340. statusText: statusTextR,
  5341. status: statusR,
  5342. data: dataR
  5343. } = await tools_httpRequest({
  5344. url: `https://store.steampowered.com/app/${gameId}`,
  5345. method: 'GET'
  5346. });
  5347. if (resultR === 'Success') {
  5348. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5349. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5350. logStatus.warning(i18n('changeAreaNotice'));
  5351. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5352. return false;
  5353. }
  5354. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5355. }
  5356. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5357. logStatus.success();
  5358. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5359. return true;
  5360. } 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"')) {
  5361. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5362. return false;
  5363. }
  5364. logStatus.success();
  5365. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5366. return true;
  5367. }
  5368. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5369. return false;
  5370. }
  5371. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5372. return false;
  5373. } catch (error) {
  5374. throwError(error, 'Steam.addToWishlist');
  5375. return false;
  5376. }
  5377. }
  5378. async function _removeFromWishlist2(gameId) {
  5379. try {
  5380. var _data$response2;
  5381. if (this.whiteList.wishlists.includes(gameId)) {
  5382. scripts_echoLog({
  5383. type: 'whiteList',
  5384. text: 'Steam.removeFromWishlist',
  5385. id: gameId
  5386. });
  5387. return true;
  5388. }
  5389. const logStatus = scripts_echoLog({
  5390. type: 'removingFromWishlist',
  5391. text: gameId
  5392. });
  5393. const {
  5394. result,
  5395. data
  5396. } = await tools_httpRequest({
  5397. url: 'https://store.steampowered.com/api/removefromwishlist',
  5398. method: 'POST',
  5399. headers: {
  5400. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5401. },
  5402. data: $.param({
  5403. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5404. appid: gameId
  5405. }),
  5406. dataType: 'json'
  5407. });
  5408. 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) {
  5409. logStatus.success();
  5410. return true;
  5411. }
  5412. const {
  5413. result: resultR,
  5414. statusText: statusTextR,
  5415. status: statusR,
  5416. data: dataR
  5417. } = await tools_httpRequest({
  5418. url: `https://store.steampowered.com/app/${gameId}`,
  5419. method: 'GET'
  5420. });
  5421. if (resultR === 'Success') {
  5422. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5423. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5424. logStatus.warning(i18n('changeAreaNotice'));
  5425. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5426. if (!result || result === 'CN' || result === 'skip') {
  5427. return false;
  5428. }
  5429. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5430. }
  5431. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5432. logStatus.success();
  5433. return true;
  5434. }
  5435. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5436. return false;
  5437. }
  5438. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5439. return false;
  5440. }
  5441. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5442. return false;
  5443. } catch (error) {
  5444. throwError(error, 'Steam.removeFromWishlist');
  5445. return false;
  5446. }
  5447. }
  5448. async function _toggleFollowGame2(gameId, doTask) {
  5449. try {
  5450. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5451. scripts_echoLog({
  5452. type: 'whiteList',
  5453. text: 'Steam.unfollowGame',
  5454. id: gameId
  5455. });
  5456. return true;
  5457. }
  5458. const logStatus = scripts_echoLog({
  5459. type: `${doTask ? '' : 'un'}followingGame`,
  5460. text: gameId
  5461. });
  5462. const requestData = {
  5463. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5464. appid: gameId
  5465. };
  5466. if (!doTask) {
  5467. requestData.unfollow = '1';
  5468. }
  5469. const {
  5470. result,
  5471. data
  5472. } = await tools_httpRequest({
  5473. url: 'https://store.steampowered.com/explore/followgame/',
  5474. method: 'POST',
  5475. headers: {
  5476. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5477. },
  5478. data: $.param(requestData)
  5479. });
  5480. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5481. logStatus.success();
  5482. return true;
  5483. }
  5484. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5485. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5486. logStatus.warning(i18n('changeAreaNotice'));
  5487. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5488. return false;
  5489. }
  5490. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5491. }
  5492. if (doTask === followed) {
  5493. logStatus.success();
  5494. if (doTask) {
  5495. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5496. }
  5497. return true;
  5498. }
  5499. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5500. return false;
  5501. } catch (error) {
  5502. throwError(error, 'Steam.toggleFollowGame');
  5503. return false;
  5504. }
  5505. }
  5506. async function _isFollowedGame2(gameId) {
  5507. try {
  5508. const {
  5509. result,
  5510. data
  5511. } = await tools_httpRequest({
  5512. url: `https://store.steampowered.com/app/${gameId}`,
  5513. method: 'GET'
  5514. });
  5515. if (result === 'Success') {
  5516. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5517. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5518. return 'areaLocked';
  5519. }
  5520. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5521. return true;
  5522. }
  5523. return false;
  5524. }
  5525. return false;
  5526. }
  5527. return false;
  5528. } catch (error) {
  5529. throwError(error, 'Steam.isFollowedGame');
  5530. return false;
  5531. }
  5532. }
  5533. async function _toggleForum2(gameId) {
  5534. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5535. try {
  5536. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5537. scripts_echoLog({
  5538. type: 'whiteList',
  5539. text: 'Steam.unsubscribForum',
  5540. id: gameId
  5541. });
  5542. return true;
  5543. }
  5544. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5545. if (!forumId) {
  5546. return false;
  5547. }
  5548. const logStatus = scripts_echoLog({
  5549. type: `${doTask ? '' : 'un'}subscribingForum`,
  5550. text: gameId
  5551. });
  5552. const [ id, feature ] = forumId.split('_');
  5553. const {
  5554. result,
  5555. statusText,
  5556. status,
  5557. data
  5558. } = await tools_httpRequest({
  5559. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5560. method: 'POST',
  5561. responseType: 'json',
  5562. headers: {
  5563. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5564. },
  5565. data: $.param({
  5566. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5567. })
  5568. });
  5569. if (result === 'Success') {
  5570. var _data$response3, _data$response4;
  5571. 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)) {
  5572. if (doTask) {
  5573. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5574. }
  5575. logStatus.success();
  5576. return true;
  5577. }
  5578. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5579. return true;
  5580. }
  5581. logStatus.error(`${result}:${statusText}(${status})`);
  5582. return true;
  5583. } catch (error) {
  5584. throwError(error, 'Steam.toggleForum');
  5585. return true;
  5586. }
  5587. }
  5588. async function _getForumId2(gameId) {
  5589. try {
  5590. const logStatus = scripts_echoLog({
  5591. type: 'gettingForumId',
  5592. text: gameId
  5593. });
  5594. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5595. if (forumId) {
  5596. logStatus.success();
  5597. return forumId;
  5598. }
  5599. const {
  5600. result,
  5601. statusText,
  5602. status,
  5603. data
  5604. } = await tools_httpRequest({
  5605. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5606. method: 'GET'
  5607. });
  5608. if (result === 'Success') {
  5609. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5610. var _data$responseText, _data$responseText$ma8;
  5611. 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];
  5612. if (forumId) {
  5613. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5614. logStatus.success();
  5615. return forumId;
  5616. }
  5617. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5618. return false;
  5619. }
  5620. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5621. return false;
  5622. }
  5623. logStatus.error(`${result}:${statusText}(${status})`);
  5624. return false;
  5625. } catch (error) {
  5626. throwError(error, 'Steam.getForumId');
  5627. return false;
  5628. }
  5629. }
  5630. async function _toggleFavoriteWorkshop2(id) {
  5631. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5632. try {
  5633. if (!doTask && this.whiteList.workshops.includes(id)) {
  5634. scripts_echoLog({
  5635. type: 'whiteList',
  5636. text: 'Steam.unfavoriteWorkshop',
  5637. id: id
  5638. });
  5639. return true;
  5640. }
  5641. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5642. if (!appid) {
  5643. return false;
  5644. }
  5645. const logStatus = scripts_echoLog({
  5646. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5647. text: id
  5648. });
  5649. const {
  5650. result,
  5651. statusText,
  5652. status,
  5653. data
  5654. } = await tools_httpRequest({
  5655. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5656. method: 'POST',
  5657. headers: {
  5658. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5659. },
  5660. data: $.param({
  5661. id: id,
  5662. appid: appid,
  5663. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5664. })
  5665. });
  5666. if (result === 'Success') {
  5667. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5668. if (doTask) {
  5669. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5670. }
  5671. logStatus.success();
  5672. return true;
  5673. }
  5674. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5675. return false;
  5676. }
  5677. logStatus.error(`${result}:${statusText}(${status})`);
  5678. return false;
  5679. } catch (error) {
  5680. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5681. return false;
  5682. }
  5683. }
  5684. async function _getWorkshopAppId2(id) {
  5685. try {
  5686. const logStatus = scripts_echoLog({
  5687. type: 'gettingWorkshopAppId',
  5688. text: id
  5689. });
  5690. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5691. if (appId) {
  5692. logStatus.success();
  5693. return appId;
  5694. }
  5695. const {
  5696. result,
  5697. statusText,
  5698. status,
  5699. data
  5700. } = await tools_httpRequest({
  5701. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5702. method: 'GET'
  5703. });
  5704. if (result === 'Success') {
  5705. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5706. var _data$responseText$ma9;
  5707. 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];
  5708. if (appId) {
  5709. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5710. logStatus.success();
  5711. return appId;
  5712. }
  5713. logStatus.error('Error: getWorkshopAppId failed');
  5714. return false;
  5715. }
  5716. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5717. return false;
  5718. }
  5719. logStatus.error(`${result}:${statusText}(${status})`);
  5720. return false;
  5721. } catch (error) {
  5722. throwError(error, 'Steam.getWorkshopAppId');
  5723. return false;
  5724. }
  5725. }
  5726. async function _voteUpWorkshop2(id) {
  5727. try {
  5728. const logStatus = scripts_echoLog({
  5729. type: 'votingUpWorkshop',
  5730. text: id
  5731. });
  5732. const {
  5733. result,
  5734. statusText,
  5735. status,
  5736. data
  5737. } = await tools_httpRequest({
  5738. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5739. method: 'POST',
  5740. responseType: 'json',
  5741. headers: {
  5742. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5743. },
  5744. data: $.param({
  5745. id: id,
  5746. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5747. })
  5748. });
  5749. if (result === 'Success') {
  5750. var _data$response5;
  5751. 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) {
  5752. logStatus.success();
  5753. return true;
  5754. }
  5755. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5756. return true;
  5757. }
  5758. logStatus.error(`${result}:${statusText}(${status})`);
  5759. return true;
  5760. } catch (error) {
  5761. throwError(error, 'Steam.voteupWorkshop');
  5762. return true;
  5763. }
  5764. }
  5765. async function _toggleCurator2(curatorId) {
  5766. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5767. try {
  5768. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5769. scripts_echoLog({
  5770. type: 'whiteList',
  5771. text: 'Steam.unfollowCurator',
  5772. id: curatorId
  5773. });
  5774. return true;
  5775. }
  5776. const logStatus = scripts_echoLog({
  5777. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5778. text: curatorId
  5779. });
  5780. const {
  5781. result,
  5782. statusText,
  5783. status,
  5784. data
  5785. } = await tools_httpRequest({
  5786. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5787. method: 'POST',
  5788. headers: {
  5789. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5790. },
  5791. data: $.param({
  5792. clanid: curatorId,
  5793. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5794. follow: doTask
  5795. }),
  5796. dataType: 'json'
  5797. });
  5798. if (result === 'Success') {
  5799. var _data$response6, _data$response6$succe, _data$response7;
  5800. 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) {
  5801. logStatus.success();
  5802. return true;
  5803. }
  5804. 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})`);
  5805. return false;
  5806. }
  5807. logStatus.error(`${result}:${statusText}(${status})`);
  5808. return false;
  5809. } catch (error) {
  5810. throwError(error, 'Steam.toggleCurator');
  5811. return false;
  5812. }
  5813. }
  5814. async function _toggleCuratorLike2(link) {
  5815. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5816. try {
  5817. const [ path, name ] = link.split('/');
  5818. if (!(path && name)) {
  5819. scripts_echoLog({
  5820. text: i18n('errorLink', link)
  5821. });
  5822. return false;
  5823. }
  5824. const curatorId = await this.getCuratorId(path, name);
  5825. if (curatorId) {
  5826. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5827. }
  5828. return false;
  5829. } catch (error) {
  5830. throwError(error, 'Steam.toggleCuratorLike');
  5831. return false;
  5832. }
  5833. }
  5834. async function _getAnnouncementParams2(appId, viewId) {
  5835. try {
  5836. const logStatus = scripts_echoLog({
  5837. type: 'gettingAnnouncementParams',
  5838. text: appId,
  5839. id: viewId
  5840. });
  5841. const {
  5842. result,
  5843. statusText,
  5844. status,
  5845. data
  5846. } = await tools_httpRequest({
  5847. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5848. method: 'GET',
  5849. headers: {
  5850. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5851. }
  5852. });
  5853. if (result === 'Success') {
  5854. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5855. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5856. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5857. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5858. 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];
  5859. if (authWgToken && clanId) {
  5860. logStatus.success();
  5861. return {
  5862. authWgToken: authWgToken,
  5863. clanId: clanId,
  5864. gid: gid
  5865. };
  5866. }
  5867. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5868. return {};
  5869. }
  5870. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5871. return {};
  5872. }
  5873. logStatus.error(`${result}:${statusText}(${status})`);
  5874. return {};
  5875. } catch (error) {
  5876. throwError(error, 'Steam.likeAnnouncement');
  5877. return {};
  5878. }
  5879. }
  5880. async function _likeAnnouncement2(id) {
  5881. try {
  5882. const [ appId, viewId ] = id.split('/');
  5883. if (!(appId && viewId)) {
  5884. scripts_echoLog({
  5885. type: 'lost params',
  5886. text: id
  5887. });
  5888. return false;
  5889. }
  5890. const {
  5891. authWgToken,
  5892. clanId,
  5893. gid
  5894. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5895. if (!(authWgToken && clanId)) {
  5896. return false;
  5897. }
  5898. const logStatus = scripts_echoLog({
  5899. type: 'likingAnnouncement',
  5900. text: appId,
  5901. id: viewId
  5902. });
  5903. const {
  5904. result,
  5905. statusText,
  5906. status,
  5907. data
  5908. } = await tools_httpRequest({
  5909. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5910. method: 'POST',
  5911. headers: {
  5912. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5913. Host: 'store.steampowered.com',
  5914. Origin: 'https://store.steampowered.com',
  5915. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5916. },
  5917. data: $.param({
  5918. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5919. wgauthtoken: authWgToken,
  5920. voteup: 1,
  5921. clanid: clanId,
  5922. ajax: 1
  5923. }),
  5924. dataType: 'json'
  5925. });
  5926. if (result === 'Success') {
  5927. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5928. logStatus.success();
  5929. return true;
  5930. }
  5931. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5932. return false;
  5933. }
  5934. logStatus.error(`${result}:${statusText}(${status})`);
  5935. return false;
  5936. } catch (error) {
  5937. throwError(error, 'Steam.likeAnnouncement');
  5938. return false;
  5939. }
  5940. }
  5941. function Steam_setCache2(type, name, id) {
  5942. try {
  5943. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  5944. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  5945. } catch (error) {
  5946. throwError(error, 'Steam.setCache');
  5947. }
  5948. }
  5949. const social_Steam = Steam;
  5950. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  5951. Website_checkPrivateRedeclaration(obj, privateSet);
  5952. privateSet.add(obj);
  5953. }
  5954. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  5955. if (privateCollection.has(obj)) {
  5956. throw new TypeError('Cannot initialize the same private elements twice on an object');
  5957. }
  5958. }
  5959. function Website_defineProperty(obj, key, value) {
  5960. if (key in obj) {
  5961. Object.defineProperty(obj, key, {
  5962. value: value,
  5963. enumerable: true,
  5964. configurable: true,
  5965. writable: true
  5966. });
  5967. } else {
  5968. obj[key] = value;
  5969. }
  5970. return obj;
  5971. }
  5972. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  5973. if (!privateSet.has(receiver)) {
  5974. throw new TypeError('attempted to get private field on non-instance');
  5975. }
  5976. return fn;
  5977. }
  5978. var _bind = new WeakSet();
  5979. class Website {
  5980. constructor() {
  5981. Website_classPrivateMethodInitSpec(this, _bind);
  5982. Website_defineProperty(this, 'undoneTasks', void 0);
  5983. Website_defineProperty(this, 'socialTasks', void 0);
  5984. Website_defineProperty(this, 'giveawayId', void 0);
  5985. Website_defineProperty(this, 'socialInitialized', {
  5986. discord: false,
  5987. instagram: false,
  5988. reddit: false,
  5989. twitch: false,
  5990. twitter: false,
  5991. vk: false,
  5992. youtube: false,
  5993. steam: false
  5994. });
  5995. Website_defineProperty(this, 'initialized', false);
  5996. Website_defineProperty(this, 'social', {});
  5997. }
  5998. async initSocial(action) {
  5999. try {
  6000. const pro = [];
  6001. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6002. if (tasks.discord) {
  6003. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6004. if (hasDiscord && !this.socialInitialized.discord) {
  6005. this.social.discord = new social_Discord();
  6006. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6007. }
  6008. }
  6009. if (tasks.instagram) {
  6010. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6011. if (hasInstagram && !this.socialInitialized.instagram) {
  6012. this.social.instagram = new social_Instagram();
  6013. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6014. }
  6015. }
  6016. if (tasks.reddit) {
  6017. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6018. if (hasReddit && !this.socialInitialized.reddit) {
  6019. this.social.reddit = new social_Reddit();
  6020. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6021. }
  6022. }
  6023. if (tasks.twitch) {
  6024. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6025. if (hasTwitch && !this.socialInitialized.twitch) {
  6026. this.social.twitch = new social_Twitch();
  6027. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6028. }
  6029. }
  6030. if (tasks.twitter) {
  6031. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6032. if (hasTwitter && !this.socialInitialized.twitter) {
  6033. this.social.twitter = new social_Twitter();
  6034. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6035. }
  6036. }
  6037. if (tasks.vk) {
  6038. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6039. if (hasVk && !this.socialInitialized.vk) {
  6040. this.social.vk = new social_Vk();
  6041. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6042. }
  6043. }
  6044. if (tasks.youtube) {
  6045. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6046. if (hasYoutube && !this.socialInitialized.youtube) {
  6047. this.social.youtube = new Youtube();
  6048. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6049. }
  6050. }
  6051. if (tasks.steam) {
  6052. const hasSteam = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6053. if (hasSteam && !this.socialInitialized.steam) {
  6054. this.social.steam = new social_Steam();
  6055. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steam', this.social.steam.init()));
  6056. }
  6057. }
  6058. if (tasks.links && tasks.links.length > 0) {
  6059. this.social.visitLink = visitLink;
  6060. }
  6061. return await Promise.all(pro).then(result => {
  6062. let checked = true;
  6063. for (const data of result) {
  6064. if (data.result) {
  6065. this.socialInitialized[data.name] = data.result;
  6066. } else {
  6067. checked = false;
  6068. }
  6069. }
  6070. return checked;
  6071. });
  6072. } catch (error) {
  6073. throwError(error, 'Website.initSocial');
  6074. return false;
  6075. }
  6076. }
  6077. uniqueTasks(allTasks) {
  6078. const result = {};
  6079. for (const [ social, types ] of Object.entries(allTasks)) {
  6080. result[social] = {};
  6081. for (const [ type, tasks ] of Object.entries(types)) {
  6082. result[social][type] = unique(tasks);
  6083. }
  6084. }
  6085. return result;
  6086. }
  6087. async toggleTask(action) {
  6088. try {
  6089. if (!this.initialized && !this.init()) {
  6090. return false;
  6091. }
  6092. if (!await this.classifyTask(action)) {
  6093. return false;
  6094. }
  6095. if (!await this.initSocial(action)) {
  6096. return false;
  6097. }
  6098. const pro = [];
  6099. const doTask = action === 'do';
  6100. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6101. if (this.social.discord) {
  6102. pro.push(this.social.discord.toggle({
  6103. doTask: doTask,
  6104. ...tasks.discord
  6105. }));
  6106. }
  6107. if (this.social.instagram) {
  6108. pro.push(this.social.instagram.toggle({
  6109. doTask: doTask,
  6110. ...tasks.instagram
  6111. }));
  6112. }
  6113. if (this.social.reddit) {
  6114. pro.push(this.social.reddit.toggle({
  6115. doTask: doTask,
  6116. ...tasks.reddit
  6117. }));
  6118. }
  6119. if (this.social.twitch) {
  6120. pro.push(this.social.twitch.toggle({
  6121. doTask: doTask,
  6122. ...tasks.twitch
  6123. }));
  6124. }
  6125. if (this.social.twitter) {
  6126. pro.push(this.social.twitter.toggle({
  6127. doTask: doTask,
  6128. ...tasks.twitter
  6129. }));
  6130. }
  6131. if (this.social.vk) {
  6132. pro.push(this.social.vk.toggle({
  6133. doTask: doTask,
  6134. ...tasks.vk
  6135. }));
  6136. }
  6137. if (this.social.youtube) {
  6138. pro.push(this.social.youtube.toggle({
  6139. doTask: doTask,
  6140. ...tasks.youtube
  6141. }));
  6142. }
  6143. if (this.social.steam) {
  6144. pro.push(this.social.steam.toggle({
  6145. doTask: doTask,
  6146. ...tasks.steam
  6147. }));
  6148. }
  6149. if (this.social.visitLink && tasks.links && doTask) {
  6150. for (const link of tasks.links) {
  6151. pro.push(this.social.visitLink(link));
  6152. }
  6153. }
  6154. if (doTask && tasks.extra && this.extraDoTask) {
  6155. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6156. if (hasExtra) {
  6157. pro.push(this.extraDoTask(tasks.extra));
  6158. }
  6159. }
  6160. await Promise.all(pro);
  6161. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6162. return true;
  6163. } catch (error) {
  6164. throwError(error, 'Website.toggleTask');
  6165. return false;
  6166. }
  6167. }
  6168. async doTask() {
  6169. try {
  6170. return await this.toggleTask('do');
  6171. } catch (error) {
  6172. throwError(error, 'Website.doTask');
  6173. return false;
  6174. }
  6175. }
  6176. async undoTask() {
  6177. try {
  6178. return await this.toggleTask('undo');
  6179. } catch (error) {
  6180. throwError(error, 'Website.undoTask');
  6181. return false;
  6182. }
  6183. }
  6184. }
  6185. async function _bind2(name, init) {
  6186. try {
  6187. return {
  6188. name: name,
  6189. result: await init
  6190. };
  6191. } catch (error) {
  6192. throwError(error, 'Website.bind');
  6193. return {
  6194. name: name,
  6195. result: false
  6196. };
  6197. }
  6198. }
  6199. const website_Website = Website;
  6200. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6201. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6202. privateSet.add(obj);
  6203. }
  6204. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6205. if (privateCollection.has(obj)) {
  6206. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6207. }
  6208. }
  6209. function FreeAnyWhere_defineProperty(obj, key, value) {
  6210. if (key in obj) {
  6211. Object.defineProperty(obj, key, {
  6212. value: value,
  6213. enumerable: true,
  6214. configurable: true,
  6215. writable: true
  6216. });
  6217. } else {
  6218. obj[key] = value;
  6219. }
  6220. return obj;
  6221. }
  6222. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6223. if (!privateSet.has(receiver)) {
  6224. throw new TypeError('attempted to get private field on non-instance');
  6225. }
  6226. return fn;
  6227. }
  6228. const FreeAnyWhere_defaultTasks = {
  6229. steam: {
  6230. groupLinks: [],
  6231. wishlistLinks: [],
  6232. curatorLinks: [],
  6233. followLinks: []
  6234. },
  6235. vk: {
  6236. nameLinks: []
  6237. }
  6238. };
  6239. var _getGiveawayId = new WeakSet();
  6240. var _verify = new WeakSet();
  6241. class FreeAnyWhere extends website_Website {
  6242. constructor() {
  6243. super(...arguments);
  6244. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6245. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6246. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6247. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6248. FreeAnyWhere_defineProperty(this, 'socialTasks', {
  6249. ...FreeAnyWhere_defaultTasks
  6250. });
  6251. FreeAnyWhere_defineProperty(this, 'undoneTasks', {
  6252. ...FreeAnyWhere_defaultTasks
  6253. });
  6254. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6255. }
  6256. static test() {
  6257. return window.location.host === 'freeanywhere.net';
  6258. }
  6259. init() {
  6260. try {
  6261. const logStatus = scripts_echoLog({
  6262. text: i18n('initing')
  6263. });
  6264. if ($('a[href="#/login"]').length > 0) {
  6265. window.open('/#/login', '_self');
  6266. logStatus.warning(i18n('needLogin'));
  6267. return false;
  6268. }
  6269. if (window.location.href.includes('/login')) {
  6270. logStatus.warning(i18n('needLogin'));
  6271. return false;
  6272. }
  6273. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6274. var _window$location$href;
  6275. 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];
  6276. if (!id) {
  6277. logStatus.error(i18n('getFailed', 'Id'));
  6278. return false;
  6279. }
  6280. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6281. }
  6282. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6283. return false;
  6284. }
  6285. this.initialized = true;
  6286. logStatus.success();
  6287. return true;
  6288. } catch (error) {
  6289. throwError(error, 'Freeanywhere.init');
  6290. return false;
  6291. }
  6292. }
  6293. async classifyTask(action) {
  6294. try {
  6295. const logStatus = scripts_echoLog({
  6296. text: i18n('getTasksInfo')
  6297. });
  6298. if (action === 'undo') {
  6299. var _GM_getValue;
  6300. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  6301. ...FreeAnyWhere_defaultTasks
  6302. };
  6303. }
  6304. const {
  6305. result,
  6306. statusText,
  6307. status,
  6308. data
  6309. } = await tools_httpRequest({
  6310. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6311. method: 'GET',
  6312. headers: {
  6313. authorization: `Token ${window.localStorage.getItem('token')}`,
  6314. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6315. },
  6316. responseType: 'json'
  6317. });
  6318. if (result === 'Success') {
  6319. var _data$response;
  6320. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6321. if (tasks) {
  6322. if (action === 'verify') {
  6323. this.tasks = [];
  6324. }
  6325. for (const task of tasks) {
  6326. const type = task.challenge;
  6327. const social = task.challenge_provider;
  6328. const taskInfo = {
  6329. id: task.id,
  6330. title: task.title
  6331. };
  6332. if (action === 'verify' && !task.is_success) {
  6333. this.tasks.push(taskInfo);
  6334. continue;
  6335. }
  6336. switch (social) {
  6337. case 'steam':
  6338. taskInfo.social = 'steam';
  6339. switch (type) {
  6340. case 'WL':
  6341. if (action === 'undo') {
  6342. this.socialTasks.steam.wishlistLinks.push(task.link);
  6343. }
  6344. if (action === 'do' && !task.is_success) {
  6345. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6346. }
  6347. break;
  6348.  
  6349. case 'JTG':
  6350. if (action === 'undo') {
  6351. this.socialTasks.steam.groupLinks.push(task.link);
  6352. }
  6353. if (action === 'do' && !task.is_success) {
  6354. this.undoneTasks.steam.groupLinks.push(task.link);
  6355. }
  6356. break;
  6357.  
  6358. case 'STC':
  6359. if (action === 'undo') {
  6360. this.socialTasks.steam.curatorLinks.push(task.link);
  6361. }
  6362. if (action === 'do' && !task.is_success) {
  6363. this.undoneTasks.steam.curatorLinks.push(task.link);
  6364. }
  6365. break;
  6366.  
  6367. case 'GF':
  6368. if (action === 'undo') {
  6369. this.socialTasks.steam.followLinks.push(task.link);
  6370. }
  6371. if (action === 'do' && !task.is_success) {
  6372. this.undoneTasks.steam.followLinks.push(task.link);
  6373. }
  6374. break;
  6375. }
  6376. break;
  6377.  
  6378. case 'vk-oauth2':
  6379. if (action === 'undo') {
  6380. this.socialTasks.vk.nameLinks.push(task.link);
  6381. }
  6382. if (action === 'do' && !task.is_success) {
  6383. this.undoneTasks.vk.nameLinks.push(task.link);
  6384. }
  6385. break;
  6386.  
  6387. case 'website':
  6388. break;
  6389.  
  6390. default:
  6391. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6392. break;
  6393. }
  6394. }
  6395. logStatus.success();
  6396. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6397. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6398. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6399. tasks: this.socialTasks,
  6400. time: new Date().getTime()
  6401. });
  6402. return true;
  6403. }
  6404. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6405. console.error(data);
  6406. return false;
  6407. }
  6408. logStatus.error(`${result}:${statusText}(${status})`);
  6409. return false;
  6410. } catch (error) {
  6411. throwError(error, 'Freeanywhere.classifyTask');
  6412. return false;
  6413. }
  6414. }
  6415. async verifyTask() {
  6416. try {
  6417. if (!this.initialized && !this.init()) {
  6418. return false;
  6419. }
  6420. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6421. return false;
  6422. }
  6423. const pro = [];
  6424. for (const task of this.tasks) {
  6425. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6426. await delay(1e3);
  6427. }
  6428. await Promise.all(pro);
  6429. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6430. return !!await this.getKey(true);
  6431. } catch (error) {
  6432. throwError(error, 'Freeanywhere.verifyTask');
  6433. return false;
  6434. }
  6435. }
  6436. async getKey(initialized) {
  6437. try {
  6438. if (!initialized && !this.initialized && !this.init()) {
  6439. return false;
  6440. }
  6441. const logStatus = scripts_echoLog({
  6442. text: i18n('gettingKey')
  6443. });
  6444. const {
  6445. result,
  6446. statusText,
  6447. status,
  6448. data
  6449. } = await tools_httpRequest({
  6450. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6451. method: 'GET',
  6452. dataType: 'json',
  6453. headers: {
  6454. authorization: `Token ${window.localStorage.getItem('token')}`
  6455. }
  6456. });
  6457. if (result === 'Success') {
  6458. var _data$response2;
  6459. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6460. logStatus.success();
  6461. scripts_echoLog({}).success(data.response.reward);
  6462. return data.response.reward;
  6463. }
  6464. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6465. return false;
  6466. }
  6467. logStatus.error(`${result}:${statusText}(${status})`);
  6468. return false;
  6469. } catch (error) {
  6470. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6471. return false;
  6472. }
  6473. }
  6474. }
  6475. function _getGiveawayId2() {
  6476. try {
  6477. var _window$location$href2;
  6478. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6479. if (giveawayId) {
  6480. this.giveawayId = giveawayId;
  6481. return true;
  6482. }
  6483. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6484. return false;
  6485. } catch (error) {
  6486. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6487. }
  6488. }
  6489. async function _verify2(task) {
  6490. try {
  6491. const logStatus = scripts_echoLog({
  6492. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6493. });
  6494. const {
  6495. result,
  6496. statusText,
  6497. status,
  6498. data
  6499. } = await tools_httpRequest({
  6500. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6501. method: 'GET',
  6502. dataType: 'json',
  6503. headers: {
  6504. authorization: `Token ${window.localStorage.getItem('token')}`,
  6505. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6506. }
  6507. });
  6508. if (result === 'Success') {
  6509. var _data$response3;
  6510. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6511. logStatus.success();
  6512. return true;
  6513. }
  6514. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6515. return false;
  6516. }
  6517. logStatus.error(`${result}:${statusText}(${status})`);
  6518. return false;
  6519. } catch (error) {
  6520. throwError(error, 'Freeanywhere.verify');
  6521. return false;
  6522. }
  6523. }
  6524. const website_FreeAnyWhere = FreeAnyWhere;
  6525. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6526. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6527. privateSet.add(obj);
  6528. }
  6529. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6530. if (privateCollection.has(obj)) {
  6531. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6532. }
  6533. }
  6534. function GiveawaySu_defineProperty(obj, key, value) {
  6535. if (key in obj) {
  6536. Object.defineProperty(obj, key, {
  6537. value: value,
  6538. enumerable: true,
  6539. configurable: true,
  6540. writable: true
  6541. });
  6542. } else {
  6543. obj[key] = value;
  6544. }
  6545. return obj;
  6546. }
  6547. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6548. if (!privateSet.has(receiver)) {
  6549. throw new TypeError('attempted to get private field on non-instance');
  6550. }
  6551. return fn;
  6552. }
  6553. const GiveawaySu_defaultTasks = {
  6554. steam: {
  6555. groupLinks: [],
  6556. wishlistLinks: [],
  6557. curatorLinks: [],
  6558. curatorLikeLinks: [],
  6559. followLinks: [],
  6560. forumLinks: [],
  6561. announcementLinks: [],
  6562. workshopVoteLinks: []
  6563. },
  6564. discord: {
  6565. serverLinks: []
  6566. },
  6567. instagram: {
  6568. userLinks: []
  6569. },
  6570. vk: {
  6571. nameLinks: []
  6572. },
  6573. twitch: {
  6574. channelLinks: []
  6575. },
  6576. reddit: {
  6577. redditLinks: []
  6578. },
  6579. youtube: {
  6580. channelLinks: [],
  6581. likeLinks: []
  6582. }
  6583. };
  6584. var _checkLogin = new WeakSet();
  6585. var _checkLeftKey = new WeakSet();
  6586. var GiveawaySu_getGiveawayId = new WeakSet();
  6587. class GiveawaySu extends website_Website {
  6588. constructor() {
  6589. super(...arguments);
  6590. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6591. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6592. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6593. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6594. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6595. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6596. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6597. }
  6598. static test() {
  6599. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6600. }
  6601. async after() {
  6602. try {
  6603. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6604. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6605. }
  6606. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6607. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6608. }
  6609. scripts_echoLog({}).warning(i18n('gsNotice'));
  6610. } catch (error) {
  6611. throwError(error, 'Giveawaysu.after');
  6612. }
  6613. }
  6614. init() {
  6615. try {
  6616. const logStatus = scripts_echoLog({
  6617. text: i18n('initing')
  6618. });
  6619. if ($('a.steam-login').length > 0) {
  6620. window.open('/steam/redirect', '_self');
  6621. logStatus.warning(i18n('needLogin'));
  6622. return false;
  6623. }
  6624. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6625. return false;
  6626. }
  6627. this.initialized = true;
  6628. logStatus.success();
  6629. return true;
  6630. } catch (error) {
  6631. throwError(error, 'Giveawaysu.init');
  6632. return false;
  6633. }
  6634. }
  6635. async classifyTask(action) {
  6636. try {
  6637. const logStatus = scripts_echoLog({
  6638. text: i18n('getTasksInfo')
  6639. });
  6640. if (action === 'undo') {
  6641. var _GM_getValue;
  6642. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6643. return true;
  6644. }
  6645. const pro = [];
  6646. const tasks = $('#actions tr');
  6647. if ($('div.bind-discord').is(':visible')) {
  6648. $('div.bind-discord a')[0].click();
  6649. }
  6650. if ($('div.bind-twitch').is(':visible')) {
  6651. $('div.bind-twitch a')[0].click();
  6652. }
  6653. for (const task of tasks) {
  6654. pro.push(new Promise(resolve => {
  6655. const td = $(task).find('td:not(".hidden")');
  6656. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6657. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6658. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6659. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6660. const taskName = taskDes.text().trim();
  6661. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6662. return resolve(true);
  6663. }
  6664. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6665. if (!taskLink) {
  6666. return resolve(false);
  6667. }
  6668. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6669. this.undoneTasks.steam.groupLinks.push(taskLink);
  6670. } else if (/like.*announcement/gi.test(taskName)) {
  6671. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6672. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6673. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6674. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6675. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6676. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6677. this.undoneTasks.steam.forumLinks.push(taskLink);
  6678. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6679. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6680. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6681. this.undoneTasks.discord.serverLinks.push(taskLink);
  6682. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6683. this.undoneTasks.instagram.userLinks.push(taskLink);
  6684. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6685. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6686. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6687. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6688. } else if (/watch.*art/gim.test(taskName)) {
  6689. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6690. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6691. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6692. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6693. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6694. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6695. this.undoneTasks.vk.nameLinks.push(taskLink);
  6696. } else {
  6697. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6698. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6699. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6700. }
  6701. if (/follow.*button/gim.test(taskName)) {
  6702. this.undoneTasks.steam.followLinks.push(taskLink);
  6703. }
  6704. }
  6705. }
  6706. resolve(true);
  6707. }).catch(error => {
  6708. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6709. return false;
  6710. });
  6711. }));
  6712. }
  6713. await Promise.all(pro);
  6714. logStatus.success();
  6715. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6716. this.socialTasks = this.undoneTasks;
  6717. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6718. tasks: this.socialTasks,
  6719. time: new Date().getTime()
  6720. });
  6721. return true;
  6722. } catch (error) {
  6723. throwError(error, 'Giveawaysu.classifyTask');
  6724. return false;
  6725. }
  6726. }
  6727. }
  6728. function _checkLogin2() {
  6729. try {
  6730. if (!globalOptions.other.checkLogin) {
  6731. return true;
  6732. }
  6733. if ($('a.steam-login').length > 0) {
  6734. window.open('/steam/redirect', '_self');
  6735. }
  6736. return true;
  6737. } catch (error) {
  6738. throwError(error, 'Giveawaysu.checkLogin');
  6739. return false;
  6740. }
  6741. }
  6742. async function _checkLeftKey2() {
  6743. try {
  6744. if (!globalOptions.other.checkLeftKey) {
  6745. return true;
  6746. }
  6747. if ($('.giveaway-ended').length > 0) {
  6748. await external_Swal_default().fire({
  6749. icon: 'warning',
  6750. title: i18n('notice'),
  6751. text: i18n('noKeysLeft'),
  6752. confirmButtonText: i18n('confirm'),
  6753. cancelButtonText: i18n('cancel'),
  6754. showCancelButton: true
  6755. }).then(_ref => {
  6756. let {
  6757. value
  6758. } = _ref;
  6759. if (value) {
  6760. window.close();
  6761. }
  6762. });
  6763. }
  6764. return true;
  6765. } catch (error) {
  6766. throwError(error, 'Giveawaysu.checkLeftKey');
  6767. return false;
  6768. }
  6769. }
  6770. function GiveawaySu_getGiveawayId2() {
  6771. var _window$location$href;
  6772. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6773. if (giveawayId) {
  6774. this.giveawayId = giveawayId;
  6775. return true;
  6776. }
  6777. scripts_echoLog({
  6778. text: i18n('getFailed', 'GiveawayId')
  6779. });
  6780. return false;
  6781. }
  6782. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6783. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6784. privateSet.add(obj);
  6785. }
  6786. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6787. if (privateCollection.has(obj)) {
  6788. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6789. }
  6790. }
  6791. function Indiedb_defineProperty(obj, key, value) {
  6792. if (key in obj) {
  6793. Object.defineProperty(obj, key, {
  6794. value: value,
  6795. enumerable: true,
  6796. configurable: true,
  6797. writable: true
  6798. });
  6799. } else {
  6800. obj[key] = value;
  6801. }
  6802. return obj;
  6803. }
  6804. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6805. if (!privateSet.has(receiver)) {
  6806. throw new TypeError('attempted to get private field on non-instance');
  6807. }
  6808. return fn;
  6809. }
  6810. var _join = new WeakSet();
  6811. var _do = new WeakSet();
  6812. var Indiedb_checkLogin = new WeakSet();
  6813. var Indiedb_checkLeftKey = new WeakSet();
  6814. class Indiedb {
  6815. constructor() {
  6816. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6817. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6818. Indiedb_classPrivateMethodInitSpec(this, _do);
  6819. Indiedb_classPrivateMethodInitSpec(this, _join);
  6820. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6821. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6822. }
  6823. static test() {
  6824. return window.location.host === 'www.indiedb.com';
  6825. }
  6826. async after() {
  6827. try {
  6828. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  6829. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6830. }
  6831. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  6832. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6833. }
  6834. } catch (error) {
  6835. throwError(error, 'Indiedb.after');
  6836. }
  6837. }
  6838. async doTask() {
  6839. try {
  6840. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  6841. return false;
  6842. }
  6843. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  6844. } catch (error) {
  6845. throwError(error, 'Indiedb.doTask');
  6846. return false;
  6847. }
  6848. }
  6849. }
  6850. async function _join2() {
  6851. try {
  6852. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6853. scripts_echoLog({}).error(i18n('needLogin'));
  6854. return false;
  6855. }
  6856. const currentoption = $('a.buttonenter.buttongiveaway');
  6857. if (/join giveaway/gim.test(currentoption.text())) {
  6858. const logStatus = scripts_echoLog({
  6859. text: `${i18n('joiningGiveaway')}...`
  6860. });
  6861. const {
  6862. result,
  6863. statusText,
  6864. status,
  6865. data
  6866. } = await tools_httpRequest({
  6867. url: currentoption.attr('href'),
  6868. method: 'POST',
  6869. data: 'ajax=t',
  6870. dataType: 'json',
  6871. headers: {
  6872. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6873. accept: 'application/json, text/javascript, */*; q=0.01',
  6874. origin: window.location.origin
  6875. }
  6876. });
  6877. if (result === 'Success') {
  6878. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6879. var _data$response, _data$response4, _data$response5;
  6880. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6881. var _data$response2, _data$response3;
  6882. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6883. $('#giveawaysjoined').slideDown();
  6884. $('#giveawaysrecommend').slideDown();
  6885. 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}` : ''}`);
  6886. return true;
  6887. }
  6888. 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}` : ''}`);
  6889. return false;
  6890. }
  6891. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6892. return false;
  6893. }
  6894. logStatus.error(`${result}:${statusText}(${status})`);
  6895. return false;
  6896. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6897. return true;
  6898. }
  6899. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6900. return false;
  6901. } catch (error) {
  6902. throwError(error, 'Indiedb.init');
  6903. return false;
  6904. }
  6905. }
  6906. async function _do2() {
  6907. try {
  6908. const id = $('script').map((index, script) => {
  6909. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6910. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6911. 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] ];
  6912. }
  6913. return null;
  6914. });
  6915. if (id.length === 2) {
  6916. const pro = [];
  6917. const tasks = $('#giveawaysjoined a[class*=promo]');
  6918. for (const task of tasks) {
  6919. const promo = $(task);
  6920. if (!promo.hasClass('buttonentered')) {
  6921. const status = scripts_echoLog({
  6922. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6923. });
  6924. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6925. let text = '';
  6926. if (promo.hasClass('facebookpromo')) {
  6927. text = 'facebookpromo';
  6928. } else if (promo.hasClass('twitterpromo')) {
  6929. text = 'twitterpromo';
  6930. } else {
  6931. text = 'visitpromo';
  6932. }
  6933. pro.push(new Promise(resolve => {
  6934. $.ajax({
  6935. type: 'POST',
  6936. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6937. timeout: 6e4,
  6938. dataType: 'json',
  6939. data: {
  6940. ajax: 't'
  6941. },
  6942. error(response, error, exception) {
  6943. console.log({
  6944. response: response,
  6945. error: error,
  6946. exception: exception
  6947. });
  6948. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6949. resolve(true);
  6950. },
  6951. success(response) {
  6952. console.log(response);
  6953. if (response.success) {
  6954. status.success(`Success:${response.text}`);
  6955. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6956. resolve(true);
  6957. } else {
  6958. status.error(`Error:${response.text}`);
  6959. resolve(true);
  6960. }
  6961. }
  6962. });
  6963. }));
  6964. } else if (promo.hasClass('emailoptinpromo')) {
  6965. pro.push(new Promise(resolve => {
  6966. $.ajax({
  6967. type: 'POST',
  6968. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6969. timeout: 6e4,
  6970. dataType: 'json',
  6971. data: {
  6972. ajax: 't',
  6973. emailsystoggle: 4
  6974. },
  6975. error(response, error, exception) {
  6976. console.log({
  6977. response: response,
  6978. error: error,
  6979. exception: exception
  6980. });
  6981. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6982. resolve(true);
  6983. },
  6984. success(response) {
  6985. console.log(response);
  6986. if (response.success) {
  6987. status.success(`Success:${response.text}`);
  6988. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6989. resolve(true);
  6990. } else {
  6991. status.error(`Error:${response.text}`);
  6992. resolve(true);
  6993. }
  6994. }
  6995. });
  6996. }));
  6997. } else if (promo.hasClass('watchingpromo')) {
  6998. pro.push(new Promise(resolve => {
  6999. var _promo$attr;
  7000. const data = getUrlQuery(promo.attr('href'));
  7001. data.ajax = 't';
  7002. $.ajax({
  7003. type: 'POST',
  7004. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7005. timeout: 6e4,
  7006. dataType: 'json',
  7007. data: data,
  7008. error(response, error, exception) {
  7009. console.log({
  7010. response: response,
  7011. error: error,
  7012. exception: exception
  7013. });
  7014. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7015. resolve(true);
  7016. },
  7017. success(response) {
  7018. console.log(response);
  7019. if (response.success) {
  7020. status.success(`Success:${response.text}`);
  7021. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7022. resolve(true);
  7023. } else {
  7024. status.error(`Error:${response.text}`);
  7025. resolve(true);
  7026. }
  7027. }
  7028. });
  7029. }));
  7030. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7031. pro.push(new Promise(resolve => {
  7032. $.ajax({
  7033. type: 'POST',
  7034. url: urlPath(promo.attr('href')),
  7035. timeout: 6e4,
  7036. dataType: 'json',
  7037. data: {
  7038. ajax: 't'
  7039. },
  7040. error(response, error, exception) {
  7041. console.log({
  7042. response: response,
  7043. error: error,
  7044. exception: exception
  7045. });
  7046. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7047. resolve(true);
  7048. },
  7049. success(response) {
  7050. console.log(response);
  7051. if (response.success) {
  7052. status.success(`Success:${response.text}`);
  7053. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7054. resolve(true);
  7055. } else {
  7056. status.error(`Error:${response.text}`);
  7057. resolve(true);
  7058. }
  7059. }
  7060. });
  7061. }));
  7062. } else {
  7063. status.error(`Error:${i18n('unKnownTaskType')}`);
  7064. }
  7065. }
  7066. }
  7067. await Promise.all(pro);
  7068. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7069. return true;
  7070. }
  7071. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7072. return false;
  7073. } catch (error) {
  7074. throwError(error, 'Indiedb.classifyTask');
  7075. return false;
  7076. }
  7077. }
  7078. function Indiedb_checkLogin2() {
  7079. try {
  7080. if (!globalOptions.other.checkLogin) {
  7081. return true;
  7082. }
  7083. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7084. window.open('/members/login', '_self');
  7085. }
  7086. return true;
  7087. } catch (error) {
  7088. throwError(error, 'Indiedb.checkLogin');
  7089. return false;
  7090. }
  7091. }
  7092. async function Indiedb_checkLeftKey2() {
  7093. try {
  7094. if (!globalOptions.other.checkLeftKey) {
  7095. return true;
  7096. }
  7097. if ($('a.buttonenter:contains("next time")').length > 0) {
  7098. await external_Swal_default().fire({
  7099. icon: 'warning',
  7100. title: i18n('notice'),
  7101. text: i18n('giveawayEnded'),
  7102. confirmButtonText: i18n('confirm'),
  7103. cancelButtonText: i18n('cancel'),
  7104. showCancelButton: true
  7105. }).then(_ref => {
  7106. let {
  7107. value
  7108. } = _ref;
  7109. if (value) {
  7110. window.close();
  7111. }
  7112. });
  7113. }
  7114. return true;
  7115. } catch (error) {
  7116. throwError(error, 'Indiedb.checkLeftKey');
  7117. return false;
  7118. }
  7119. }
  7120. const website_Indiedb = Indiedb;
  7121. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7122. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7123. privateSet.add(obj);
  7124. }
  7125. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7126. if (privateCollection.has(obj)) {
  7127. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7128. }
  7129. }
  7130. function Keyhub_defineProperty(obj, key, value) {
  7131. if (key in obj) {
  7132. Object.defineProperty(obj, key, {
  7133. value: value,
  7134. enumerable: true,
  7135. configurable: true,
  7136. writable: true
  7137. });
  7138. } else {
  7139. obj[key] = value;
  7140. }
  7141. return obj;
  7142. }
  7143. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7144. if (!privateSet.has(receiver)) {
  7145. throw new TypeError('attempted to get private field on non-instance');
  7146. }
  7147. return fn;
  7148. }
  7149. const Keyhub_defaultTasks = {
  7150. steam: {
  7151. groupLinks: [],
  7152. wishlistLinks: [],
  7153. curatorLinks: []
  7154. },
  7155. discord: {
  7156. serverLinks: []
  7157. },
  7158. links: []
  7159. };
  7160. var Keyhub_getGiveawayId = new WeakSet();
  7161. var Keyhub_checkLeftKey = new WeakSet();
  7162. var Keyhub_checkLogin = new WeakSet();
  7163. class Keyhub extends website_Website {
  7164. constructor() {
  7165. super(...arguments);
  7166. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7167. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7168. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7169. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7170. Keyhub_defineProperty(this, 'socialTasks', {
  7171. ...Keyhub_defaultTasks
  7172. });
  7173. Keyhub_defineProperty(this, 'undoneTasks', {
  7174. ...Keyhub_defaultTasks
  7175. });
  7176. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7177. }
  7178. static test() {
  7179. return window.location.host === 'key-hub.eu';
  7180. }
  7181. async after() {
  7182. try {
  7183. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7184. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7185. }
  7186. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7187. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7188. }
  7189. } catch (error) {
  7190. throwError(error, 'Keyhub.after');
  7191. }
  7192. }
  7193. init() {
  7194. try {
  7195. const logStatus = scripts_echoLog({
  7196. text: i18n('initing')
  7197. });
  7198. if ($('a[href*="/connect/steam"]').length > 0) {
  7199. window.open('/connect/steam', '_self');
  7200. logStatus.warning(i18n('needLogin'));
  7201. return false;
  7202. }
  7203. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7204. return false;
  7205. }
  7206. $('#VPNoverlay').hide();
  7207. $('#mainArticleSection').show();
  7208. this.initialized = true;
  7209. logStatus.success();
  7210. return true;
  7211. } catch (error) {
  7212. throwError(error, 'Keyhub.init');
  7213. return false;
  7214. }
  7215. }
  7216. async classifyTask(action) {
  7217. try {
  7218. const logStatus = scripts_echoLog({
  7219. text: i18n('getTasksInfo')
  7220. });
  7221. if (action === 'undo') {
  7222. var _GM_getValue;
  7223. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  7224. ...Keyhub_defaultTasks
  7225. };
  7226. }
  7227. const tasks = $('.task a');
  7228. for (const task of tasks) {
  7229. let link = $(task).attr('href');
  7230. const taskDes = $(task).text().trim();
  7231. if (!link) {
  7232. continue;
  7233. }
  7234. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7235. link = await getRedirectLink(link) || link;
  7236. }
  7237. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7238. window.open(link, '_blank');
  7239. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7240. if (action === 'undo') {
  7241. this.socialTasks.steam.groupLinks.push(link);
  7242. }
  7243. if (action === 'do') {
  7244. this.undoneTasks.steam.groupLinks.push(link);
  7245. }
  7246. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7247. if (action === 'undo') {
  7248. this.socialTasks.steam.wishlistLinks.push(link);
  7249. }
  7250. if (action === 'do') {
  7251. this.undoneTasks.steam.wishlistLinks.push(link);
  7252. }
  7253. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7254. if (action === 'undo') {
  7255. this.socialTasks.steam.curatorLinks.push(link);
  7256. }
  7257. if (action === 'do') {
  7258. this.undoneTasks.steam.curatorLinks.push(link);
  7259. }
  7260. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7261. if (action === 'undo') {
  7262. this.socialTasks.discord.serverLinks.push(link);
  7263. }
  7264. if (action === 'do') {
  7265. this.undoneTasks.discord.serverLinks.push(link);
  7266. }
  7267. } else {
  7268. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7269. }
  7270. }
  7271. logStatus.success();
  7272. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7273. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7274. GM_setValue(`khTasks-${this.giveawayId}`, {
  7275. tasks: this.socialTasks,
  7276. time: new Date().getTime()
  7277. });
  7278. return true;
  7279. } catch (error) {
  7280. throwError(error, 'Keyhub.classifyTask');
  7281. return false;
  7282. }
  7283. }
  7284. verifyTask() {
  7285. try {
  7286. scripts_echoLog({
  7287. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7288. });
  7289. $.get(window.location.href, res => {
  7290. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7291. });
  7292. } catch (error) {
  7293. throwError(error, 'keyhub.verifyTask');
  7294. }
  7295. }
  7296. }
  7297. function Keyhub_getGiveawayId2() {
  7298. try {
  7299. var _window$location$href;
  7300. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7301. if (giveawayId) {
  7302. this.giveawayId = giveawayId;
  7303. return true;
  7304. }
  7305. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7306. return false;
  7307. } catch (error) {
  7308. throwError(error, 'Keyhub.getGiveawayId');
  7309. return false;
  7310. }
  7311. }
  7312. async function Keyhub_checkLeftKey2() {
  7313. try {
  7314. if (!globalOptions.other.checkLeftKey) {
  7315. return true;
  7316. }
  7317. const leftKey = $('#keysleft').text().trim();
  7318. if (leftKey === '0') {
  7319. await external_Swal_default().fire({
  7320. icon: 'warning',
  7321. title: i18n('notice'),
  7322. text: i18n('noKeysLeft'),
  7323. confirmButtonText: i18n('confirm'),
  7324. cancelButtonText: i18n('cancel'),
  7325. showCancelButton: true
  7326. }).then(_ref => {
  7327. let {
  7328. value
  7329. } = _ref;
  7330. if (value) {
  7331. window.close();
  7332. }
  7333. });
  7334. }
  7335. return true;
  7336. } catch (error) {
  7337. throwError(error, 'Keyhub.checkLeftKey');
  7338. return false;
  7339. }
  7340. }
  7341. function Keyhub_checkLogin2() {
  7342. try {
  7343. if (!globalOptions.other.checkLogin) {
  7344. return true;
  7345. }
  7346. if ($('a[href*="/connect/steam"]').length > 0) {
  7347. window.open('/connect/steam', '_self');
  7348. }
  7349. return true;
  7350. } catch (error) {
  7351. throwError(error, 'Keyhub.checkLogin');
  7352. return false;
  7353. }
  7354. }
  7355. const website_Keyhub = Keyhub;
  7356. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7357. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7358. privateSet.add(obj);
  7359. }
  7360. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7361. if (privateCollection.has(obj)) {
  7362. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7363. }
  7364. }
  7365. function Givekey_defineProperty(obj, key, value) {
  7366. if (key in obj) {
  7367. Object.defineProperty(obj, key, {
  7368. value: value,
  7369. enumerable: true,
  7370. configurable: true,
  7371. writable: true
  7372. });
  7373. } else {
  7374. obj[key] = value;
  7375. }
  7376. return obj;
  7377. }
  7378. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7379. if (!privateSet.has(receiver)) {
  7380. throw new TypeError('attempted to get private field on non-instance');
  7381. }
  7382. return fn;
  7383. }
  7384. const Givekey_defaultTasks = {
  7385. steam: {
  7386. groupLinks: [],
  7387. wishlistLinks: [],
  7388. curatorLinks: [],
  7389. curatorLikeLinks: []
  7390. },
  7391. twitter: {
  7392. userLinks: []
  7393. },
  7394. vk: {
  7395. nameLinks: []
  7396. },
  7397. discord: {
  7398. serverLinks: []
  7399. }
  7400. };
  7401. var Givekey_verify = new WeakSet();
  7402. var Givekey_getGiveawayId = new WeakSet();
  7403. var Givekey_checkLeftKey = new WeakSet();
  7404. class Givekey extends website_Website {
  7405. constructor() {
  7406. super(...arguments);
  7407. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7408. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7409. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7410. Givekey_defineProperty(this, 'name', 'Givekey');
  7411. Givekey_defineProperty(this, 'tasks', []);
  7412. Givekey_defineProperty(this, 'socialTasks', {
  7413. ...Givekey_defaultTasks
  7414. });
  7415. Givekey_defineProperty(this, 'undoneTasks', {
  7416. ...Givekey_defaultTasks
  7417. });
  7418. Givekey_defineProperty(this, 'userId', void 0);
  7419. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7420. }
  7421. static test() {
  7422. return window.location.host === 'givekey.ru';
  7423. }
  7424. async after() {
  7425. try {
  7426. await new Promise(resolve => {
  7427. const checker = setInterval(() => {
  7428. if ($('#navbarDropdown').length > 0) {
  7429. clearInterval(checker);
  7430. resolve(true);
  7431. }
  7432. });
  7433. });
  7434. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7435. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7436. }
  7437. } catch (error) {
  7438. throwError(error, 'Givekey.after');
  7439. return false;
  7440. }
  7441. }
  7442. init() {
  7443. try {
  7444. const logStatus = scripts_echoLog({
  7445. text: i18n('initing')
  7446. });
  7447. if ($('a[href*="/auth/steam"]').length > 0) {
  7448. window.open('/auth/steam', '_self');
  7449. logStatus.warning(i18n('needLogin'));
  7450. return false;
  7451. }
  7452. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7453. return false;
  7454. }
  7455. const userId = $('meta[name="user-id"]').attr('content');
  7456. if (!userId) {
  7457. logStatus.error(i18n('getFailed', i18n('userId')));
  7458. return false;
  7459. }
  7460. this.userId = userId;
  7461. this.initialized = true;
  7462. logStatus.success();
  7463. return true;
  7464. } catch (error) {
  7465. throwError(error, 'Givekey.init');
  7466. return false;
  7467. }
  7468. }
  7469. async classifyTask(action) {
  7470. try {
  7471. const logStatus = scripts_echoLog({
  7472. text: i18n('getTasksInfo')
  7473. });
  7474. if (action === 'undo') {
  7475. var _GM_getValue;
  7476. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || Givekey_defaultTasks;
  7477. }
  7478. const tasks = $('.card-body:has("button") .row');
  7479. for (const task of tasks) {
  7480. const taskEle = $(task);
  7481. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7482. if (isSuccess && action !== 'undo') {
  7483. continue;
  7484. }
  7485. const checkButton = taskEle.find('#task_check');
  7486. const taskId = checkButton.attr('data-id');
  7487. if (taskId) {
  7488. this.tasks.push(taskId);
  7489. }
  7490. if (action === 'verify') {
  7491. continue;
  7492. }
  7493. let href = taskEle.find('a').attr('href') || null;
  7494. const text = taskEle.find('a').text().trim();
  7495. const icon = taskEle.find('i');
  7496. if (!href || !text) {
  7497. continue;
  7498. }
  7499. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7500. href = await getRedirectLink(href);
  7501. }
  7502. if (!href) {
  7503. continue;
  7504. }
  7505. if (/^https?:\/\/vk\.com\//.test(href)) {
  7506. this.socialTasks.vk.nameLinks.push(href);
  7507. if (action === 'do' && !isSuccess) {
  7508. this.undoneTasks.vk.nameLinks.push(href);
  7509. }
  7510. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7511. this.socialTasks.steam.groupLinks.push(href);
  7512. if (action === 'do' && !isSuccess) {
  7513. this.undoneTasks.steam.groupLinks.push(href);
  7514. }
  7515. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7516. this.socialTasks.steam.wishlistLinks.push(href);
  7517. if (action === 'do' && !isSuccess) {
  7518. this.undoneTasks.steam.wishlistLinks.push(href);
  7519. }
  7520. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7521. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7522. this.socialTasks.steam.curatorLinks.push(href);
  7523. if (action === 'do' && !isSuccess) {
  7524. this.undoneTasks.steam.curatorLinks.push(href);
  7525. }
  7526. } else {
  7527. this.socialTasks.steam.curatorLikeLinks.push(href);
  7528. if (action === 'do' && !isSuccess) {
  7529. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7530. }
  7531. }
  7532. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7533. this.socialTasks.twitter.userLinks.push(href);
  7534. if (action === 'do' && !isSuccess) {
  7535. this.undoneTasks.twitter.userLinks.push(href);
  7536. }
  7537. } else if (icon.hasClass('fa-discord')) {
  7538. this.socialTasks.discord.serverLinks.push(href);
  7539. if (action === 'do' && !isSuccess) {
  7540. this.undoneTasks.discord.serverLinks.push(href);
  7541. }
  7542. } else {
  7543. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7544. }
  7545. }
  7546. logStatus.success();
  7547. this.tasks = unique(this.tasks);
  7548. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7549. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7550. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7551. tasks: this.socialTasks,
  7552. time: new Date().getTime()
  7553. });
  7554. return true;
  7555. } catch (error) {
  7556. throwError(error, 'Givekey.classifyTask');
  7557. return false;
  7558. }
  7559. }
  7560. async verifyTask() {
  7561. try {
  7562. if (!this.initialized && !this.init()) {
  7563. return false;
  7564. }
  7565. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7566. return false;
  7567. }
  7568. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7569. const taskLength = this.tasks.length;
  7570. for (let i = 0; i < taskLength; i++) {
  7571. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7572. if (i < taskLength - 1) {
  7573. await delay(15e3);
  7574. }
  7575. }
  7576. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7577. scripts_echoLog({
  7578. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7579. });
  7580. return true;
  7581. } catch (error) {
  7582. throwError(error, 'Givekey.verifyTask');
  7583. return false;
  7584. }
  7585. }
  7586. }
  7587. async function Givekey_verify2(task) {
  7588. try {
  7589. const logStatus = scripts_echoLog({
  7590. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7591. });
  7592. return await new Promise(resolve => {
  7593. $.ajax({
  7594. url: 'https://givekey.ru/giveaway/task',
  7595. method: 'POST',
  7596. data: `id=${task}&user_id=${this.userId}`,
  7597. dataType: 'json',
  7598. headers: {
  7599. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7600. },
  7601. success: data => {
  7602. if (data.btn) {
  7603. $(`button[data-id=${this.userId}]`).html(data.btn);
  7604. }
  7605. if (data.status === 'ok') {
  7606. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7607. logStatus.success();
  7608. resolve(true);
  7609. } else if (data.status === 'end') {
  7610. logStatus.success();
  7611. scripts_echoLog({}).success(data.key);
  7612. resolve(true);
  7613. } else {
  7614. logStatus.error(`Error:${data.msg}`);
  7615. resolve(false);
  7616. }
  7617. },
  7618. error: xhr => {
  7619. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7620. resolve(false);
  7621. }
  7622. });
  7623. });
  7624. } catch (error) {
  7625. throwError(error, 'Givekey.verify');
  7626. return false;
  7627. }
  7628. }
  7629. function Givekey_getGiveawayId2() {
  7630. try {
  7631. var _window$location$href;
  7632. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7633. if (giveawayId) {
  7634. this.giveawayId = giveawayId;
  7635. return true;
  7636. }
  7637. scripts_echoLog({
  7638. text: i18n('getFailed', 'GiveawayId')
  7639. });
  7640. return false;
  7641. } catch (error) {
  7642. throwError(error, 'Givekey.getGiveawayId');
  7643. return false;
  7644. }
  7645. }
  7646. async function Givekey_checkLeftKey2() {
  7647. try {
  7648. if (!globalOptions.other.checkLeftKey) {
  7649. return true;
  7650. }
  7651. if (!$('#keys_count').text()) {
  7652. await external_Swal_default().fire({
  7653. icon: 'warning',
  7654. title: i18n('notice'),
  7655. text: i18n('noKeysLeft'),
  7656. confirmButtonText: i18n('confirm'),
  7657. cancelButtonText: i18n('cancel'),
  7658. showCancelButton: true
  7659. }).then(_ref => {
  7660. let {
  7661. value
  7662. } = _ref;
  7663. if (value) {
  7664. window.close();
  7665. }
  7666. });
  7667. }
  7668. return true;
  7669. } catch (error) {
  7670. throwError(error, 'Givekey.checkLeftKey');
  7671. return false;
  7672. }
  7673. }
  7674. const website_Givekey = Givekey;
  7675. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7676. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7677. privateSet.add(obj);
  7678. }
  7679. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7680. if (privateCollection.has(obj)) {
  7681. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7682. }
  7683. }
  7684. function GiveeClub_defineProperty(obj, key, value) {
  7685. if (key in obj) {
  7686. Object.defineProperty(obj, key, {
  7687. value: value,
  7688. enumerable: true,
  7689. configurable: true,
  7690. writable: true
  7691. });
  7692. } else {
  7693. obj[key] = value;
  7694. }
  7695. return obj;
  7696. }
  7697. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7698. if (!privateSet.has(receiver)) {
  7699. throw new TypeError('attempted to get private field on non-instance');
  7700. }
  7701. return fn;
  7702. }
  7703. var GiveeClub_checkLogin = new WeakSet();
  7704. var GiveeClub_getGiveawayId = new WeakSet();
  7705. var GiveeClub_checkLeftKey = new WeakSet();
  7706. class GiveeClub extends GiveawaySu {
  7707. constructor() {
  7708. super(...arguments);
  7709. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7710. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7711. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7712. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7713. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7714. }
  7715. static test() {
  7716. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7717. }
  7718. async after() {
  7719. try {
  7720. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7721. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7722. }
  7723. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7724. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7725. }
  7726. } catch (error) {
  7727. throwError(error, 'GiveeClub.after');
  7728. }
  7729. }
  7730. init() {
  7731. try {
  7732. const logStatus = scripts_echoLog({
  7733. text: i18n('initing')
  7734. });
  7735. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7736. logStatus.warning(i18n('needLogin'));
  7737. return false;
  7738. }
  7739. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7740. return false;
  7741. }
  7742. this.initialized = true;
  7743. logStatus.success();
  7744. return true;
  7745. } catch (error) {
  7746. throwError(error, 'GiveeClub.init');
  7747. return false;
  7748. }
  7749. }
  7750. async classifyTask(action) {
  7751. try {
  7752. const logStatus = scripts_echoLog({
  7753. text: i18n('getTasksInfo')
  7754. });
  7755. if (action === 'undo') {
  7756. var _GM_getValue;
  7757. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7758. return true;
  7759. }
  7760. const pro = [];
  7761. const tasks = $('.event-actions tr');
  7762. for (const task of tasks) {
  7763. pro.push(new Promise(resolve => {
  7764. const taskDes = $(task).find('.event-action-label a');
  7765. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7766. const taskName = taskDes.text().trim();
  7767. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7768. return resolve(true);
  7769. }
  7770. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7771. if (!taskLink) {
  7772. return resolve(false);
  7773. }
  7774. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7775. this.undoneTasks.steam.groupLinks.push(taskLink);
  7776. } else if (/like.*announcement/gi.test(taskName)) {
  7777. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7778. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7779. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7780. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7781. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7782. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7783. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7784. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7785. this.undoneTasks.steam.forumLinks.push(taskLink);
  7786. } else if (taskIcon.includes('discord')) {
  7787. this.undoneTasks.discord.serverLinks.push(taskLink);
  7788. } else if (taskIcon.includes('instagram')) {
  7789. this.undoneTasks.instagram.userLinks.push(taskLink);
  7790. } else if (taskIcon.includes('twitch')) {
  7791. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7792. } else if (taskIcon.includes('reddit')) {
  7793. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7794. } else if (/watch.*art/gim.test(taskName)) {
  7795. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7796. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7797. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7798. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7799. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7800. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7801. this.undoneTasks.vk.nameLinks.push(taskLink);
  7802. } else {
  7803. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7804. if (/follow.*button/gim.test(taskName)) {
  7805. this.undoneTasks.steam.followLinks.push(taskLink);
  7806. }
  7807. }
  7808. }
  7809. resolve(true);
  7810. }).catch(error => {
  7811. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7812. return false;
  7813. });
  7814. }));
  7815. }
  7816. await Promise.all(pro);
  7817. logStatus.success();
  7818. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7819. this.socialTasks = this.undoneTasks;
  7820. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7821. tasks: this.socialTasks,
  7822. time: new Date().getTime()
  7823. });
  7824. return true;
  7825. } catch (error) {
  7826. throwError(error, 'GiveeClub.classifyTask');
  7827. return false;
  7828. }
  7829. }
  7830. }
  7831. function GiveeClub_checkLogin2() {
  7832. try {
  7833. if (!globalOptions.other.checkLogin) {
  7834. return true;
  7835. }
  7836. if ($('a[href*="/account/auth"]').length > 0) {
  7837. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7838. }
  7839. return true;
  7840. } catch (error) {
  7841. throwError(error, 'GiveeClub.checkLogin');
  7842. return false;
  7843. }
  7844. }
  7845. function GiveeClub_getGiveawayId2() {
  7846. var _window$location$href;
  7847. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7848. if (giveawayId) {
  7849. this.giveawayId = giveawayId;
  7850. return true;
  7851. }
  7852. scripts_echoLog({
  7853. text: i18n('getFailed', 'GiveawayId')
  7854. });
  7855. return false;
  7856. }
  7857. async function GiveeClub_checkLeftKey2() {
  7858. try {
  7859. if (!globalOptions.other.checkLeftKey) {
  7860. return true;
  7861. }
  7862. if ($('.event-ended').length > 0) {
  7863. await external_Swal_default().fire({
  7864. icon: 'warning',
  7865. title: i18n('notice'),
  7866. text: i18n('giveawayEnded'),
  7867. confirmButtonText: i18n('confirm'),
  7868. cancelButtonText: i18n('cancel'),
  7869. showCancelButton: true
  7870. }).then(_ref => {
  7871. let {
  7872. value
  7873. } = _ref;
  7874. if (value) {
  7875. window.close();
  7876. }
  7877. });
  7878. }
  7879. return true;
  7880. } catch (error) {
  7881. throwError(error, 'Giveawaysu.checkLeftKey');
  7882. return false;
  7883. }
  7884. }
  7885. const website_GiveeClub = GiveeClub;
  7886. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  7887. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  7888. privateSet.add(obj);
  7889. }
  7890. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  7891. if (privateCollection.has(obj)) {
  7892. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7893. }
  7894. }
  7895. function OpiumPulses_defineProperty(obj, key, value) {
  7896. if (key in obj) {
  7897. Object.defineProperty(obj, key, {
  7898. value: value,
  7899. enumerable: true,
  7900. configurable: true,
  7901. writable: true
  7902. });
  7903. } else {
  7904. obj[key] = value;
  7905. }
  7906. return obj;
  7907. }
  7908. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  7909. if (!privateSet.has(receiver)) {
  7910. throw new TypeError('attempted to get private field on non-instance');
  7911. }
  7912. return fn;
  7913. }
  7914. const defaultOptions = {
  7915. maxPoint: '99999999'
  7916. };
  7917. var _toggleTask = new WeakSet();
  7918. var OpiumPulses_checkLogin = new WeakSet();
  7919. class OpiumPulses {
  7920. constructor() {
  7921. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  7922. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  7923. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  7924. OpiumPulses_defineProperty(this, 'options', {
  7925. ...defaultOptions,
  7926. ...GM_getValue('OpiumPulsesOptions')
  7927. });
  7928. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  7929. OpiumPulses_defineProperty(this, 'myPoints', 0);
  7930. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  7931. }
  7932. static test() {
  7933. return window.location.host === 'www.opiumpulses.com';
  7934. }
  7935. async after() {
  7936. try {
  7937. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  7938. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7939. }
  7940. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7941. } catch (error) {
  7942. throwError(error, 'OpiumPulses.after');
  7943. }
  7944. }
  7945. async doFreeTask() {
  7946. try {
  7947. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  7948. } catch (error) {
  7949. throwError(error, 'OpiumPulses.doFreeTask');
  7950. }
  7951. }
  7952. async doPointTask() {
  7953. try {
  7954. var _$$text$match;
  7955. 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);
  7956. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  7957. } catch (error) {
  7958. throwError(error, 'OpiumPulses.doPointTask');
  7959. }
  7960. }
  7961. init() {
  7962. return true;
  7963. }
  7964. classifyTask() {
  7965. return true;
  7966. }
  7967. }
  7968. async function _toggleTask2(type) {
  7969. try {
  7970. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7971. for (const item of items) {
  7972. var _$$find$text$match;
  7973. 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);
  7974. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7975. if (type === 'points' && needPoints > this.myPoints) {
  7976. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7977. } else if (type === 'points' && !needPoints) {
  7978. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  7979. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  7980. var _aElement$attr;
  7981. const logStatus = scripts_echoLog({
  7982. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  7983. });
  7984. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  7985. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  7986. var _aElement$attr2, _aElement$attr2$match;
  7987. 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];
  7988. if (giveawayId) {
  7989. checkUser(giveawayId);
  7990. }
  7991. }
  7992. if (!aElement.attr('href')) {
  7993. logStatus.error('Error: No "href".');
  7994. continue;
  7995. }
  7996. const {
  7997. result,
  7998. statusText,
  7999. status,
  8000. data
  8001. } = await tools_httpRequest({
  8002. url: aElement.attr('href'),
  8003. method: 'GET'
  8004. });
  8005. if (result === 'Success') {
  8006. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8007. var _data$responseText$ma;
  8008. logStatus.success();
  8009. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8010. if (type === 'points' && points) {
  8011. this.myPoints = parseInt(points, 10);
  8012. }
  8013. } else {
  8014. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8015. }
  8016. } else {
  8017. logStatus.error(`${result}:${statusText}(${status})`);
  8018. }
  8019. }
  8020. }
  8021. scripts_echoLog({
  8022. text: '-----END-----'
  8023. });
  8024. } catch (error) {
  8025. throwError(error, 'OpiumPulses.toggleTask');
  8026. }
  8027. }
  8028. function OpiumPulses_checkLogin2() {
  8029. try {
  8030. if (!globalOptions.other.checkLogin) {
  8031. return true;
  8032. }
  8033. if ($('a[href*="/site/login"]').length > 1) {
  8034. window.open('/site/login', '_self');
  8035. }
  8036. return true;
  8037. } catch (error) {
  8038. throwError(error, 'OpiumPulses.checkLogin');
  8039. return false;
  8040. }
  8041. }
  8042. const website_OpiumPulses = OpiumPulses;
  8043. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8044. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8045. privateSet.add(obj);
  8046. }
  8047. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8048. if (privateCollection.has(obj)) {
  8049. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8050. }
  8051. }
  8052. function Keylol_defineProperty(obj, key, value) {
  8053. if (key in obj) {
  8054. Object.defineProperty(obj, key, {
  8055. value: value,
  8056. enumerable: true,
  8057. configurable: true,
  8058. writable: true
  8059. });
  8060. } else {
  8061. obj[key] = value;
  8062. }
  8063. return obj;
  8064. }
  8065. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8066. if (!privateSet.has(receiver)) {
  8067. throw new TypeError('attempted to get private field on non-instance');
  8068. }
  8069. return fn;
  8070. }
  8071. const Keylol_defaultTasks = {
  8072. steam: {
  8073. groupLinks: [],
  8074. wishlistLinks: [],
  8075. curatorLinks: [],
  8076. curatorLikeLinks: [],
  8077. followLinks: [],
  8078. forumLinks: [],
  8079. announcementLinks: [],
  8080. workshopVoteLinks: []
  8081. },
  8082. discord: {
  8083. serverLinks: []
  8084. },
  8085. instagram: {
  8086. userLinks: []
  8087. },
  8088. vk: {
  8089. nameLinks: []
  8090. },
  8091. twitch: {
  8092. channelLinks: []
  8093. },
  8094. reddit: {
  8095. redditLinks: []
  8096. },
  8097. twitter: {
  8098. userLinks: [],
  8099. retweetLinks: []
  8100. },
  8101. youtube: {
  8102. channelLinks: [],
  8103. likeLinks: []
  8104. }
  8105. };
  8106. var _addBtn = new WeakSet();
  8107. class Keylol extends website_Website {
  8108. constructor() {
  8109. super(...arguments);
  8110. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8111. Keylol_defineProperty(this, 'name', 'Keylol');
  8112. Keylol_defineProperty(this, 'socialTasks', {
  8113. ...Keylol_defaultTasks
  8114. });
  8115. Keylol_defineProperty(this, 'undoneTasks', {
  8116. ...Keylol_defaultTasks
  8117. });
  8118. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8119. }
  8120. static test() {
  8121. var _$$eq$attr;
  8122. 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'));
  8123. }
  8124. init() {
  8125. return true;
  8126. }
  8127. after() {
  8128. try {
  8129. const selecter = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8130. const mainPost = $(selecter);
  8131. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8132. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8133. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8134. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8135. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8136. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8137. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8138. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8139. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8140. if (discordLinks.length > 0) {
  8141. for (const discordLink of discordLinks) {
  8142. const link = $(discordLink).attr('href');
  8143. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8144. continue;
  8145. }
  8146. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8147. }
  8148. }
  8149. if (redditLinks.length > 0) {
  8150. for (const redditLink of redditLinks) {
  8151. const link = $(redditLink).attr('href');
  8152. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8153. continue;
  8154. }
  8155. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8156. }
  8157. }
  8158. if (insLinks.length > 0) {
  8159. for (const insLink of insLinks) {
  8160. const link = $(insLink).attr('href');
  8161. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8162. continue;
  8163. }
  8164. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8165. }
  8166. }
  8167. if (twitterLinks.length > 0) {
  8168. for (const twitterLink of twitterLinks) {
  8169. const link = $(twitterLink).attr('href');
  8170. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8171. continue;
  8172. }
  8173. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8174. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8175. } else {
  8176. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8177. }
  8178. }
  8179. }
  8180. if (twitchLinks.length > 0) {
  8181. for (const twitchLink of twitchLinks) {
  8182. const link = $(twitchLink).attr('href');
  8183. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8184. continue;
  8185. }
  8186. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8187. }
  8188. }
  8189. if (vkLinks.length > 0) {
  8190. for (const vkLink of vkLinks) {
  8191. const link = $(vkLink).attr('href');
  8192. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8193. continue;
  8194. }
  8195. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8196. }
  8197. }
  8198. if (steamStoreLinks.length > 0) {
  8199. for (const steamStoreLink of steamStoreLinks) {
  8200. const link = $(steamStoreLink).attr('href');
  8201. if (!link) {
  8202. continue;
  8203. }
  8204. if (/app\/[\d]+/.test(link)) {
  8205. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8206. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8207. } else if (/curator\/[\d]+/.test(link)) {
  8208. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8209. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8210. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8211. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8212. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8213. }
  8214. }
  8215. }
  8216. if (steamCommunityLinks.length > 0) {
  8217. for (const steamCommunityLink of steamCommunityLinks) {
  8218. const link = $(steamCommunityLink).attr('href');
  8219. if (!link) {
  8220. continue;
  8221. }
  8222. if (/groups\/.+/.test(link)) {
  8223. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8224. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8225. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8226. }
  8227. }
  8228. }
  8229. if (ytbLinks.length > 0) {
  8230. for (const ytbLink of ytbLinks) {
  8231. const link = $(ytbLink).attr('href');
  8232. if (!link) {
  8233. continue;
  8234. }
  8235. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8236. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8237. }
  8238. }
  8239. } catch (error) {
  8240. throwError(error, 'keylol.after');
  8241. }
  8242. }
  8243. classifyTask(action) {
  8244. try {
  8245. this.socialTasks = {
  8246. ...Keylol_defaultTasks
  8247. };
  8248. this.undoneTasks = {
  8249. ...Keylol_defaultTasks
  8250. };
  8251. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8252. for (const btn of selectedBtns) {
  8253. const button = $(btn);
  8254. const social = button.attr('data-social');
  8255. const type = button.attr('data-type');
  8256. const link = button.attr('data-link');
  8257. if (!(social && type && link)) {
  8258. continue;
  8259. }
  8260. if (action === 'do') {
  8261. this.undoneTasks[social][type].push(link);
  8262. }
  8263. if (action === 'undo') {
  8264. this.socialTasks[social][type].push(link);
  8265. }
  8266. }
  8267. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8268. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8269. return true;
  8270. } catch (error) {
  8271. throwError(error, 'Keylol.classifyTask');
  8272. return false;
  8273. }
  8274. }
  8275. selectAll() {
  8276. try {
  8277. $('.auto-task-keylol').attr('selected', 'selected');
  8278. } catch (error) {
  8279. throwError(error, 'Keylol.selectAll');
  8280. }
  8281. }
  8282. selectNone() {
  8283. try {
  8284. $('.auto-task-keylol').removeAttr('selected');
  8285. } catch (error) {
  8286. throwError(error, 'Keylol.selectNone');
  8287. }
  8288. }
  8289. invertSelect() {
  8290. try {
  8291. $('.auto-task-keylol').each((index, element) => {
  8292. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8293. });
  8294. } catch (error) {
  8295. throwError(error, 'Keylol.invertSelect');
  8296. }
  8297. }
  8298. }
  8299. function _addBtn2(before, social, linkType, link) {
  8300. try {
  8301. $(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>`);
  8302. } catch (error) {
  8303. throwError(error, 'keylol.addBtn');
  8304. }
  8305. }
  8306. const website_Keylol = Keylol;
  8307. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8308. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8309. privateSet.add(obj);
  8310. }
  8311. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8312. if (privateCollection.has(obj)) {
  8313. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8314. }
  8315. }
  8316. function Opquests_defineProperty(obj, key, value) {
  8317. if (key in obj) {
  8318. Object.defineProperty(obj, key, {
  8319. value: value,
  8320. enumerable: true,
  8321. configurable: true,
  8322. writable: true
  8323. });
  8324. } else {
  8325. obj[key] = value;
  8326. }
  8327. return obj;
  8328. }
  8329. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8330. if (!privateSet.has(receiver)) {
  8331. throw new TypeError('attempted to get private field on non-instance');
  8332. }
  8333. return fn;
  8334. }
  8335. const Opquests_defaultTasks = {
  8336. steam: {
  8337. groupLinks: [],
  8338. wishlistLinks: [],
  8339. followLinks: [],
  8340. curatorLikeLinks: []
  8341. }
  8342. };
  8343. var Opquests_getGiveawayId = new WeakSet();
  8344. var Opquests_checkLogin = new WeakSet();
  8345. class Opquests extends website_Website {
  8346. constructor() {
  8347. super(...arguments);
  8348. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8349. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8350. Opquests_defineProperty(this, 'name', 'Opquests');
  8351. Opquests_defineProperty(this, 'undoneTasks', {
  8352. ...Opquests_defaultTasks
  8353. });
  8354. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8355. }
  8356. static test() {
  8357. return window.location.host === 'opquests.com';
  8358. }
  8359. async after() {
  8360. try {
  8361. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8362. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8363. }
  8364. } catch (error) {
  8365. throwError(error, 'Opquests.after');
  8366. }
  8367. }
  8368. init() {
  8369. try {
  8370. const logStatus = scripts_echoLog({
  8371. text: i18n('initing')
  8372. });
  8373. if ($('a[href*="/auth/redirect"]').length > 0) {
  8374. window.open('/auth/redirect', '_self');
  8375. logStatus.warning(i18n('needLogin'));
  8376. return false;
  8377. }
  8378. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8379. return false;
  8380. }
  8381. this.initialized = true;
  8382. logStatus.success();
  8383. return true;
  8384. } catch (error) {
  8385. throwError(error, 'Opquests.init');
  8386. return false;
  8387. }
  8388. }
  8389. async classifyTask(action) {
  8390. try {
  8391. if (action === 'undo') {
  8392. scripts_echoLog({
  8393. text: i18n('cannotUndo')
  8394. });
  8395. return false;
  8396. }
  8397. const logStatus = scripts_echoLog({
  8398. text: i18n('getTasksInfo')
  8399. });
  8400. const tasks = $('.w-full:contains("Validate") .items-center');
  8401. for (const task of tasks) {
  8402. const link = $(task).find('a:contains("Open")').attr('href');
  8403. const taskDes = $(task).find('div').eq(1).text().trim();
  8404. if (!link) {
  8405. continue;
  8406. }
  8407. if (/steamcommunity\.com\/groups\//.test(link)) {
  8408. this.undoneTasks.steam.groupLinks.push(link);
  8409. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8410. if (/wishlist/gim.test(taskDes)) {
  8411. this.undoneTasks.steam.wishlistLinks.push(link);
  8412. } else if (/follow/gim.test(taskDes)) {
  8413. this.undoneTasks.steam.followLinks.push(link);
  8414. }
  8415. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8416. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8417. } else {
  8418. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8419. }
  8420. }
  8421. logStatus.success();
  8422. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8423. return true;
  8424. } catch (error) {
  8425. throwError(error, 'Opquests.classifyTask');
  8426. return false;
  8427. }
  8428. }
  8429. }
  8430. function Opquests_getGiveawayId2() {
  8431. try {
  8432. var _window$location$href;
  8433. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8434. if (giveawayId) {
  8435. this.giveawayId = giveawayId;
  8436. return true;
  8437. }
  8438. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8439. return false;
  8440. } catch (error) {
  8441. throwError(error, 'Opquests.getGiveawayId');
  8442. return false;
  8443. }
  8444. }
  8445. function Opquests_checkLogin2() {
  8446. try {
  8447. if (!globalOptions.other.checkLogin) {
  8448. return true;
  8449. }
  8450. if ($('a[href*="/auth/redirect"]').length > 0) {
  8451. window.open('/auth/redirect', '_self');
  8452. }
  8453. return true;
  8454. } catch (error) {
  8455. throwError(error, 'Opquests.checkLogin');
  8456. return false;
  8457. }
  8458. }
  8459. const website_Opquests = Opquests;
  8460. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8461. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8462. privateSet.add(obj);
  8463. }
  8464. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8465. if (privateCollection.has(obj)) {
  8466. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8467. }
  8468. }
  8469. function Gleam_defineProperty(obj, key, value) {
  8470. if (key in obj) {
  8471. Object.defineProperty(obj, key, {
  8472. value: value,
  8473. enumerable: true,
  8474. configurable: true,
  8475. writable: true
  8476. });
  8477. } else {
  8478. obj[key] = value;
  8479. }
  8480. return obj;
  8481. }
  8482. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8483. if (!privateSet.has(receiver)) {
  8484. throw new TypeError('attempted to get private field on non-instance');
  8485. }
  8486. return fn;
  8487. }
  8488. const Gleam_defaultTasks = {
  8489. steam: {
  8490. groupLinks: [],
  8491. wishlistLinks: [],
  8492. followLinks: [],
  8493. curatorLinks: [],
  8494. curatorLikeLinks: []
  8495. },
  8496. twitter: {
  8497. userLinks: [],
  8498. retweetLinks: []
  8499. },
  8500. twitch: {
  8501. channelLinks: []
  8502. },
  8503. discord: {
  8504. serverLinks: []
  8505. },
  8506. youtube: {
  8507. channelLinks: []
  8508. },
  8509. extra: {
  8510. gleam: []
  8511. }
  8512. };
  8513. const Gleam_defaultOptions = {
  8514. vlootUsername: '',
  8515. gameroundUsername: ''
  8516. };
  8517. var _checkSync = new WeakSet();
  8518. var _doGleamTask = new WeakSet();
  8519. var Gleam_getGiveawayId = new WeakSet();
  8520. var _getGleamLink = new WeakSet();
  8521. var Gleam_checkLeftKey = new WeakSet();
  8522. class Gleam extends website_Website {
  8523. constructor() {
  8524. super(...arguments);
  8525. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8526. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8527. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8528. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8529. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8530. Gleam_defineProperty(this, 'name', 'Gleam');
  8531. Gleam_defineProperty(this, 'undoneTasks', {
  8532. ...Gleam_defaultTasks
  8533. });
  8534. Gleam_defineProperty(this, 'socialTasks', {
  8535. ...Gleam_defaultTasks
  8536. });
  8537. Gleam_defineProperty(this, 'options', {
  8538. ...Gleam_defaultOptions,
  8539. ...GM_getValue('GleamOptions')
  8540. });
  8541. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8542. }
  8543. static test() {
  8544. return window.location.host === 'gleam.io';
  8545. }
  8546. async after() {
  8547. try {
  8548. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8549. const checkComplete = setInterval(() => {
  8550. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8551. clearInterval(checkComplete);
  8552. window.close();
  8553. }
  8554. });
  8555. for (const task of $('.entry-content .entry-method')) {
  8556. const taskInfo = $(task).find('.user-links');
  8557. const expandInfo = $(task).find('.expandable');
  8558. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8559. if (aElements.length > 0) {
  8560. for (const element of aElements) {
  8561. const $element = $(element);
  8562. const href = $element.attr('href');
  8563. $element.removeAttr('href')[0].click();
  8564. $element.attr('href', href);
  8565. await delay(1e3);
  8566. }
  8567. }
  8568. taskInfo[0].click();
  8569. await delay(1e3);
  8570. }
  8571. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8572. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8573. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8574. }
  8575. } catch (error) {
  8576. throwError(error, 'Gleam.after');
  8577. return false;
  8578. }
  8579. }
  8580. init() {
  8581. try {
  8582. const logStatus = scripts_echoLog({
  8583. text: i18n('initing')
  8584. });
  8585. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  8586. return false;
  8587. }
  8588. this.initialized = true;
  8589. logStatus.success();
  8590. return true;
  8591. } catch (error) {
  8592. throwError(error, 'Gleam.init');
  8593. return false;
  8594. }
  8595. }
  8596. async classifyTask(action) {
  8597. try {
  8598. const logStatus = scripts_echoLog({
  8599. text: i18n('getTasksInfo')
  8600. });
  8601. if (action === 'undo') {
  8602. var _GM_getValue;
  8603. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  8604. ...Gleam_defaultTasks
  8605. };
  8606. }
  8607. const tasks = $('.entry-content .entry-method');
  8608. for (const task of tasks) {
  8609. var _socialIcon$attr;
  8610. const $task = $(task);
  8611. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8612. continue;
  8613. }
  8614. const socialIcon = $task.find('.icon-wrapper i');
  8615. const taskInfo = $task.find('.user-links');
  8616. const taskText = taskInfo.text().trim();
  8617. const expandInfo = $task.find('.expandable');
  8618. const aElements = expandInfo.find('a.btn');
  8619. if (aElements.length > 0) {
  8620. for (const element of aElements) {
  8621. const $element = $(element);
  8622. const href = $element.attr('href');
  8623. $element.removeAttr('href')[0].click();
  8624. $element.attr('href', href);
  8625. }
  8626. }
  8627. if (socialIcon.hasClass('fa-twitter')) {
  8628. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8629. if (!link) {
  8630. continue;
  8631. }
  8632. if (/follow/gi.test(taskText)) {
  8633. if (action === 'undo') {
  8634. this.socialTasks.twitter.userLinks.push(link);
  8635. }
  8636. if (action === 'do') {
  8637. this.undoneTasks.twitter.userLinks.push(link);
  8638. }
  8639. } else if (/retweet/gim.test(taskText)) {
  8640. if (action === 'undo') {
  8641. this.socialTasks.twitter.retweetLinks.push(link);
  8642. }
  8643. if (action === 'do') {
  8644. this.undoneTasks.twitter.retweetLinks.push(link);
  8645. }
  8646. }
  8647. } else if (socialIcon.hasClass('fa-twitch')) {
  8648. if (/follow/gim.test(taskText)) {
  8649. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8650. if (!link) {
  8651. continue;
  8652. }
  8653. if (action === 'undo') {
  8654. this.socialTasks.twitch.channelLinks.push(link);
  8655. }
  8656. if (action === 'do') {
  8657. this.undoneTasks.twitch.channelLinks.push(link);
  8658. }
  8659. }
  8660. } else if (socialIcon.hasClass('fa-discord')) {
  8661. if (/join/gim.test(taskText)) {
  8662. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8663. if (!link) {
  8664. var _$task$find$attr, _$task$find$attr$matc;
  8665. 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];
  8666. if (!ggLink) {
  8667. continue;
  8668. }
  8669. link = `https://discord.com/invite/${ggLink}`;
  8670. }
  8671. if (action === 'undo') {
  8672. this.socialTasks.discord.serverLinks.push(link);
  8673. }
  8674. if (action === 'do') {
  8675. this.undoneTasks.discord.serverLinks.push(link);
  8676. }
  8677. }
  8678. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8679. continue;
  8680. } else if (socialIcon.hasClass('fa-youtube')) {
  8681. if (/subscribe/gim.test(taskText)) {
  8682. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8683. if (!link) {
  8684. continue;
  8685. }
  8686. if (action === 'undo') {
  8687. this.socialTasks.youtube.channelLinks.push(link);
  8688. }
  8689. if (action === 'do') {
  8690. this.undoneTasks.youtube.channelLinks.push(link);
  8691. }
  8692. }
  8693. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8694. if (/join.*group/gi.test(taskText)) {
  8695. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8696. if (!link) {
  8697. continue;
  8698. }
  8699. if (action === 'undo') {
  8700. this.socialTasks.steam.groupLinks.push(link);
  8701. }
  8702. if (action === 'do') {
  8703. this.undoneTasks.steam.groupLinks.push(link);
  8704. }
  8705. } else if (/follow.*curator/gi.test(taskText)) {
  8706. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8707. if (!link) {
  8708. continue;
  8709. }
  8710. if (action === 'undo') {
  8711. this.socialTasks.steam.curatorLinks.push(link);
  8712. }
  8713. if (action === 'do') {
  8714. this.undoneTasks.steam.curatorLinks.push(link);
  8715. }
  8716. }
  8717. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  8718. expandInfo.find('input').val(this.options.vlootUsername);
  8719. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8720. expandInfo.find('input').val(this.options.gameroundUsername);
  8721. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  8722. if (action !== 'do') {
  8723. continue;
  8724. }
  8725. const link = aElements.attr('href');
  8726. if (!link) {
  8727. continue;
  8728. }
  8729. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  8730. if (!gleamLink) {
  8731. continue;
  8732. }
  8733. this.undoneTasks.extra.gleam.push(gleamLink);
  8734. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  8735. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  8736. }
  8737. }
  8738. logStatus.success();
  8739. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8740. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8741. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8742. tasks: this.socialTasks,
  8743. time: new Date().getTime()
  8744. });
  8745. return true;
  8746. } catch (error) {
  8747. throwError(error, 'Gleam.classifyTask');
  8748. return false;
  8749. }
  8750. }
  8751. async extraDoTask(_ref) {
  8752. let {
  8753. gleam
  8754. } = _ref;
  8755. try {
  8756. const pro = [];
  8757. for (const link of gleam) {
  8758. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  8759. }
  8760. return Promise.all(pro).then(() => true);
  8761. } catch (error) {
  8762. throwError(error, 'Gleam.extraDoTask');
  8763. return false;
  8764. }
  8765. }
  8766. async verifyTask() {
  8767. try {
  8768. scripts_echoLog({
  8769. text: `${i18n('verifyingTask')}...`
  8770. });
  8771. const tasks = $('.entry-content .entry-method');
  8772. for (const task of tasks) {
  8773. const $task = $(task);
  8774. if ($task.find('i.fa-question').length === 0) {
  8775. continue;
  8776. }
  8777. const taskInfo = $task.find('.user-links');
  8778. taskInfo[0].click();
  8779. await delay(500);
  8780. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8781. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  8782. for (const button of continueBtn) {
  8783. button.click();
  8784. await delay(500);
  8785. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8786. }
  8787. }
  8788. scripts_echoLog({
  8789. text: i18n('verifiedGleamTasks')
  8790. });
  8791. } catch (error) {
  8792. throwError(error, 'Gleam.verifyTask');
  8793. return false;
  8794. }
  8795. }
  8796. }
  8797. async function _checkSync2() {
  8798. try {
  8799. return await new Promise(resolve => {
  8800. const checker = setInterval(() => {
  8801. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  8802. clearInterval(checker);
  8803. resolve(true);
  8804. }
  8805. }, 500);
  8806. });
  8807. } catch (error) {
  8808. throwError(error, 'Gleam.checkSync');
  8809. return false;
  8810. }
  8811. }
  8812. async function _doGleamTask2(link) {
  8813. try {
  8814. const logStatus = scripts_echoLog({
  8815. text: i18n('doingGleamTask')
  8816. });
  8817. return await new Promise(resolve => {
  8818. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  8819. active: true,
  8820. insert: true,
  8821. setParent: true
  8822. }).onclose = () => {
  8823. logStatus.success();
  8824. resolve(true);
  8825. };
  8826. });
  8827. } catch (error) {
  8828. throwError(error, 'Gleam.doGleamTask');
  8829. return false;
  8830. }
  8831. }
  8832. function Gleam_getGiveawayId2() {
  8833. try {
  8834. const giveawayId = window.location.pathname;
  8835. if (giveawayId) {
  8836. this.giveawayId = giveawayId;
  8837. return true;
  8838. }
  8839. scripts_echoLog({
  8840. text: i18n('getFailed', 'GiveawayId')
  8841. });
  8842. return false;
  8843. } catch (error) {
  8844. throwError(error, 'Gleam.getGiveawayId');
  8845. return false;
  8846. }
  8847. }
  8848. async function _getGleamLink2(link) {
  8849. try {
  8850. const logStatus = scripts_echoLog({
  8851. text: i18n('gettingGleamLink')
  8852. });
  8853. const {
  8854. result,
  8855. statusText,
  8856. status,
  8857. data
  8858. } = await tools_httpRequest({
  8859. url: link,
  8860. method: 'GET'
  8861. });
  8862. if (result === 'Success') {
  8863. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  8864. var _data$responseText$ma;
  8865. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8866. if (gleamLink) {
  8867. logStatus.success();
  8868. return gleamLink;
  8869. }
  8870. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  8871. return false;
  8872. }
  8873. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8874. return false;
  8875. }
  8876. logStatus.error(`${result}:${statusText}(${status})`);
  8877. return false;
  8878. } catch (error) {
  8879. throwError(error, 'Gleam.getGleamLink');
  8880. return false;
  8881. }
  8882. }
  8883. async function Gleam_checkLeftKey2() {
  8884. try {
  8885. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  8886. if (!globalOptions.other.checkLeftKey) {
  8887. return true;
  8888. }
  8889. 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];
  8890. if (!campaignString) {
  8891. return false;
  8892. }
  8893. const {
  8894. campaign,
  8895. incentive
  8896. } = JSON.parse(campaignString);
  8897. 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];
  8898. let ownedKey = false;
  8899. if (controllerString) {
  8900. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  8901. 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) {
  8902. ownedKey = true;
  8903. }
  8904. }
  8905. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  8906. await external_Swal_default().fire({
  8907. icon: 'warning',
  8908. title: i18n('notice'),
  8909. text: i18n('giveawayNotWork'),
  8910. confirmButtonText: i18n('confirm'),
  8911. cancelButtonText: i18n('cancel'),
  8912. showCancelButton: true
  8913. }).then(_ref2 => {
  8914. let {
  8915. value
  8916. } = _ref2;
  8917. if (value) {
  8918. window.close();
  8919. }
  8920. });
  8921. }
  8922. return true;
  8923. } catch (error) {
  8924. throwError(error, 'Gleam.checkLeftKey');
  8925. return false;
  8926. }
  8927. }
  8928. const website_Gleam = Gleam;
  8929. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  8930. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  8931. privateSet.add(obj);
  8932. }
  8933. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  8934. if (privateCollection.has(obj)) {
  8935. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8936. }
  8937. }
  8938. function SweepWidget_defineProperty(obj, key, value) {
  8939. if (key in obj) {
  8940. Object.defineProperty(obj, key, {
  8941. value: value,
  8942. enumerable: true,
  8943. configurable: true,
  8944. writable: true
  8945. });
  8946. } else {
  8947. obj[key] = value;
  8948. }
  8949. return obj;
  8950. }
  8951. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  8952. if (!privateSet.has(receiver)) {
  8953. throw new TypeError('attempted to get private field on non-instance');
  8954. }
  8955. return fn;
  8956. }
  8957. const SweepWidget_defaultOptions = {
  8958. username: '',
  8959. email: ''
  8960. };
  8961. var SweepWidget_checkLogin = new WeakSet();
  8962. var SweepWidget_getGiveawayId = new WeakSet();
  8963. var _checkEnter = new WeakSet();
  8964. var _checkFinish = new WeakSet();
  8965. class SweepWidget extends website_Website {
  8966. constructor() {
  8967. super(...arguments);
  8968. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  8969. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  8970. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  8971. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  8972. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  8973. SweepWidget_defineProperty(this, 'options', {
  8974. ...SweepWidget_defaultOptions,
  8975. ...GM_getValue('SweepWidgetOptions')
  8976. });
  8977. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  8978. }
  8979. static test() {
  8980. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  8981. }
  8982. async after() {
  8983. try {
  8984. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  8985. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8986. }
  8987. } catch (error) {
  8988. throwError(error, 'SweepWidget.after');
  8989. }
  8990. }
  8991. init() {
  8992. try {
  8993. const logStatus = scripts_echoLog({
  8994. text: i18n('initing')
  8995. });
  8996. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  8997. logStatus.warning(i18n('needLogin'));
  8998. return false;
  8999. }
  9000. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9001. return false;
  9002. }
  9003. this.initialized = true;
  9004. logStatus.success();
  9005. return true;
  9006. } catch (error) {
  9007. throwError(error, 'SweepWidget.init');
  9008. return false;
  9009. }
  9010. }
  9011. classifyTask() {
  9012. return true;
  9013. }
  9014. async doTask() {
  9015. try {
  9016. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9017. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9018. $('input[name="sw__login_name"]').val(this.options.username);
  9019. }
  9020. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9021. $('input[name="sw__login_email"]').val(this.options.email);
  9022. }
  9023. if ($('#sw_login_button:visible').length > 0) {
  9024. $('#sw_login_button')[0].click();
  9025. }
  9026. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9027. return false;
  9028. }
  9029. }
  9030. const logStatus = scripts_echoLog({
  9031. text: i18n('SweepWidgetNotice')
  9032. });
  9033. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9034. for (const task of tasks) {
  9035. var _aElement$, _$task$find$removeAtt;
  9036. const $task = $(task);
  9037. if ($task.find('i.fa-check:visible').length > 0) {
  9038. continue;
  9039. }
  9040. const title = $task.find('.sw_text_inner');
  9041. title[0].click();
  9042. const aElement = $task.find('a.sw_link');
  9043. const link = aElement.attr('href');
  9044. aElement.attr('href', '#a').attr('target', '_self');
  9045. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9046. await delay(300);
  9047. aElement.attr('href', link).attr('target', '_blank');
  9048. $task.find('input[type="text"]').val('test');
  9049. const verifyBtn = $task.find('input.sw_verify');
  9050. if (verifyBtn.prop('disabled') === true) {
  9051. title[0].click();
  9052. await delay(300);
  9053. title[0].click();
  9054. await delay(300);
  9055. }
  9056. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9057. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9058. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9059. }
  9060. logStatus.success();
  9061. return true;
  9062. } catch (error) {
  9063. throwError(error, 'SweepWidget.doTask');
  9064. return false;
  9065. }
  9066. }
  9067. }
  9068. function SweepWidget_checkLogin2() {
  9069. try {
  9070. if ($('#twitter_login_button').length > 0) {
  9071. $('#twitter_login_button')[0].click();
  9072. }
  9073. return true;
  9074. } catch (error) {
  9075. throwError(error, 'SweepWidget.checkLogin');
  9076. return false;
  9077. }
  9078. }
  9079. function SweepWidget_getGiveawayId2() {
  9080. try {
  9081. var _window$location$href;
  9082. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9083. if (giveawayId) {
  9084. this.giveawayId = giveawayId;
  9085. return true;
  9086. }
  9087. scripts_echoLog({
  9088. text: i18n('getFailed', 'GiveawayId')
  9089. });
  9090. return false;
  9091. } catch (error) {
  9092. throwError(error, 'SweepWidget.getGiveawayId');
  9093. return false;
  9094. }
  9095. }
  9096. async function _checkEnter2() {
  9097. try {
  9098. return new Promise(resolve => {
  9099. const checker = setInterval(() => {
  9100. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9101. clearInterval(checker);
  9102. resolve(true);
  9103. }
  9104. });
  9105. });
  9106. } catch (error) {
  9107. throwError(error, 'SweepWidget.checkEnter');
  9108. return false;
  9109. }
  9110. }
  9111. async function _checkFinish2($task) {
  9112. try {
  9113. return new Promise(resolve => {
  9114. const checker = setInterval(() => {
  9115. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9116. clearInterval(checker);
  9117. resolve(true);
  9118. }
  9119. });
  9120. });
  9121. } catch (error) {
  9122. throwError(error, 'SweepWidget.checkFinish');
  9123. return false;
  9124. }
  9125. }
  9126. const website_SweepWidget = SweepWidget;
  9127. const defaultWhiteList = {
  9128. discord: {
  9129. servers: []
  9130. },
  9131. instagram: {
  9132. users: []
  9133. },
  9134. twitch: {
  9135. channels: []
  9136. },
  9137. twitter: {
  9138. users: [],
  9139. retweets: [],
  9140. likes: []
  9141. },
  9142. vk: {
  9143. names: []
  9144. },
  9145. youtube: {
  9146. channels: [],
  9147. likes: []
  9148. },
  9149. reddit: {
  9150. reddits: []
  9151. },
  9152. steam: {
  9153. groups: [],
  9154. wishlists: [],
  9155. follows: [],
  9156. forums: [],
  9157. workshops: [],
  9158. curators: [],
  9159. workshopVotes: [],
  9160. curatorLikes: [],
  9161. announcements: []
  9162. }
  9163. };
  9164. const link2id = async function(type) {
  9165. 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;
  9166. try {
  9167. const link = $('#socialLink').val();
  9168. let id = '';
  9169. switch (type) {
  9170. case 'discord.servers':
  9171. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9172. break;
  9173.  
  9174. case 'instagram.users':
  9175. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9176. break;
  9177.  
  9178. case 'twitch.channels':
  9179. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9180. break;
  9181.  
  9182. case 'twitter.users':
  9183. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9184. break;
  9185.  
  9186. case 'twitter.retweets':
  9187. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9188. break;
  9189.  
  9190. case 'vk.names':
  9191. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9192. break;
  9193.  
  9194. case 'youtube.channels':
  9195. 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) || '';
  9196. break;
  9197.  
  9198. case 'youtube.likes':
  9199. 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) || '';
  9200. break;
  9201.  
  9202. case 'reddit.reddits':
  9203. 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]) || '';
  9204. break;
  9205.  
  9206. case 'steam.groups':
  9207. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9208. break;
  9209.  
  9210. case 'steam.wishlists':
  9211. case 'steam.follows':
  9212. case 'steam.forums':
  9213. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9214. break;
  9215.  
  9216. case 'steam.workshops':
  9217. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9218. break;
  9219.  
  9220. case 'steam.curators':
  9221. {
  9222. if (link.includes('curator')) {
  9223. var _link$match12;
  9224. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9225. } else {
  9226. var _link$match13;
  9227. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9228. if (!param || param.length !== 2) {
  9229. break;
  9230. }
  9231. const steam = new social_Steam();
  9232. if (await steam.init()) {
  9233. id = await steam.getCuratorId(param[0], param[1]) || '';
  9234. }
  9235. }
  9236. }
  9237. break;
  9238. }
  9239. return id;
  9240. } catch (error) {
  9241. throwError(error, 'link2id');
  9242. return i18n('getFailed', 'id');
  9243. }
  9244. };
  9245. const disabledType = {
  9246. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9247. twitter: [ 'likes' ]
  9248. };
  9249. const whiteListOptions = function(showType) {
  9250. try {
  9251. const whiteList = {
  9252. ...defaultWhiteList,
  9253. ...GM_getValue('whiteList') || {}
  9254. };
  9255. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9256. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9257. for (const [ social, types ] of Object.entries(whiteList)) {
  9258. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9259. var _disabledType$social;
  9260. 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>`;
  9261. }).join('');
  9262. }
  9263. whiteListOptionsForm += '</tbody></table></form>';
  9264. if (showType === 'swal') {
  9265. external_Swal_default().fire({
  9266. title: i18n('whiteListOptions'),
  9267. html: whiteListOptionsForm,
  9268. showConfirmButton: false,
  9269. showCloseButton: true
  9270. });
  9271. } else {
  9272. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9273. }
  9274. $('.editWhiteList').on('click', function() {
  9275. var _whiteList$social;
  9276. const value = $(this).attr('data-value');
  9277. if (!value) {
  9278. return;
  9279. }
  9280. const [ social, type ] = value.split('.');
  9281. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9282. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9283. return;
  9284. }
  9285. external_Swal_default().fire({
  9286. title: i18n('changeWhiteListOption', value),
  9287. input: 'textarea',
  9288. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9289. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9290. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9291. inputValue: whiteList[social][type].join('\n'),
  9292. showConfirmButton: true,
  9293. confirmButtonText: i18n('save'),
  9294. showCancelButton: true,
  9295. cancelButtonText: i18n('close'),
  9296. showDenyButton: true,
  9297. denyButtonText: i18n('return')
  9298. }).then(_ref => {
  9299. let {
  9300. isDenied,
  9301. isConfirmed,
  9302. value
  9303. } = _ref;
  9304. if (isDenied) {
  9305. if (showType === 'swal') {
  9306. whiteListOptions(showType);
  9307. }
  9308. return;
  9309. } else if (isConfirmed) {
  9310. whiteList[social][type] = value.split('\n');
  9311. GM_setValue('whiteList', whiteList);
  9312. external_Swal_default().fire({
  9313. title: i18n('changeWhiteListSuccess'),
  9314. icon: 'success'
  9315. });
  9316. }
  9317. });
  9318. $('#link2id').on('click', async function() {
  9319. const type = $(this).attr('data-type');
  9320. $('#socialLink').val(await link2id(type));
  9321. });
  9322. });
  9323. } catch (error) {
  9324. throwError(error, 'whiteListOptions');
  9325. }
  9326. };
  9327. const whiteList = whiteListOptions;
  9328. const setGistData = async (token, gistId, fileName, content) => {
  9329. try {
  9330. const logStatus = scripts_echoLog({
  9331. text: i18n('settingData')
  9332. });
  9333. const contentData = JSON.stringify({
  9334. files: {
  9335. [fileName]: {
  9336. content: JSON.stringify(content)
  9337. }
  9338. }
  9339. });
  9340. const {
  9341. result,
  9342. statusText,
  9343. status,
  9344. data
  9345. } = await tools_httpRequest({
  9346. url: `https://api.github.com/gists/${gistId}`,
  9347. headers: {
  9348. Accept: 'application/vnd.github.v3+json',
  9349. Authorization: `token ${token}`
  9350. },
  9351. data: contentData,
  9352. responseType: 'json',
  9353. method: 'POST',
  9354. timeout: 3e4
  9355. });
  9356. if (result === 'Success') {
  9357. var _data$response$files, _data$response$files$;
  9358. 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)) {
  9359. logStatus.success();
  9360. return true;
  9361. }
  9362. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9363. return false;
  9364. }
  9365. logStatus.error(`${result}:${statusText}(${status})`);
  9366. return false;
  9367. } catch (error) {
  9368. throwError(error, 'setGistData');
  9369. return false;
  9370. }
  9371. };
  9372. const getGistData = async (token, gistId, fileName) => {
  9373. try {
  9374. const logStatus = scripts_echoLog({
  9375. text: i18n('gettingData')
  9376. });
  9377. const {
  9378. result,
  9379. statusText,
  9380. status,
  9381. data
  9382. } = await tools_httpRequest({
  9383. url: `https://api.github.com/gists/${gistId}`,
  9384. headers: {
  9385. Accept: 'application/vnd.github.v3+json',
  9386. Authorization: `token ${token}`
  9387. },
  9388. responseType: 'json',
  9389. method: 'GET',
  9390. timeout: 3e4
  9391. });
  9392. if (result === 'Success') {
  9393. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9394. var _data$response, _data$response$files2, _data$response$files3;
  9395. logStatus.success();
  9396. 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);
  9397. }
  9398. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9399. return false;
  9400. }
  9401. logStatus.error(`${result}:${statusText}(${status})`);
  9402. return false;
  9403. } catch (error) {
  9404. throwError(error, 'getGistData');
  9405. return false;
  9406. }
  9407. };
  9408. const syncOptions = () => {
  9409. try {
  9410. const {
  9411. TOKEN,
  9412. GIST_ID,
  9413. FILE_NAME,
  9414. SYNC_HISTORY
  9415. } = GM_getValue('gistOptions') || {
  9416. TOKEN: '',
  9417. GIST_ID: '',
  9418. FILE_NAME: '',
  9419. SYNC_HISTORY: true
  9420. };
  9421. external_Swal_default().fire({
  9422. title: i18n('gistOptions'),
  9423. 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;">
  9424. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9425. ${i18n('downloadFromGist')}</button></p>`,
  9426. focusConfirm: false,
  9427. showLoaderOnConfirm: true,
  9428. 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>`,
  9429. preConfirm: async () => {
  9430. const token = $('#github-token').val();
  9431. const gistId = $('#gist-id').val();
  9432. const fileName = $('#file-name').val();
  9433. const syncHistory = $('#sync-history').prop('checked');
  9434. GM_setValue('gistOptions', {
  9435. TOKEN: token,
  9436. GIST_ID: gistId,
  9437. FILE_NAME: fileName,
  9438. SYNC_HISTORY: syncHistory
  9439. });
  9440. return await getGistData(token, gistId, fileName);
  9441. },
  9442. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9443. confirmButtonText: i18n('saveAndTest'),
  9444. showCancelButton: true,
  9445. cancelButtonText: i18n('close')
  9446. }).then(_ref => {
  9447. let {
  9448. value
  9449. } = _ref;
  9450. if (value) {
  9451. external_Swal_default().fire({
  9452. icon: 'success',
  9453. title: i18n('testSuccess')
  9454. }).then(syncOptions);
  9455. } else if (value !== undefined) {
  9456. external_Swal_default().fire({
  9457. icon: 'error',
  9458. title: i18n('testFailed')
  9459. }).then(syncOptions);
  9460. }
  9461. });
  9462. $('#upload-data').on('click', async () => {
  9463. const {
  9464. TOKEN,
  9465. GIST_ID,
  9466. FILE_NAME
  9467. } = GM_getValue('gistOptions') || {};
  9468. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9469. return external_Swal_default().fire({
  9470. icon: 'error',
  9471. title: i18n('saveAndTestNotice')
  9472. }).then(syncOptions);
  9473. }
  9474. external_Swal_default().fire({
  9475. icon: 'info',
  9476. title: i18n('processingData')
  9477. });
  9478. const data = {};
  9479. const names = GM_listValues();
  9480. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9481. for (const name of names) {
  9482. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9483. continue;
  9484. }
  9485. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9486. continue;
  9487. }
  9488. data[name] = GM_getValue(name);
  9489. }
  9490. external_Swal_default().update({
  9491. icon: 'info',
  9492. title: i18n('updatingData')
  9493. });
  9494. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9495. external_Swal_default().fire({
  9496. icon: 'success',
  9497. title: i18n('syncDataSuccess')
  9498. });
  9499. } else {
  9500. external_Swal_default().fire({
  9501. icon: 'error',
  9502. title: i18n('syncDataFailed')
  9503. });
  9504. }
  9505. });
  9506. $('#download-data').on('click', async () => {
  9507. const {
  9508. TOKEN,
  9509. GIST_ID,
  9510. FILE_NAME
  9511. } = GM_getValue('gistOptions') || {};
  9512. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9513. return external_Swal_default().fire({
  9514. icon: 'error',
  9515. title: i18n('saveAndTestNotice')
  9516. }).then(syncOptions);
  9517. }
  9518. external_Swal_default().fire({
  9519. icon: 'info',
  9520. title: i18n('downloadingData')
  9521. });
  9522. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9523. if (!data) {
  9524. return external_Swal_default().fire({
  9525. icon: 'error',
  9526. title: i18n('checkedNoData')
  9527. }).then(syncOptions);
  9528. }
  9529. external_Swal_default().update({
  9530. icon: 'info',
  9531. title: i18n('savingData')
  9532. });
  9533. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9534. for (const [ name, value ] of Object.entries(data)) {
  9535. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9536. continue;
  9537. }
  9538. GM_setValue(name, value);
  9539. }
  9540. external_Swal_default().fire({
  9541. icon: 'success',
  9542. title: i18n('syncDataSuccess')
  9543. });
  9544. });
  9545. } catch (error) {
  9546. throwError(error, 'syncOptions');
  9547. }
  9548. };
  9549. const dataSync = syncOptions;
  9550. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9551. Setting_checkPrivateRedeclaration(obj, privateSet);
  9552. privateSet.add(obj);
  9553. }
  9554. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9555. if (privateCollection.has(obj)) {
  9556. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9557. }
  9558. }
  9559. function Setting_defineProperty(obj, key, value) {
  9560. if (key in obj) {
  9561. Object.defineProperty(obj, key, {
  9562. value: value,
  9563. enumerable: true,
  9564. configurable: true,
  9565. writable: true
  9566. });
  9567. } else {
  9568. obj[key] = value;
  9569. }
  9570. return obj;
  9571. }
  9572. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9573. if (!privateSet.has(receiver)) {
  9574. throw new TypeError('attempted to get private field on non-instance');
  9575. }
  9576. return fn;
  9577. }
  9578. var Setting_getId = new WeakSet();
  9579. var _environment = new WeakSet();
  9580. class Setting {
  9581. constructor() {
  9582. Setting_classPrivateMethodInitSpec(this, _environment);
  9583. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  9584. Setting_defineProperty(this, 'name', 'Setting');
  9585. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  9586. Setting_defineProperty(this, 'dataSync', dataSync);
  9587. }
  9588. tasksHistory() {
  9589. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9590. }
  9591. static test() {
  9592. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9593. }
  9594. before() {
  9595. $('body').html('').addClass('auto-task-options');
  9596. }
  9597. after() {
  9598. try {
  9599. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  9600. changeGlobalOptions('page');
  9601. whiteList('page');
  9602. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9603. $('#getTwitterUserId').on('click', () => {
  9604. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  9605. });
  9606. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9607. $('#getYoutubeChannelId').on('click', () => {
  9608. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  9609. });
  9610. $('input[name^="position"]').on('input', function() {
  9611. const type = $(this).attr('name').replace('position.', '');
  9612. const xLabel = 'rightleft';
  9613. const yLabel = 'topbottpm';
  9614. switch (type) {
  9615. case 'buttonSideX':
  9616. case 'buttonSideY':
  9617. case 'buttonDistance':
  9618. {
  9619. const distance = $('input[name="position.buttonDistance"]').val();
  9620. const sideX = $('input[name="position.buttonSideX"]').val();
  9621. const sideY = $('input[name="position.buttonSideY"]').val();
  9622. if (![ 'right', 'left' ].includes(sideX)) {
  9623. break;
  9624. }
  9625. if (![ 'top', 'bottom' ].includes(sideY)) {
  9626. break;
  9627. }
  9628. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9629. break;
  9630. }
  9631. const distanceArr = distance.split(',');
  9632. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9633. break;
  9634. }
  9635.  
  9636. case 'showButtonSideX':
  9637. case 'showButtonSideY':
  9638. case 'showButtonDistance':
  9639. {
  9640. const distance = $('input[name="position.showButtonDistance"]').val();
  9641. const sideX = $('input[name="position.showButtonSideX"]').val();
  9642. const sideY = $('input[name="position.showButtonSideY"]').val();
  9643. if (![ 'right', 'left' ].includes(sideX)) {
  9644. break;
  9645. }
  9646. if (![ 'top', 'bottom' ].includes(sideY)) {
  9647. break;
  9648. }
  9649. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9650. break;
  9651. }
  9652. const distanceArr = distance.split(',');
  9653. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9654. break;
  9655. }
  9656.  
  9657. case 'logSideX':
  9658. case 'logSideY':
  9659. case 'logDistance':
  9660. {
  9661. const distance = $('input[name="position.logDistance"]').val();
  9662. const sideX = $('input[name="position.logSideX"]').val();
  9663. const sideY = $('input[name="position.logSideY"]').val();
  9664. if (![ 'right', 'left' ].includes(sideX)) {
  9665. break;
  9666. }
  9667. if (![ 'top', 'bottom' ].includes(sideY)) {
  9668. break;
  9669. }
  9670. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9671. break;
  9672. }
  9673. const distanceArr = distance.split(',');
  9674. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9675. break;
  9676. }
  9677.  
  9678. default:
  9679. break;
  9680. }
  9681. });
  9682. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9683. let functionKey = '';
  9684. if (event.altKey) {
  9685. functionKey += 'alt + ';
  9686. } else if (event.ctrlKey) {
  9687. functionKey += 'ctrl + ';
  9688. } else if (event.shiftKey) {
  9689. functionKey += 'shift + ';
  9690. }
  9691. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9692. });
  9693. } catch (error) {
  9694. throwError(error, 'Setting.after');
  9695. }
  9696. }
  9697. saveGlobalOptions() {
  9698. saveData();
  9699. }
  9700. }
  9701. function Setting_getId2(social) {
  9702. try {
  9703. external_Swal_default().fire({
  9704. title: i18n('getId', i18n(social)),
  9705. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9706. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9707. showCancelButton: true,
  9708. cancelButtonText: i18n('close'),
  9709. showConfirmButton: false
  9710. });
  9711. $('#link2id').on('click', async function() {
  9712. const link = $('#socialLink').val();
  9713. if (!link) {
  9714. return;
  9715. }
  9716. const type = $(this).attr('data-type');
  9717. if (type === 'twitterUser') {
  9718. var _link$match;
  9719. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9720. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9721. } else if (type === 'youtubeChannel') {
  9722. var _link$match2, _await$getInfo, _await$getInfo$params;
  9723. 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;
  9724. $('#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) || '');
  9725. }
  9726. });
  9727. } catch (error) {
  9728. throwError(error, 'Setting.getId');
  9729. }
  9730. }
  9731. function _environment2() {
  9732. try {
  9733. const userAgent = (0, javascript_utils_umd_min.ua)();
  9734. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9735. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9736. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9737. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9738. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9739. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9740. </tbody></table></form>`;
  9741. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9742. } catch (error) {
  9743. throwError(error, 'Setting.environment');
  9744. }
  9745. }
  9746. const website_Setting = Setting;
  9747. const external_dayjs_namespaceObject = dayjs;
  9748. function History_classPrivateMethodInitSpec(obj, privateSet) {
  9749. History_checkPrivateRedeclaration(obj, privateSet);
  9750. privateSet.add(obj);
  9751. }
  9752. function History_checkPrivateRedeclaration(obj, privateCollection) {
  9753. if (privateCollection.has(obj)) {
  9754. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9755. }
  9756. }
  9757. function History_defineProperty(obj, key, value) {
  9758. if (key in obj) {
  9759. Object.defineProperty(obj, key, {
  9760. value: value,
  9761. enumerable: true,
  9762. configurable: true,
  9763. writable: true
  9764. });
  9765. } else {
  9766. obj[key] = value;
  9767. }
  9768. return obj;
  9769. }
  9770. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  9771. if (!privateSet.has(receiver)) {
  9772. throw new TypeError('attempted to get private field on non-instance');
  9773. }
  9774. return fn;
  9775. }
  9776. var _addItem = new WeakSet();
  9777. class History extends website_Keylol {
  9778. constructor() {
  9779. super(...arguments);
  9780. History_classPrivateMethodInitSpec(this, _addItem);
  9781. History_defineProperty(this, 'name', 'History');
  9782. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  9783. }
  9784. static test() {
  9785. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9786. }
  9787. before() {
  9788. try {
  9789. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  9790. const data = GM_listValues() || [];
  9791. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9792. for (const item of tasksHistory) {
  9793. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  9794. }
  9795. } catch (error) {
  9796. throwError(error, 'History.before');
  9797. }
  9798. }
  9799. clearHistory() {
  9800. try {
  9801. const data = GM_listValues() || [];
  9802. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9803. for (const item of tasksHistory) {
  9804. GM_deleteValue(item);
  9805. }
  9806. external_Swal_default().fire({
  9807. title: i18n('clearHistoryFinished'),
  9808. icon: 'success'
  9809. });
  9810. } catch (error) {
  9811. throwError(error, 'History.after');
  9812. }
  9813. }
  9814. }
  9815. function _addItem2(item) {
  9816. try {
  9817. const tasksData = GM_getValue(item);
  9818. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9819. return;
  9820. }
  9821. let html = '';
  9822. let title = '';
  9823. let link = '';
  9824. const [ website, id ] = item.split('-');
  9825. switch (website) {
  9826. case 'fawTasks':
  9827. title = `Freeanywhere[${id}]`;
  9828. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9829. break;
  9830.  
  9831. case 'gasTasks':
  9832. title = `Giveawaysu[${id}]`;
  9833. link = `https://giveaway.su/giveaway/view/${id}`;
  9834. break;
  9835.  
  9836. case 'gcTasks':
  9837. title = `GiveeClub[${id}]`;
  9838. link = `https://givee.club/event/${id}`;
  9839. break;
  9840.  
  9841. case 'gkTasks':
  9842. title = `Givekey[${id}]`;
  9843. link = `https://givekey.ru/giveaway/${id}`;
  9844. break;
  9845.  
  9846. case 'gleamTasks':
  9847. title = `Gleam[${id}]`;
  9848. link = `https://gleam.io${id}`;
  9849. break;
  9850.  
  9851. case 'khTasks':
  9852. title = `keyhub[${id}]`;
  9853. link = `https://key-hub.eu/giveaway/${id}`;
  9854. break;
  9855.  
  9856. case 'prysTasks':
  9857. title = `Prys[${id}]`;
  9858. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  9859. break;
  9860.  
  9861. default:
  9862. return;
  9863. }
  9864. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  9865. for (const [ type, tasks ] of Object.entries(types)) {
  9866. for (const task of tasks) {
  9867. 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>`;
  9868. }
  9869. }
  9870. }
  9871. $('.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>`);
  9872. $('span.delete-task').on('click', function() {
  9873. const itemName = $(this).attr('data-name');
  9874. if (itemName) {
  9875. GM_deleteValue(itemName);
  9876. external_Swal_default().fire({
  9877. title: i18n('clearTaskFinished'),
  9878. text: itemName,
  9879. icon: 'success'
  9880. });
  9881. } else {
  9882. external_Swal_default().fire({
  9883. title: i18n('clearTaskFailed'),
  9884. icon: 'error'
  9885. });
  9886. }
  9887. });
  9888. } catch (error) {
  9889. throwError(error, 'History.addItem');
  9890. }
  9891. }
  9892. const website_History = History;
  9893. 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 ];
  9894. const websiteOptions = function(website, options) {
  9895. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  9896. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  9897. for (const [ option, value ] of Object.entries(options)) {
  9898. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  9899. }
  9900. websiteOptionsForm += '</tbody></table></form>';
  9901. external_Swal_default().fire({
  9902. title: i18n('websiteOptions'),
  9903. html: websiteOptionsForm,
  9904. showConfirmButton: true,
  9905. confirmButtonText: i18n('save'),
  9906. showCancelButton: true,
  9907. cancelButtonText: i18n('close')
  9908. }).then(_ref => {
  9909. let {
  9910. isConfirmed
  9911. } = _ref;
  9912. if (isConfirmed) {
  9913. $('#websiteOptionsForm').serializeArray().map(value => {
  9914. options[value.name] = value.value;
  9915. return value;
  9916. });
  9917. GM_setValue(`${website}Options`, options);
  9918. external_Swal_default().fire({
  9919. title: i18n('changeWebsiteOptionsSuccess'),
  9920. icon: 'success'
  9921. });
  9922. }
  9923. });
  9924. };
  9925. const options = websiteOptions;
  9926. const external_keyboardJS_namespaceObject = keyboardJS;
  9927. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  9928. const checkUpdate = async (updateLink, auto) => {
  9929. try {
  9930. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  9931. const {
  9932. result,
  9933. statusText,
  9934. status,
  9935. data
  9936. } = await tools_httpRequest({
  9937. url: checkUrl,
  9938. responseType: 'json',
  9939. method: 'GET',
  9940. timeout: 3e4
  9941. });
  9942. if (result === 'Success') {
  9943. var _data$response;
  9944. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  9945. return data.response;
  9946. }
  9947. if (!auto) {
  9948. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  9949. }
  9950. return false;
  9951. }
  9952. if (!auto) {
  9953. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  9954. }
  9955. return false;
  9956. } catch (error) {
  9957. throwError(error, 'checkUpdate');
  9958. return false;
  9959. }
  9960. };
  9961. const hasNewVersion = (currentVersion, remoteVersion) => {
  9962. try {
  9963. const [ currentRealVersion ] = currentVersion.split('-');
  9964. const [ remoteRealVersion ] = remoteVersion.split('-');
  9965. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  9966. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  9967. if (remoteVersion1 > currentVersion1) {
  9968. return true;
  9969. }
  9970. if (remoteVersion1 < currentVersion1) {
  9971. return false;
  9972. }
  9973. if (remoteVersion2 > currentVersion2) {
  9974. return true;
  9975. }
  9976. if (remoteVersion2 < currentVersion2) {
  9977. return false;
  9978. }
  9979. if (remoteVersion3 > currentVersion3) {
  9980. return true;
  9981. }
  9982. return false;
  9983. } catch (error) {
  9984. throwError(error, 'compareVersion');
  9985. return false;
  9986. }
  9987. };
  9988. const updateChecker = async () => {
  9989. try {
  9990. const currentVersion = GM_info.script.version;
  9991. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  9992. const updateLinks = {
  9993. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  9994. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  9995. standby: 'https://auto-task-v4.hclonely.com/'
  9996. };
  9997. let version;
  9998. let updateLink = '';
  9999. let packageData;
  10000. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10001. updateLink = updateLinks[updateSource];
  10002. packageData = await checkUpdate(updateLink, false);
  10003. } else {
  10004. updateLink = updateLinks.github;
  10005. packageData = await checkUpdate(updateLink, true);
  10006. if (!packageData) {
  10007. updateLink = updateLinks.jsdelivr;
  10008. packageData = await checkUpdate(updateLink, true);
  10009. if (!packageData) {
  10010. updateLink = updateLinks.standby;
  10011. packageData = await checkUpdate(updateLink, true);
  10012. }
  10013. }
  10014. }
  10015. if (packageData) {
  10016. version = packageData.version || currentVersion;
  10017. } else {
  10018. version = currentVersion;
  10019. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10020. }
  10021. if (packageData && hasNewVersion(currentVersion, version)) {
  10022. var _packageData$change;
  10023. scripts_echoLog({
  10024. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10025. });
  10026. scripts_echoLog({
  10027. 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>`
  10028. });
  10029. }
  10030. } catch (error) {
  10031. throwError(error, 'updateChecker');
  10032. }
  10033. };
  10034. const scripts_updateChecker = updateChecker;
  10035. if (window.location.hostname === 'discord.com') {
  10036. var _window$localStorage, _window$localStorage$;
  10037. 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, '');
  10038. GM_setValue('discordAuth', {
  10039. auth: discordAuth
  10040. });
  10041. if (discordAuth && window.location.hash === '#auth') {
  10042. window.close();
  10043. external_Swal_default().fire('', i18n('closePageNotice'));
  10044. }
  10045. }
  10046. const loadScript = async () => {
  10047. var _website, _website2, _website3, _website4, _website5, _website6;
  10048. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10049. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10050. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10051. if (isLogin) {
  10052. var _commonOptions, _commonOptions$header;
  10053. GM_setValue('twitchAuth', {
  10054. authToken: authToken,
  10055. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10056. });
  10057. window.close();
  10058. external_Swal_default().fire('', i18n('closePageNotice'));
  10059. } else {
  10060. external_Swal_default().fire('', i18n('needLogin'));
  10061. }
  10062. }
  10063. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10064. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10065. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10066. if (isLogin && ct0) {
  10067. GM_setValue('twitterAuth', {
  10068. ct0: ct0
  10069. });
  10070. window.close();
  10071. external_Swal_default().fire('', i18n('closePageNotice'));
  10072. } else {
  10073. external_Swal_default().fire('', i18n('needLogin'));
  10074. }
  10075. }
  10076. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10077. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10078. if (PAPISID) {
  10079. GM_setValue('youtubeAuth', {
  10080. PAPISID: PAPISID
  10081. });
  10082. window.close();
  10083. external_Swal_default().fire('', i18n('closePageNotice'));
  10084. } else {
  10085. external_Swal_default().fire('', i18n('needLogin'));
  10086. }
  10087. }
  10088. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10089. const betaButton = $('#redesign-beta-optin-btn');
  10090. if (betaButton.length > 0) {
  10091. GM_setValue('redditAuth', '#auth');
  10092. return betaButton[0].click();
  10093. }
  10094. GM_setValue('redditAuth', null);
  10095. window.close();
  10096. external_Swal_default().fire('', i18n('closePageNotice'));
  10097. }
  10098. let website;
  10099. for (const Website of Websites) {
  10100. if (Website.test()) {
  10101. website = new Website();
  10102. break;
  10103. }
  10104. }
  10105. if (!website) {
  10106. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10107. return;
  10108. }
  10109. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10110. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10111. }
  10112. $('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>`);
  10113. $('div.show-button-div').on('click', () => {
  10114. $('#auto-task-buttons').show();
  10115. $('div.show-button-div').hide();
  10116. });
  10117. const toggleLog = () => {
  10118. const $this = $('#toggle-log');
  10119. const status = $this.attr('data-status');
  10120. if (status === 'show') {
  10121. $('#auto-task-info').hide();
  10122. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10123. } else {
  10124. $('#auto-task-info').show();
  10125. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10126. }
  10127. };
  10128. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10129. if (website.doTask) {
  10130. website.doTask();
  10131. }
  10132. });
  10133. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10134. if (website.undoTask) {
  10135. website.doTask();
  10136. }
  10137. });
  10138. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10139. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10140. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10141. }
  10142. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10143. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10144. for (const button of website.buttons) {
  10145. if (website[button]) {
  10146. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10147. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10148. website[button]();
  10149. });
  10150. $('#auto-task-buttons').append(btnElement);
  10151. }
  10152. }
  10153. }
  10154. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10155. ${i18n('hideButton')}</a></p>`);
  10156. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10157. $('#auto-task-buttons').hide();
  10158. $('div.show-button-div').show();
  10159. });
  10160. 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'}">
  10161. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10162. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10163. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10164. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10165. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10166. options(website.name, website.options);
  10167. });
  10168. }
  10169. if (website.name !== 'Setting') {
  10170. GM_registerMenuCommand(i18n('whiteList'), () => {
  10171. whiteList('swal');
  10172. });
  10173. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10174. changeGlobalOptions('swal');
  10175. });
  10176. GM_registerMenuCommand(i18n('tasksHistory'), () => {
  10177. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10178. });
  10179. GM_registerMenuCommand(i18n('syncData'), dataSync);
  10180. GM_registerMenuCommand(i18n('settingPage'), () => {
  10181. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10182. });
  10183. }
  10184. GM_addStyle(auto_task.Z);
  10185. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10186. if (!GM_getValue('notice')) {
  10187. var _echoLog$font;
  10188. external_Swal_default().fire({
  10189. title: i18n('swalNotice'),
  10190. icon: 'warning'
  10191. }).then(() => {
  10192. window.open(i18n('noticeLink'), '_blank');
  10193. GM_setValue('notice', new Date().getTime());
  10194. });
  10195. (_echoLog$font = scripts_echoLog({
  10196. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10197. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10198. GM_setValue('notice', new Date().getTime());
  10199. });
  10200. }
  10201. scripts_updateChecker();
  10202. };
  10203. if (window.location.hostname === 'opquests.com') {
  10204. loadScript();
  10205. } else {
  10206. $(loadScript);
  10207. }
  10208. }();
  10209. })();