auto-task-v4

赠Key站自动任务

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.5-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}', '' ]);
  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. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1357. };
  1358. const zh_CN = data;
  1359. const en_US_data = {
  1360. website: 'Website',
  1361. type: 'Type',
  1362. edit: 'Edit',
  1363. whiteList: 'Whitelist',
  1364. skipTask: 'Skip undo task',
  1365. whiteListOptions: 'Whitelist options',
  1366. changeWhiteListOption: 'Whitelist option(%0)',
  1367. whiteListNotFound: 'Cannot find this whitelist: %0',
  1368. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1369. changeWebsiteOptions: 'Website options',
  1370. changeGlobalOptions: 'Global options',
  1371. ok: 'OK',
  1372. save: 'Save',
  1373. close: 'Close',
  1374. return: 'Return',
  1375. option: 'Option',
  1376. value: 'Value',
  1377. websiteOptions: 'Current website settings',
  1378. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1379. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1380. needLogin: 'Please log in first!',
  1381. getTasksInfo: 'Obtaining and processing task information...',
  1382. gettingKey: 'Getting Key...',
  1383. verifyingTask: 'Verifying task',
  1384. notice: 'Automatic task script notice',
  1385. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1386. giveawayEnded: 'This event has ended, do you want to close it?',
  1387. 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?',
  1388. confirm: 'Confirm',
  1389. cancel: 'Cancel',
  1390. unKnown: 'Unknown',
  1391. unKnownTaskType: 'Unrecognized task',
  1392. doing: 'Doing a task',
  1393. allTasksComplete: 'All tasks have been completed!',
  1394. getTaskIdFailed: 'Failed to obtain task Id!',
  1395. initSuccess: '%0 was initialized successfully!',
  1396. initFailed: '%0 initialization failed!',
  1397. errorLink: 'Link error: %0',
  1398. needInit: 'Please initialize first',
  1399. verifyingAuth: 'Verifying %0 token...',
  1400. updatingAuth: 'Update %0 token...',
  1401. initing: 'Initializing...',
  1402. getFailed: 'Failed to get %0!',
  1403. checkLoginFailed: 'Failed to detect login status!',
  1404. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1405. userId: 'User Id',
  1406. joiningGiveaway: 'Joining giveaway',
  1407. needJoinGiveaway: 'Need to join the giveaway first',
  1408. cannotUndo: 'This website does not support canceling tasks',
  1409. verifyAuth: 'Verifying %0 token...',
  1410. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1411. errorReport: 'A script error is detected, do you want to report the BUG?',
  1412. visitingLink: 'Visiting link: ',
  1413. doTask: 'DoTask',
  1414. undoTask: 'UndoTask',
  1415. verifyTask: 'Verify',
  1416. getKey: 'GetKey',
  1417. selectAll: 'SelectAll',
  1418. selectNone: 'SelectNone',
  1419. invertSelect: 'InvertSelect',
  1420. doFreeTask: 'FreeTask',
  1421. doPointTask: 'PointTask',
  1422. skipTaskOption: 'Skip task has been configured in the settings',
  1423. other: 'Other',
  1424. globalOptions: 'Global Options',
  1425. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1426. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1427. twitterVerifyId: 'Verify Twitter token by trying to follow the account.</br>The default is the official Twitter account 783214.',
  1428. youtubeVerifyChannel: 'Verify YouTube token by trying to subscribe to the channel.</br>' + 'The default is the official YouTube channel UCrXUsMBcfTVqwAS7DKg9C0Q.',
  1429. 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.',
  1430. saveGlobalOptions: 'SaveSettings',
  1431. settingPage: 'Setting Page',
  1432. name: 'Name',
  1433. version: 'Version',
  1434. scriptManager: 'Script Manager',
  1435. script: 'Script',
  1436. environment: 'Environment',
  1437. os: 'OS',
  1438. browser: 'Browser',
  1439. getId: 'Get %0 id',
  1440. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1441. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1442. showButton: 'ShowButton',
  1443. hideButton: 'HideButton',
  1444. showLog: 'ShowLog',
  1445. hideLog: 'HideLog',
  1446. defaultShowButton: 'Default display button',
  1447. defaultShowLog: 'Display log by default',
  1448. position: 'Component position',
  1449. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1450. 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',
  1451. 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',
  1452. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1453. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1454. 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',
  1455. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1456. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1457. 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',
  1458. hotKey: 'Shortcut key',
  1459. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1460. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1461. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1462. tasksHistory: 'TasksHistory',
  1463. clearHistory: 'Clear history',
  1464. clearHistoryFinished: 'The mission history has been cleared!',
  1465. deleteTask: 'Delete task',
  1466. lastChangeTime: 'Last Change Time',
  1467. clearTaskFinished: 'Delete the following tasks completed!',
  1468. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1469. syncData: 'Data synchronization',
  1470. settingData: 'Uploading data...',
  1471. gettingData: 'Getting data...',
  1472. help: 'Help',
  1473. fileName: 'Filename',
  1474. upload2gist: 'Sync to Gist',
  1475. downloadFromGist: 'Sync from Gist',
  1476. saveAndTest: 'Save configuration and test',
  1477. testSuccess: 'Test success!',
  1478. testFailed: 'Test failed!',
  1479. saveAndTestNotice: 'Please save the configuration and test first!',
  1480. processingData: 'Processing data...',
  1481. updatingData: 'Uploading data...',
  1482. syncDataSuccess: 'Synchronized data successfully!',
  1483. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1484. downloadingData: 'Downloading data...',
  1485. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1486. savingData: 'Saving data...',
  1487. syncHistory: 'Synchronize tasks history',
  1488. checkUpdateFailed: 'Check update failed',
  1489. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1490. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1491. gistOptions: 'Gist Settings',
  1492. 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!',
  1493. 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!',
  1494. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1495. toGithub: 'Feedback(Github)',
  1496. toKeylol: 'Feedback(Keylol)',
  1497. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1498. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1499. updateText: 'Updates in version %0:',
  1500. groups: 'Group',
  1501. wishlists: 'Wishlist',
  1502. follows: 'Follow Game',
  1503. forums: 'Forum',
  1504. workshops: 'Favorite Workshop',
  1505. curators: 'Curator',
  1506. workshopVotes: 'Voteup Workshop',
  1507. announcements: 'Announcement',
  1508. steamCommunity: 'Steam Community',
  1509. steamStore: 'Steam Store',
  1510. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1511. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1512. joiningSteamGroup: 'Joining Steam Group',
  1513. leavingSteamGroup: 'Leaving Steam Group',
  1514. gettingSteamGroupId: 'Getting Steam Group Id',
  1515. subscribingForum: 'Subscribing the Steam Forum',
  1516. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1517. gettingForumId: 'Getting Steam Forum Id',
  1518. followingCurator: 'Following Steam Curator',
  1519. unfollowingCurator: 'Unfollowing Steam Curator',
  1520. addingToWishlist: 'Adding the game to the Steam wishlist',
  1521. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1522. followingGame: 'Following Steam games',
  1523. unfollowingGame: 'Unfollowing Steam games',
  1524. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1525. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1526. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1527. votingUpWorkshop: 'Liking Steam workshop items',
  1528. gettingAnnouncementParams: 'Getting Steam announcement information',
  1529. likingAnnouncement: 'Liking Steam announcement',
  1530. changingArea: 'Changing Steam area: %0...',
  1531. notNeededChangeArea: 'The current area does not need to be changed',
  1532. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1533. gettingAreaInfo: 'Getting Steam area information...',
  1534. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1535. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1536. servers: 'Server',
  1537. joiningDiscordServer: 'Joining Discord Server',
  1538. leavingDiscordServer: 'Leaving Discord Server',
  1539. gettingDiscordGuild: 'Getting Discord server Id',
  1540. users: 'User',
  1541. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1542. insBanned: 'Your Instagram account has been banned',
  1543. verifyingInsAuth: 'Verifying Instagram token...',
  1544. gettingInsUserId: 'Getting Instagram user Id',
  1545. followingIns: 'Following Instagram user',
  1546. unfollowingIns: 'Unfollowing Instagram user',
  1547. reddits: 'Reddit/User',
  1548. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1549. changingRedditVersion: 'Switching Reddit to a new version page...',
  1550. joiningReddit: 'Joining the Reddit',
  1551. leavingReddit: 'Leaving the Reddit',
  1552. followingRedditUser: 'Following Reddit User',
  1553. unfollowingRedditUser: 'Unfollowing Reddit User',
  1554. channels: 'Channel',
  1555. followingTwitchChannel: 'Following Twitch Channel',
  1556. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1557. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1558. twitterUser: 'Twitter User',
  1559. retweets: 'Retweet',
  1560. followingTwitterUser: 'Following Twitter User',
  1561. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1562. retweetting: 'Retweeting',
  1563. unretweetting: 'Unretweeting',
  1564. names: 'Group/Public/Wall',
  1565. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1566. gettingVkId: 'Getting Vk task Id',
  1567. joiningVkGroup: 'Joining Vk Group',
  1568. leavingVkGroup: 'Leaving Vk Group',
  1569. joiningVkPublic: 'Joining Vk Public',
  1570. leavingVkPublic: 'Leaving Vk Public',
  1571. sendingVkWall: 'Sending Vk Wall',
  1572. deletingVkWall: 'Deleting Vk Wall',
  1573. youtubeChannel: 'YouTube Channel',
  1574. likes: 'Like',
  1575. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1576. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1577. gettingYtbToken: 'Getting YouTube Token...',
  1578. followingYtbChannel: 'Subscribing to YouTube channel',
  1579. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1580. likingYtbVideo: 'Liking YouTube video',
  1581. unlikingYtbVideo: 'Unliking YouTube video',
  1582. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1583. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1584. noPoints: 'Not enough points, skip the lottery',
  1585. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1586. joiningLottery: 'Joining the lottery',
  1587. doingGleamTask: 'Doing Gleam Task...',
  1588. gettingGleamLink: 'Getting Gleam task link...',
  1589. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1590. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1591. 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...'
  1592. };
  1593. const en_US = en_US_data;
  1594. const languages = {
  1595. zh: zh_CN,
  1596. en: en_US
  1597. };
  1598. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1599. const I18n = function(key) {
  1600. var _languages$language;
  1601. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1602. argvs[_key - 1] = arguments[_key];
  1603. }
  1604. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1605. return key;
  1606. }
  1607. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1608. };
  1609. const i18n = I18n;
  1610. function throwError(error, name) {
  1611. external_Swal_default().fire({
  1612. title: i18n('errorReport'),
  1613. icon: 'error',
  1614. showCancelButton: true,
  1615. confirmButtonText: i18n('toGithub'),
  1616. showDenyButton: true,
  1617. denyButtonText: i18n('toKeylol'),
  1618. cancelButtonText: i18n('close')
  1619. }).then(_ref => {
  1620. let {
  1621. isDenied,
  1622. isConfirmed
  1623. } = _ref;
  1624. if (isConfirmed) {
  1625. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1626.  
  1627. 环境:
  1628. \`\`\`
  1629. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1630. \`\`\`
  1631. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1632. 脚本版本: \`${GM_info.script.version}\`
  1633.  
  1634. 报错信息:
  1635. \`\`\`
  1636. ${error.stack}
  1637. \`\`\`
  1638.  
  1639. 执行日志:
  1640. \`\`\`
  1641. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1642. \`\`\`
  1643. `)}`, '_blank');
  1644. } else if (isDenied) {
  1645. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1646.  
  1647. 环境:
  1648.  
  1649. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1650.  
  1651. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1652. 脚本版本: ${GM_info.script.version}
  1653.  
  1654. 报错信息:
  1655. [code]${error.stack}[/code]
  1656.  
  1657. 执行日志:
  1658. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1659. GM_setClipboard(text);
  1660. external_Swal_default().fire({
  1661. title: i18n('copySuccess'),
  1662. icon: 'success',
  1663. confirmButtonText: i18n('ok')
  1664. }).then(() => {
  1665. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1666. });
  1667. }
  1668. });
  1669. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1670. }
  1671. function _defineProperty(obj, key, value) {
  1672. if (key in obj) {
  1673. Object.defineProperty(obj, key, {
  1674. value: value,
  1675. enumerable: true,
  1676. configurable: true,
  1677. writable: true
  1678. });
  1679. } else {
  1680. obj[key] = value;
  1681. }
  1682. return obj;
  1683. }
  1684. class Social {
  1685. constructor() {
  1686. _defineProperty(this, 'tasks', void 0);
  1687. }
  1688. getRealParams(name, links, doTask, link2param) {
  1689. try {
  1690. let realParams = [];
  1691. if (links.length > 0) {
  1692. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1693. }
  1694. if (!doTask && this.tasks[name].length > 0) {
  1695. realParams = [ ...realParams, ...this.tasks[name] ];
  1696. }
  1697. return unique(realParams);
  1698. } catch (error) {
  1699. throwError(error, 'Social.getRealParams');
  1700. return [];
  1701. }
  1702. }
  1703. }
  1704. const social_Social = Social;
  1705. function _classPrivateMethodInitSpec(obj, privateSet) {
  1706. _checkPrivateRedeclaration(obj, privateSet);
  1707. privateSet.add(obj);
  1708. }
  1709. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1710. _checkPrivateRedeclaration(obj, privateMap);
  1711. privateMap.set(obj, value);
  1712. }
  1713. function _checkPrivateRedeclaration(obj, privateCollection) {
  1714. if (privateCollection.has(obj)) {
  1715. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1716. }
  1717. }
  1718. function Discord_defineProperty(obj, key, value) {
  1719. if (key in obj) {
  1720. Object.defineProperty(obj, key, {
  1721. value: value,
  1722. enumerable: true,
  1723. configurable: true,
  1724. writable: true
  1725. });
  1726. } else {
  1727. obj[key] = value;
  1728. }
  1729. return obj;
  1730. }
  1731. function _classPrivateFieldSet(receiver, privateMap, value) {
  1732. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1733. _classApplyDescriptorSet(receiver, descriptor, value);
  1734. return value;
  1735. }
  1736. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1737. if (descriptor.set) {
  1738. descriptor.set.call(receiver, value);
  1739. } else {
  1740. if (!descriptor.writable) {
  1741. throw new TypeError('attempted to set read only private field');
  1742. }
  1743. descriptor.value = value;
  1744. }
  1745. }
  1746. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1747. if (!privateSet.has(receiver)) {
  1748. throw new TypeError('attempted to get private field on non-instance');
  1749. }
  1750. return fn;
  1751. }
  1752. function _classPrivateFieldGet(receiver, privateMap) {
  1753. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1754. return _classApplyDescriptorGet(receiver, descriptor);
  1755. }
  1756. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1757. if (!privateMap.has(receiver)) {
  1758. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1759. }
  1760. return privateMap.get(receiver);
  1761. }
  1762. function _classApplyDescriptorGet(receiver, descriptor) {
  1763. if (descriptor.get) {
  1764. return descriptor.get.call(receiver);
  1765. }
  1766. return descriptor.value;
  1767. }
  1768. const defaultTasks = {
  1769. servers: []
  1770. };
  1771. var _auth = new WeakMap();
  1772. var _cache = new WeakMap();
  1773. var _initialized = new WeakMap();
  1774. var _verifyAuth = new WeakSet();
  1775. var _updateAuth = new WeakSet();
  1776. var _joinServer = new WeakSet();
  1777. var _leaveServer = new WeakSet();
  1778. var _getGuild = new WeakSet();
  1779. var _setCache = new WeakSet();
  1780. class Discord extends social_Social {
  1781. constructor() {
  1782. var _GM_getValue;
  1783. super(...arguments);
  1784. _classPrivateMethodInitSpec(this, _setCache);
  1785. _classPrivateMethodInitSpec(this, _getGuild);
  1786. _classPrivateMethodInitSpec(this, _leaveServer);
  1787. _classPrivateMethodInitSpec(this, _joinServer);
  1788. _classPrivateMethodInitSpec(this, _updateAuth);
  1789. _classPrivateMethodInitSpec(this, _verifyAuth);
  1790. Discord_defineProperty(this, 'tasks', {
  1791. ...defaultTasks
  1792. });
  1793. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || {
  1794. ...defaultTasks
  1795. });
  1796. _classPrivateFieldInitSpec(this, _auth, {
  1797. writable: true,
  1798. value: GM_getValue('discordAuth') || {}
  1799. });
  1800. _classPrivateFieldInitSpec(this, _cache, {
  1801. writable: true,
  1802. value: GM_getValue('discordCache') || {}
  1803. });
  1804. _classPrivateFieldInitSpec(this, _initialized, {
  1805. writable: true,
  1806. value: false
  1807. });
  1808. }
  1809. async init() {
  1810. try {
  1811. if (_classPrivateFieldGet(this, _initialized)) {
  1812. return true;
  1813. }
  1814. if (!_classPrivateFieldGet(this, _auth).auth) {
  1815. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1816. _classPrivateFieldSet(this, _initialized, true);
  1817. return true;
  1818. }
  1819. return false;
  1820. }
  1821. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1822. if (isVerified) {
  1823. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1824. _classPrivateFieldSet(this, _initialized, true);
  1825. return true;
  1826. }
  1827. GM_setValue('discordAuth', {
  1828. auth: null
  1829. });
  1830. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1831. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1832. _classPrivateFieldSet(this, _initialized, true);
  1833. return true;
  1834. }
  1835. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1836. return false;
  1837. } catch (error) {
  1838. throwError(error, 'Discord.init');
  1839. return false;
  1840. }
  1841. }
  1842. async toggle(_ref) {
  1843. let {
  1844. doTask = true,
  1845. serverLinks = []
  1846. } = _ref;
  1847. try {
  1848. if (!_classPrivateFieldGet(this, _initialized)) {
  1849. scripts_echoLog({
  1850. text: i18n('needInit')
  1851. });
  1852. return false;
  1853. }
  1854. const prom = [];
  1855. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1856. scripts_echoLog({
  1857. type: 'globalOptionsSkip',
  1858. text: 'discord.servers'
  1859. });
  1860. } else {
  1861. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1862. var _link$match;
  1863. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1864. });
  1865. if (realServers.length > 0) {
  1866. for (const server of realServers) {
  1867. if (doTask) {
  1868. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1869. } else {
  1870. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1871. }
  1872. await delay(1e3);
  1873. }
  1874. }
  1875. }
  1876. return await Promise.all(prom).then(() => true);
  1877. } catch (error) {
  1878. throwError(error, 'Discord.toggleServers');
  1879. return false;
  1880. }
  1881. }
  1882. }
  1883. async function _verifyAuth2() {
  1884. try {
  1885. const logStatus = scripts_echoLog({
  1886. text: i18n('verifyingAuth', 'Discord')
  1887. });
  1888. const {
  1889. result,
  1890. statusText,
  1891. status,
  1892. data
  1893. } = await tools_httpRequest({
  1894. url: 'https://discord.com/api/v6/users/@me',
  1895. method: 'HEAD',
  1896. headers: {
  1897. authorization: _classPrivateFieldGet(this, _auth).auth
  1898. }
  1899. });
  1900. if (result === 'Success') {
  1901. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1902. logStatus.success();
  1903. return true;
  1904. }
  1905. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1906. return false;
  1907. }
  1908. logStatus.error(`${result}:${statusText}(${status})`);
  1909. return false;
  1910. } catch (error) {
  1911. throwError(error, 'Discord.verifyAuth');
  1912. return false;
  1913. }
  1914. }
  1915. async function _updateAuth2() {
  1916. try {
  1917. const logStatus = scripts_echoLog({
  1918. text: i18n('updatingAuth', 'Discord')
  1919. });
  1920. return await new Promise(resolve => {
  1921. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1922. active: true,
  1923. insert: true,
  1924. setParent: true
  1925. });
  1926. newTab.onclose = async () => {
  1927. var _GM_getValue2;
  1928. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1929. if (auth) {
  1930. _classPrivateFieldSet(this, _auth, {
  1931. auth: auth
  1932. });
  1933. logStatus.success();
  1934. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1935. } else {
  1936. logStatus.error('Error: Update discord auth failed!');
  1937. resolve(false);
  1938. }
  1939. };
  1940. });
  1941. } catch (error) {
  1942. throwError(error, 'Discord.updateAuth');
  1943. return false;
  1944. }
  1945. }
  1946. async function _joinServer2(inviteId) {
  1947. try {
  1948. const logStatus = scripts_echoLog({
  1949. type: 'joiningDiscordServer',
  1950. text: inviteId
  1951. });
  1952. const {
  1953. result,
  1954. statusText,
  1955. status,
  1956. data
  1957. } = await tools_httpRequest({
  1958. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1959. method: 'POST',
  1960. dataType: 'json',
  1961. headers: {
  1962. authorization: _classPrivateFieldGet(this, _auth).auth
  1963. }
  1964. });
  1965. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1966. var _data$response, _data$response$guild;
  1967. logStatus.success();
  1968. 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);
  1969. if (guild) {
  1970. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1971. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1972. }
  1973. return true;
  1974. }
  1975. logStatus.error(`${result}:${statusText}(${status})`);
  1976. return false;
  1977. } catch (error) {
  1978. throwError(error, 'Discord.joinServer');
  1979. return false;
  1980. }
  1981. }
  1982. async function _leaveServer2(inviteId) {
  1983. try {
  1984. if (this.whiteList.servers.includes(inviteId)) {
  1985. scripts_echoLog({
  1986. type: 'whiteList',
  1987. text: 'Discord.leaveServer',
  1988. id: inviteId
  1989. });
  1990. return true;
  1991. }
  1992. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  1993. if (!guild) {
  1994. return false;
  1995. }
  1996. const logStatus = scripts_echoLog({
  1997. type: 'leavingDiscordServer',
  1998. text: guild
  1999. });
  2000. const {
  2001. result,
  2002. statusText,
  2003. status,
  2004. data
  2005. } = await tools_httpRequest({
  2006. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2007. method: 'DELETE',
  2008. headers: {
  2009. authorization: _classPrivateFieldGet(this, _auth).auth
  2010. }
  2011. });
  2012. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2013. logStatus.success();
  2014. return true;
  2015. }
  2016. logStatus.error(`${result}:${statusText}(${status})`);
  2017. return false;
  2018. } catch (error) {
  2019. throwError(error, 'Discord.leaveServer');
  2020. return false;
  2021. }
  2022. }
  2023. async function _getGuild2(inviteId) {
  2024. try {
  2025. const logStatus = scripts_echoLog({
  2026. type: 'gettingDiscordGuild',
  2027. text: inviteId
  2028. });
  2029. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2030. if (guild) {
  2031. logStatus.success();
  2032. return guild;
  2033. }
  2034. const {
  2035. result,
  2036. statusText,
  2037. status,
  2038. data
  2039. } = await tools_httpRequest({
  2040. url: `https://discord.com/invite/${inviteId}`,
  2041. method: 'GET'
  2042. });
  2043. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2044. var _data$responseText$ma;
  2045. 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];
  2046. if (guild) {
  2047. logStatus.success();
  2048. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2049. return guild;
  2050. }
  2051. logStatus.error(`${result}:${statusText}(${status})`);
  2052. return false;
  2053. }
  2054. logStatus.error(`${result}:${statusText}(${status})`);
  2055. return false;
  2056. } catch (error) {
  2057. throwError(error, 'Discord.getGuild');
  2058. return false;
  2059. }
  2060. }
  2061. function _setCache2(inviteId, guild) {
  2062. try {
  2063. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2064. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2065. } catch (error) {
  2066. throwError(error, 'Discord.setCache');
  2067. }
  2068. }
  2069. const social_Discord = Discord;
  2070. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2071. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2072. privateSet.add(obj);
  2073. }
  2074. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2075. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2076. privateMap.set(obj, value);
  2077. }
  2078. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2079. if (privateCollection.has(obj)) {
  2080. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2081. }
  2082. }
  2083. function Instagram_defineProperty(obj, key, value) {
  2084. if (key in obj) {
  2085. Object.defineProperty(obj, key, {
  2086. value: value,
  2087. enumerable: true,
  2088. configurable: true,
  2089. writable: true
  2090. });
  2091. } else {
  2092. obj[key] = value;
  2093. }
  2094. return obj;
  2095. }
  2096. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2097. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2098. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2099. return value;
  2100. }
  2101. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2102. if (descriptor.set) {
  2103. descriptor.set.call(receiver, value);
  2104. } else {
  2105. if (!descriptor.writable) {
  2106. throw new TypeError('attempted to set read only private field');
  2107. }
  2108. descriptor.value = value;
  2109. }
  2110. }
  2111. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2112. if (!privateSet.has(receiver)) {
  2113. throw new TypeError('attempted to get private field on non-instance');
  2114. }
  2115. return fn;
  2116. }
  2117. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2118. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2119. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2120. }
  2121. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2122. if (!privateMap.has(receiver)) {
  2123. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2124. }
  2125. return privateMap.get(receiver);
  2126. }
  2127. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2128. if (descriptor.get) {
  2129. return descriptor.get.call(receiver);
  2130. }
  2131. return descriptor.value;
  2132. }
  2133. const Instagram_defaultTasks = {
  2134. users: []
  2135. };
  2136. var Instagram_cache = new WeakMap();
  2137. var Instagram_auth = new WeakMap();
  2138. var Instagram_initialized = new WeakMap();
  2139. var _getUserInfo = new WeakSet();
  2140. var _followUser = new WeakSet();
  2141. var _unfollowUser = new WeakSet();
  2142. var Instagram_setCache = new WeakSet();
  2143. class Instagram extends social_Social {
  2144. constructor() {
  2145. var _GM_getValue;
  2146. super(...arguments);
  2147. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2148. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2149. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2150. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2151. Instagram_defineProperty(this, 'tasks', {
  2152. ...Instagram_defaultTasks
  2153. });
  2154. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || {
  2155. ...Instagram_defaultTasks
  2156. });
  2157. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2158. writable: true,
  2159. value: GM_getValue('instagramCache') || {}
  2160. });
  2161. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2162. writable: true,
  2163. value: {}
  2164. });
  2165. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2166. writable: true,
  2167. value: false
  2168. });
  2169. }
  2170. async init() {
  2171. try {
  2172. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2173. return true;
  2174. }
  2175. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2176. if (isVerified) {
  2177. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2178. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2179. return true;
  2180. }
  2181. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2182. return false;
  2183. } catch (error) {
  2184. throwError(error, 'Instagram.init');
  2185. return false;
  2186. }
  2187. }
  2188. async toggle(_ref) {
  2189. let {
  2190. doTask = true,
  2191. userLinks = []
  2192. } = _ref;
  2193. try {
  2194. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2195. scripts_echoLog({
  2196. text: i18n('needInit')
  2197. });
  2198. return false;
  2199. }
  2200. const prom = [];
  2201. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2202. scripts_echoLog({
  2203. type: 'globalOptionsSkip',
  2204. text: 'instagram.users'
  2205. });
  2206. } else {
  2207. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2208. var _link$match;
  2209. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2210. });
  2211. if (realUsers.length > 0) {
  2212. for (const username of realUsers) {
  2213. if (doTask) {
  2214. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2215. } else {
  2216. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2217. }
  2218. await delay(1e3);
  2219. }
  2220. }
  2221. }
  2222. return await Promise.all(prom).then(() => true);
  2223. } catch (error) {
  2224. throwError(error, 'Instagram.toggleUsers');
  2225. return false;
  2226. }
  2227. }
  2228. }
  2229. async function _getUserInfo2() {
  2230. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2231. try {
  2232. const logStatus = scripts_echoLog({
  2233. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2234. text: name
  2235. });
  2236. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2237. if (userId && name !== 'instagram') {
  2238. logStatus.success();
  2239. return userId;
  2240. }
  2241. const {
  2242. result,
  2243. statusText,
  2244. status,
  2245. data
  2246. } = await tools_httpRequest({
  2247. url: `https://www.instagram.com/${name}/`,
  2248. method: 'GET'
  2249. });
  2250. if (result === 'Success') {
  2251. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2252. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2253. return false;
  2254. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2255. logStatus.error(`Error:${i18n('insBanned')}`);
  2256. return false;
  2257. }
  2258. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2259. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2260. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2261. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2262. if (name === 'instagram') {
  2263. if (csrftoken && hash) {
  2264. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2265. csrftoken: csrftoken,
  2266. hash: hash
  2267. });
  2268. return true;
  2269. }
  2270. return false;
  2271. }
  2272. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2273. if (id) {
  2274. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2275. logStatus.success();
  2276. return id;
  2277. }
  2278. logStatus.error('Error: Get ins data error!');
  2279. return false;
  2280. }
  2281. logStatus.error(`${result}:${statusText}(${status})`);
  2282. return false;
  2283. }
  2284. return false;
  2285. } catch (error) {
  2286. throwError(error, 'Instagram.getUserInfo');
  2287. return false;
  2288. }
  2289. }
  2290. async function _followUser2(name) {
  2291. try {
  2292. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2293. if (!id) {
  2294. return false;
  2295. }
  2296. const logStatus = scripts_echoLog({
  2297. type: 'followingIns',
  2298. text: name
  2299. });
  2300. const {
  2301. result,
  2302. statusText,
  2303. status,
  2304. data
  2305. } = await tools_httpRequest({
  2306. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2307. method: 'POST',
  2308. dataType: 'json',
  2309. headers: {
  2310. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2311. origin: 'https://www.instagram.com',
  2312. referer: `https://www.instagram.com/${name}/`,
  2313. 'content-type': 'application/x-www-form-urlencoded',
  2314. 'sec-fetch-site': 'same-origin',
  2315. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2316. }
  2317. });
  2318. if (result === 'Success') {
  2319. var _data$response, _data$response2;
  2320. 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') {
  2321. logStatus.success();
  2322. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2323. return true;
  2324. }
  2325. 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})`}`);
  2326. return false;
  2327. }
  2328. logStatus.error(`${result}:${statusText}(${status})`);
  2329. return false;
  2330. } catch (error) {
  2331. throwError(error, 'Instagram.followUser');
  2332. return false;
  2333. }
  2334. }
  2335. async function _unfollowUser2(name) {
  2336. try {
  2337. if (this.whiteList.users.includes(name)) {
  2338. scripts_echoLog({
  2339. type: 'whiteList',
  2340. text: 'Instagram.unfollowUser',
  2341. id: name
  2342. });
  2343. return true;
  2344. }
  2345. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2346. if (!id) {
  2347. return false;
  2348. }
  2349. const logStatus = scripts_echoLog({
  2350. type: 'unfollowingIns',
  2351. text: name
  2352. });
  2353. const {
  2354. result,
  2355. statusText,
  2356. status,
  2357. data
  2358. } = await tools_httpRequest({
  2359. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2360. method: 'POST',
  2361. dataType: 'json',
  2362. headers: {
  2363. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2364. origin: 'https://www.instagram.com',
  2365. referer: `https://www.instagram.com/${name}/`,
  2366. 'content-type': 'application/x-www-form-urlencoded',
  2367. 'sec-fetch-site': 'same-origin',
  2368. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2369. }
  2370. });
  2371. if (result === 'Success') {
  2372. var _data$response3;
  2373. 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') {
  2374. logStatus.success();
  2375. return true;
  2376. }
  2377. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2378. return false;
  2379. }
  2380. logStatus.error(`${result}:${statusText}(${status})`);
  2381. return false;
  2382. } catch (error) {
  2383. throwError(error, 'Instagram.unfollowUser');
  2384. return false;
  2385. }
  2386. }
  2387. function Instagram_setCache2(name, id) {
  2388. try {
  2389. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2390. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2391. } catch (error) {
  2392. throwError(error, 'Instagram.setCache');
  2393. }
  2394. }
  2395. const social_Instagram = Instagram;
  2396. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2397. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2398. privateSet.add(obj);
  2399. }
  2400. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2401. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2402. privateMap.set(obj, value);
  2403. }
  2404. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2405. if (privateCollection.has(obj)) {
  2406. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2407. }
  2408. }
  2409. function Reddit_defineProperty(obj, key, value) {
  2410. if (key in obj) {
  2411. Object.defineProperty(obj, key, {
  2412. value: value,
  2413. enumerable: true,
  2414. configurable: true,
  2415. writable: true
  2416. });
  2417. } else {
  2418. obj[key] = value;
  2419. }
  2420. return obj;
  2421. }
  2422. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2423. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2424. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2425. return value;
  2426. }
  2427. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2428. if (descriptor.set) {
  2429. descriptor.set.call(receiver, value);
  2430. } else {
  2431. if (!descriptor.writable) {
  2432. throw new TypeError('attempted to set read only private field');
  2433. }
  2434. descriptor.value = value;
  2435. }
  2436. }
  2437. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2438. if (!privateSet.has(receiver)) {
  2439. throw new TypeError('attempted to get private field on non-instance');
  2440. }
  2441. return fn;
  2442. }
  2443. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2444. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2445. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2446. }
  2447. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2448. if (!privateMap.has(receiver)) {
  2449. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2450. }
  2451. return privateMap.get(receiver);
  2452. }
  2453. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2454. if (descriptor.get) {
  2455. return descriptor.get.call(receiver);
  2456. }
  2457. return descriptor.value;
  2458. }
  2459. const Reddit_defaultTasks = {
  2460. reddits: []
  2461. };
  2462. var Reddit_auth = new WeakMap();
  2463. var Reddit_initialized = new WeakMap();
  2464. var _useBeta = new WeakSet();
  2465. var Reddit_updateAuth = new WeakSet();
  2466. class Reddit extends social_Social {
  2467. constructor() {
  2468. var _GM_getValue;
  2469. super(...arguments);
  2470. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2471. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2472. Reddit_defineProperty(this, 'tasks', {
  2473. ...Reddit_defaultTasks
  2474. });
  2475. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || {
  2476. ...Reddit_defaultTasks
  2477. });
  2478. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2479. writable: true,
  2480. value: void 0
  2481. });
  2482. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2483. writable: true,
  2484. value: false
  2485. });
  2486. }
  2487. async init() {
  2488. try {
  2489. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2490. return true;
  2491. }
  2492. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2493. if (isVerified) {
  2494. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2495. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2496. return true;
  2497. }
  2498. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2499. return false;
  2500. } catch (error) {
  2501. throwError(error, 'Reddit.init');
  2502. return false;
  2503. }
  2504. }
  2505. async toggleTask(_ref) {
  2506. let {
  2507. name,
  2508. doTask = true
  2509. } = _ref;
  2510. try {
  2511. if (!doTask && this.whiteList.reddits.includes(name)) {
  2512. scripts_echoLog({
  2513. type: 'whiteList',
  2514. text: 'Reddit.undoTask',
  2515. id: name
  2516. });
  2517. return true;
  2518. }
  2519. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2520. if (/^u_/.test(name)) {
  2521. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2522. }
  2523. const logStatus = scripts_echoLog({
  2524. type: type,
  2525. text: name
  2526. });
  2527. const {
  2528. result,
  2529. statusText,
  2530. status,
  2531. data
  2532. } = await tools_httpRequest({
  2533. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2534. method: 'POST',
  2535. headers: {
  2536. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2537. 'content-type': 'application/x-www-form-urlencoded'
  2538. },
  2539. data: $.param({
  2540. action: doTask ? 'sub' : 'unsub',
  2541. sr_name: name,
  2542. api_type: 'json'
  2543. })
  2544. });
  2545. if (result === 'Success') {
  2546. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2547. logStatus.success();
  2548. if (doTask) {
  2549. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2550. }
  2551. return true;
  2552. }
  2553. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2554. return false;
  2555. }
  2556. logStatus.error(`${result}:${statusText}(${status})`);
  2557. return false;
  2558. } catch (error) {
  2559. throwError(error, 'Reddit.toggleTask');
  2560. return false;
  2561. }
  2562. }
  2563. async toggle(_ref2) {
  2564. let {
  2565. doTask = true,
  2566. redditLinks = []
  2567. } = _ref2;
  2568. try {
  2569. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2570. scripts_echoLog({
  2571. text: i18n('needInit')
  2572. });
  2573. return false;
  2574. }
  2575. const prom = [];
  2576. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2577. scripts_echoLog({
  2578. type: 'globalOptionsSkip',
  2579. text: 'reddit.reddits'
  2580. });
  2581. } else {
  2582. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2583. var _link$match, _link$match2;
  2584. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2585. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2586. if (userName) {
  2587. return name || userName;
  2588. }
  2589. return name;
  2590. });
  2591. if (realReddits.length > 0) {
  2592. for (const name of realReddits) {
  2593. prom.push(this.toggleTask({
  2594. name: name,
  2595. doTask: doTask
  2596. }));
  2597. await delay(1e3);
  2598. }
  2599. }
  2600. }
  2601. return await Promise.all(prom).then(() => true);
  2602. } catch (error) {
  2603. throwError(error, 'Reddit.toggle');
  2604. return false;
  2605. }
  2606. }
  2607. }
  2608. async function _useBeta2() {
  2609. try {
  2610. const logStatus = scripts_echoLog({
  2611. text: i18n('changingRedditVersion')
  2612. });
  2613. GM_setValue('redditAuth', null);
  2614. return await new Promise(resolve => {
  2615. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2616. active: true,
  2617. insert: true,
  2618. setParent: true
  2619. });
  2620. newTab.onclose = async () => {
  2621. logStatus.success();
  2622. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2623. };
  2624. });
  2625. } catch (error) {
  2626. throwError(error, 'Reddit.useBeta');
  2627. return false;
  2628. }
  2629. }
  2630. async function Reddit_updateAuth2() {
  2631. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2632. try {
  2633. const logStatus = scripts_echoLog({
  2634. text: i18n('updatingAuth', 'Reddit')
  2635. });
  2636. const {
  2637. result,
  2638. statusText,
  2639. status,
  2640. data
  2641. } = await tools_httpRequest({
  2642. url: 'https://www.reddit.com/',
  2643. method: 'GET',
  2644. nochche: true,
  2645. headers: {
  2646. 'Cache-Control': 'no-cache'
  2647. }
  2648. });
  2649. if (result === 'Success') {
  2650. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2651. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2652. return false;
  2653. }
  2654. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2655. var _data$responseText$ma;
  2656. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2657. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2658. }
  2659. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2660. if (accessToken) {
  2661. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2662. token: accessToken
  2663. });
  2664. logStatus.success();
  2665. return true;
  2666. }
  2667. logStatus.error('Error: Parameter "accessToken" not found!');
  2668. return false;
  2669. }
  2670. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2671. return false;
  2672. }
  2673. logStatus.error(`${result}:${statusText}(${status})`);
  2674. return false;
  2675. } catch (error) {
  2676. throwError(error, 'Reddit.updateAuth');
  2677. return false;
  2678. }
  2679. }
  2680. const social_Reddit = Reddit;
  2681. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2682. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2683. privateSet.add(obj);
  2684. }
  2685. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2686. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2687. privateMap.set(obj, value);
  2688. }
  2689. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2690. if (privateCollection.has(obj)) {
  2691. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2692. }
  2693. }
  2694. function Twitch_defineProperty(obj, key, value) {
  2695. if (key in obj) {
  2696. Object.defineProperty(obj, key, {
  2697. value: value,
  2698. enumerable: true,
  2699. configurable: true,
  2700. writable: true
  2701. });
  2702. } else {
  2703. obj[key] = value;
  2704. }
  2705. return obj;
  2706. }
  2707. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2708. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2709. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2710. return value;
  2711. }
  2712. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2713. if (descriptor.set) {
  2714. descriptor.set.call(receiver, value);
  2715. } else {
  2716. if (!descriptor.writable) {
  2717. throw new TypeError('attempted to set read only private field');
  2718. }
  2719. descriptor.value = value;
  2720. }
  2721. }
  2722. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2723. if (!privateSet.has(receiver)) {
  2724. throw new TypeError('attempted to get private field on non-instance');
  2725. }
  2726. return fn;
  2727. }
  2728. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2729. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2730. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2731. }
  2732. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2733. if (!privateMap.has(receiver)) {
  2734. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2735. }
  2736. return privateMap.get(receiver);
  2737. }
  2738. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2739. if (descriptor.get) {
  2740. return descriptor.get.call(receiver);
  2741. }
  2742. return descriptor.value;
  2743. }
  2744. const Twitch_defaultTasks = {
  2745. channels: []
  2746. };
  2747. var Twitch_auth = new WeakMap();
  2748. var Twitch_cache = new WeakMap();
  2749. var Twitch_initialized = new WeakMap();
  2750. var Twitch_verifyAuth = new WeakSet();
  2751. var Twitch_updateAuth = new WeakSet();
  2752. var _toggleChannel = new WeakSet();
  2753. var _getChannelId = new WeakSet();
  2754. var Twitch_setCache = new WeakSet();
  2755. class Twitch extends social_Social {
  2756. constructor() {
  2757. var _GM_getValue;
  2758. super(...arguments);
  2759. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2760. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2761. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2762. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2763. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2764. Twitch_defineProperty(this, 'tasks', {
  2765. ...Twitch_defaultTasks
  2766. });
  2767. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || {
  2768. ...Twitch_defaultTasks
  2769. });
  2770. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2771. writable: true,
  2772. value: GM_getValue('twitchAuth') || {}
  2773. });
  2774. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2775. writable: true,
  2776. value: GM_getValue('twitchCache') || {}
  2777. });
  2778. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2779. writable: true,
  2780. value: false
  2781. });
  2782. }
  2783. async init() {
  2784. try {
  2785. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2786. return true;
  2787. }
  2788. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2789. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2790. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2791. return true;
  2792. }
  2793. return false;
  2794. }
  2795. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2796. if (isVerified) {
  2797. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2798. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2799. return true;
  2800. }
  2801. GM_setValue('twitchAuth', null);
  2802. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2803. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2804. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2805. return true;
  2806. }
  2807. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2808. return false;
  2809. } catch (error) {
  2810. throwError(error, 'Twitch.init');
  2811. return false;
  2812. }
  2813. }
  2814. async toggle(_ref) {
  2815. let {
  2816. doTask = true,
  2817. channelLinks = []
  2818. } = _ref;
  2819. try {
  2820. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2821. scripts_echoLog({
  2822. text: i18n('needInit')
  2823. });
  2824. return false;
  2825. }
  2826. const prom = [];
  2827. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2828. scripts_echoLog({
  2829. type: 'globalOptionsSkip',
  2830. text: 'twitch.channels'
  2831. });
  2832. } else {
  2833. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2834. var _link$match;
  2835. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2836. });
  2837. if (realChannels.length > 0) {
  2838. for (const channel of realChannels) {
  2839. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2840. name: channel,
  2841. doTask: doTask
  2842. }));
  2843. await delay(1e3);
  2844. }
  2845. }
  2846. }
  2847. return Promise.all(prom).then(() => true);
  2848. } catch (error) {
  2849. throwError(error, 'Twitch.toggle');
  2850. return false;
  2851. }
  2852. }
  2853. }
  2854. async function Twitch_verifyAuth2() {
  2855. try {
  2856. const logStatus = scripts_echoLog({
  2857. text: i18n('verifyingAuth', 'Twitch')
  2858. });
  2859. const {
  2860. result,
  2861. statusText,
  2862. status,
  2863. data
  2864. } = await tools_httpRequest({
  2865. url: 'https://gql.twitch.tv/gql',
  2866. method: 'POST',
  2867. dataType: 'json',
  2868. headers: {
  2869. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2870. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2871. },
  2872. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2873. });
  2874. if (result === 'Success') {
  2875. var _data$response, _data$response$, _data$response$$data;
  2876. 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) {
  2877. logStatus.success();
  2878. return true;
  2879. }
  2880. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2881. return false;
  2882. }
  2883. logStatus.error(`${result}:${statusText}(${status})`);
  2884. return false;
  2885. } catch (error) {
  2886. throwError(error, 'Twitch.verifyAuth');
  2887. return false;
  2888. }
  2889. }
  2890. async function Twitch_updateAuth2() {
  2891. try {
  2892. const logStatus = scripts_echoLog({
  2893. text: i18n('updatingAuth', 'Twitch')
  2894. });
  2895. return await new Promise(resolve => {
  2896. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2897. active: true,
  2898. insert: true,
  2899. setParent: true
  2900. });
  2901. newTab.onclose = async () => {
  2902. const auth = GM_getValue('twitchAuth');
  2903. if (auth) {
  2904. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2905. logStatus.success();
  2906. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2907. } else {
  2908. logStatus.error('Error: Update twitch auth failed!');
  2909. resolve(false);
  2910. }
  2911. };
  2912. });
  2913. } catch (error) {
  2914. throwError(error, 'Twitch.updateAuth');
  2915. return false;
  2916. }
  2917. }
  2918. async function _toggleChannel2(_ref2) {
  2919. let {
  2920. name,
  2921. doTask = true
  2922. } = _ref2;
  2923. try {
  2924. if (!doTask && this.whiteList.channels.includes(name)) {
  2925. scripts_echoLog({
  2926. type: 'whiteList',
  2927. text: 'Twitch.unfollowChannel',
  2928. id: name
  2929. });
  2930. return true;
  2931. }
  2932. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2933. if (!channelId) {
  2934. return false;
  2935. }
  2936. const logStatus = scripts_echoLog({
  2937. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2938. text: name
  2939. });
  2940. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2941. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2942. const {
  2943. result,
  2944. statusText,
  2945. status,
  2946. data
  2947. } = await tools_httpRequest({
  2948. url: 'https://gql.twitch.tv/gql',
  2949. method: 'POST',
  2950. dataType: 'json',
  2951. headers: {
  2952. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2953. },
  2954. data: doTask ? followData : unfollowData
  2955. });
  2956. if (result === 'Success') {
  2957. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2958. logStatus.success();
  2959. if (doTask) {
  2960. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2961. }
  2962. return true;
  2963. }
  2964. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2965. return false;
  2966. }
  2967. logStatus.error(`${result}:${statusText}(${status})`);
  2968. return false;
  2969. } catch (error) {
  2970. throwError(error, 'Twitch.toggleChannel');
  2971. return false;
  2972. }
  2973. }
  2974. async function _getChannelId2(name) {
  2975. try {
  2976. const logStatus = scripts_echoLog({
  2977. type: 'gettingTwitchChannelId',
  2978. text: name
  2979. });
  2980. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  2981. if (channelId) {
  2982. logStatus.success();
  2983. return channelId;
  2984. }
  2985. const {
  2986. result,
  2987. statusText,
  2988. status,
  2989. data
  2990. } = await tools_httpRequest({
  2991. url: 'https://gql.twitch.tv/gql',
  2992. method: 'POST',
  2993. headers: {
  2994. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2995. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2996. },
  2997. responseType: 'json',
  2998. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  2999. });
  3000. if (result === 'Success') {
  3001. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3002. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3003. 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);
  3004. if (channelId) {
  3005. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3006. logStatus.success();
  3007. return channelId;
  3008. }
  3009. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3010. return false;
  3011. }
  3012. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3013. return false;
  3014. }
  3015. logStatus.error(`${result}:${statusText}(${status})`);
  3016. return false;
  3017. } catch (error) {
  3018. throwError(error, 'Twitch.getChannelId');
  3019. return false;
  3020. }
  3021. }
  3022. function Twitch_setCache2(name, id) {
  3023. try {
  3024. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3025. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3026. } catch (error) {
  3027. throwError(error, 'Twitch.setCache');
  3028. }
  3029. }
  3030. const social_Twitch = Twitch;
  3031. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3032. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3033. privateSet.add(obj);
  3034. }
  3035. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3036. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3037. privateMap.set(obj, value);
  3038. }
  3039. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3040. if (privateCollection.has(obj)) {
  3041. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3042. }
  3043. }
  3044. function Twitter_defineProperty(obj, key, value) {
  3045. if (key in obj) {
  3046. Object.defineProperty(obj, key, {
  3047. value: value,
  3048. enumerable: true,
  3049. configurable: true,
  3050. writable: true
  3051. });
  3052. } else {
  3053. obj[key] = value;
  3054. }
  3055. return obj;
  3056. }
  3057. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3058. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3059. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3060. return value;
  3061. }
  3062. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3063. if (descriptor.set) {
  3064. descriptor.set.call(receiver, value);
  3065. } else {
  3066. if (!descriptor.writable) {
  3067. throw new TypeError('attempted to set read only private field');
  3068. }
  3069. descriptor.value = value;
  3070. }
  3071. }
  3072. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3073. if (!privateSet.has(receiver)) {
  3074. throw new TypeError('attempted to get private field on non-instance');
  3075. }
  3076. return fn;
  3077. }
  3078. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3079. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3080. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3081. }
  3082. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3083. if (!privateMap.has(receiver)) {
  3084. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3085. }
  3086. return privateMap.get(receiver);
  3087. }
  3088. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3089. if (descriptor.get) {
  3090. return descriptor.get.call(receiver);
  3091. }
  3092. return descriptor.value;
  3093. }
  3094. const Twitter_defaultTasks = {
  3095. users: [],
  3096. retweets: [],
  3097. likes: []
  3098. };
  3099. var _verifyId = new WeakMap();
  3100. var Twitter_auth = new WeakMap();
  3101. var Twitter_cache = new WeakMap();
  3102. var Twitter_initialized = new WeakMap();
  3103. var Twitter_verifyAuth = new WeakSet();
  3104. var Twitter_updateAuth = new WeakSet();
  3105. var _toggleUser = new WeakSet();
  3106. var _toggleRetweet = new WeakSet();
  3107. var Twitter_setCache = new WeakSet();
  3108. class Twitter extends social_Social {
  3109. constructor() {
  3110. var _GM_getValue;
  3111. super(...arguments);
  3112. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3113. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3114. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3115. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3116. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3117. Twitter_defineProperty(this, 'tasks', {
  3118. ...Twitter_defaultTasks
  3119. });
  3120. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || {
  3121. ...Twitter_defaultTasks
  3122. });
  3123. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3124. writable: true,
  3125. value: globalOptions.other.twitterVerifyId
  3126. });
  3127. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3128. writable: true,
  3129. value: GM_getValue('twitterAuth') || {}
  3130. });
  3131. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3132. writable: true,
  3133. value: GM_getValue('twitterCache') || {}
  3134. });
  3135. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3136. writable: true,
  3137. value: false
  3138. });
  3139. }
  3140. async init() {
  3141. try {
  3142. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3143. return true;
  3144. }
  3145. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3146. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3147. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3148. return true;
  3149. }
  3150. return false;
  3151. }
  3152. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3153. if (isVerified) {
  3154. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3155. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3156. return true;
  3157. }
  3158. GM_setValue('twitterAuth', null);
  3159. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3160. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3161. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3162. return true;
  3163. }
  3164. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3165. return false;
  3166. } catch (error) {
  3167. throwError(error, 'Twitter.init');
  3168. return false;
  3169. }
  3170. }
  3171. async userName2id(name) {
  3172. try {
  3173. const logStatus = scripts_echoLog({
  3174. type: 'gettingTwitterUserId',
  3175. text: name
  3176. });
  3177. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3178. if (userId) {
  3179. logStatus.success();
  3180. return userId;
  3181. }
  3182. const {
  3183. result,
  3184. statusText,
  3185. status,
  3186. data
  3187. } = await tools_httpRequest({
  3188. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3189. method: 'GET',
  3190. headers: {
  3191. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3192. 'content-type': 'application/json'
  3193. },
  3194. responseType: 'json',
  3195. anonymous: true
  3196. });
  3197. if (result === 'Success') {
  3198. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3199. var _response, _response$data, _response$data$user;
  3200. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3201. if (!response) {
  3202. try {
  3203. response = JSON.parse(data.responseText);
  3204. } catch (error) {
  3205. response = null;
  3206. }
  3207. }
  3208. 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);
  3209. if (userId) {
  3210. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3211. logStatus.success();
  3212. return userId;
  3213. }
  3214. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3215. return false;
  3216. }
  3217. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3218. return false;
  3219. }
  3220. logStatus.error(`${result}:${statusText}(${status})`);
  3221. return false;
  3222. } catch (error) {
  3223. throwError(error, 'Twitter.getUserId');
  3224. return false;
  3225. }
  3226. }
  3227. async toggle(_ref) {
  3228. let {
  3229. doTask = true,
  3230. userLinks = [],
  3231. retweetLinks = []
  3232. } = _ref;
  3233. try {
  3234. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3235. scripts_echoLog({
  3236. text: i18n('needInit')
  3237. });
  3238. return false;
  3239. }
  3240. const prom = [];
  3241. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3242. scripts_echoLog({
  3243. type: 'globalOptionsSkip',
  3244. text: 'twitter.users'
  3245. });
  3246. } else {
  3247. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3248. var _link$match;
  3249. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3250. });
  3251. if (realUsers.length > 0) {
  3252. for (const user of realUsers) {
  3253. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3254. name: user,
  3255. doTask: doTask
  3256. }));
  3257. await delay(1e3);
  3258. }
  3259. }
  3260. }
  3261. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3262. scripts_echoLog({
  3263. type: 'globalOptionsSkip',
  3264. text: 'twitter.retweets'
  3265. });
  3266. } else {
  3267. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3268. var _link$match2;
  3269. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3270. });
  3271. if (realRetweets.length > 0) {
  3272. for (const retweet of realRetweets) {
  3273. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3274. retweetId: retweet,
  3275. doTask: doTask
  3276. }));
  3277. await delay(1e3);
  3278. }
  3279. }
  3280. }
  3281. return Promise.all(prom).then(() => true);
  3282. } catch (error) {
  3283. throwError(error, 'Twitter.toggle');
  3284. return false;
  3285. }
  3286. }
  3287. }
  3288. async function Twitter_verifyAuth2() {
  3289. try {
  3290. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3291. name: 'verify',
  3292. doTask: true,
  3293. verify: true
  3294. });
  3295. } catch (error) {
  3296. throwError(error, 'Twitter.verifyAuth');
  3297. return false;
  3298. }
  3299. }
  3300. async function Twitter_updateAuth2() {
  3301. try {
  3302. const logStatus = scripts_echoLog({
  3303. text: i18n('updatingAuth', 'Twitter')
  3304. });
  3305. return await new Promise(resolve => {
  3306. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3307. active: true,
  3308. insert: true,
  3309. setParent: true
  3310. });
  3311. newTab.onclose = async () => {
  3312. const auth = GM_getValue('twitterAuth');
  3313. if (auth) {
  3314. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3315. logStatus.success();
  3316. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3317. } else {
  3318. logStatus.error('Error: Update twitter auth failed!');
  3319. resolve(false);
  3320. }
  3321. };
  3322. });
  3323. } catch (error) {
  3324. throwError(error, 'Twitter.updateToken');
  3325. return false;
  3326. }
  3327. }
  3328. async function _toggleUser2(_ref2) {
  3329. let {
  3330. name,
  3331. doTask = true,
  3332. verify = false
  3333. } = _ref2;
  3334. try {
  3335. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3336. scripts_echoLog({
  3337. type: 'whiteList',
  3338. text: 'Twitter.unfollowUser',
  3339. id: name
  3340. });
  3341. return true;
  3342. }
  3343. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3344. if (!userId) {
  3345. return false;
  3346. }
  3347. const logStatus = verify ? scripts_echoLog({
  3348. text: i18n('verifyingAuth', 'Twitter')
  3349. }) : scripts_echoLog({
  3350. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3351. text: name
  3352. });
  3353. const {
  3354. result,
  3355. statusText,
  3356. status,
  3357. data
  3358. } = await tools_httpRequest({
  3359. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3360. method: 'POST',
  3361. headers: {
  3362. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3363. 'Content-Type': 'application/x-www-form-urlencoded',
  3364. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3365. },
  3366. responseType: 'json',
  3367. data: $.param({
  3368. include_profile_interstitial_type: 1,
  3369. include_blocking: 1,
  3370. include_blocked_by: 1,
  3371. include_followed_by: 1,
  3372. include_want_retweets: 1,
  3373. include_mute_edge: 1,
  3374. include_can_dm: 1,
  3375. include_can_media_tag: 1,
  3376. skip_status: 1,
  3377. id: userId
  3378. })
  3379. });
  3380. if (result === 'Success') {
  3381. var _data$response, _data$response$errors, _data$response$errors2;
  3382. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3383. logStatus.success();
  3384. if (doTask && !verify) {
  3385. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3386. }
  3387. return true;
  3388. }
  3389. 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) {
  3390. logStatus.success();
  3391. return true;
  3392. }
  3393. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3394. return false;
  3395. }
  3396. logStatus.error(`${result}:${statusText}(${status})`);
  3397. return false;
  3398. } catch (error) {
  3399. throwError(error, 'Twitter.toggleUser');
  3400. return false;
  3401. }
  3402. }
  3403. async function _toggleRetweet2(_ref3) {
  3404. let {
  3405. retweetId,
  3406. doTask = true
  3407. } = _ref3;
  3408. try {
  3409. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3410. scripts_echoLog({
  3411. type: 'whiteList',
  3412. text: 'Twitter.unretweet',
  3413. id: retweetId
  3414. });
  3415. return true;
  3416. }
  3417. const logStatus = scripts_echoLog({
  3418. type: `${doTask ? '' : 'un'}retweetting`,
  3419. text: retweetId
  3420. });
  3421. const {
  3422. result,
  3423. statusText,
  3424. status,
  3425. data
  3426. } = await tools_httpRequest({
  3427. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3428. method: 'POST',
  3429. headers: {
  3430. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3431. 'Content-Type': 'application/x-www-form-urlencoded',
  3432. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3433. },
  3434. data: $.param({
  3435. tweet_mode: 'extended',
  3436. id: retweetId
  3437. }),
  3438. responseType: 'json'
  3439. });
  3440. if (result === 'Success') {
  3441. var _data$response2, _data$response2$error, _data$response2$error2;
  3442. 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) {
  3443. logStatus.success();
  3444. if (doTask) {
  3445. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3446. }
  3447. return true;
  3448. }
  3449. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3450. return false;
  3451. }
  3452. logStatus.error(`${result}:${statusText}(${status})`);
  3453. return false;
  3454. } catch (error) {
  3455. throwError(error, 'Twitter.toggleRetweet');
  3456. return false;
  3457. }
  3458. }
  3459. function Twitter_setCache2(name, id) {
  3460. try {
  3461. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3462. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3463. } catch (error) {
  3464. throwError(error, 'Twitter.setCache');
  3465. }
  3466. }
  3467. const social_Twitter = Twitter;
  3468. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3469. Vk_checkPrivateRedeclaration(obj, privateSet);
  3470. privateSet.add(obj);
  3471. }
  3472. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3473. Vk_checkPrivateRedeclaration(obj, privateMap);
  3474. privateMap.set(obj, value);
  3475. }
  3476. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3477. if (privateCollection.has(obj)) {
  3478. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3479. }
  3480. }
  3481. function Vk_defineProperty(obj, key, value) {
  3482. if (key in obj) {
  3483. Object.defineProperty(obj, key, {
  3484. value: value,
  3485. enumerable: true,
  3486. configurable: true,
  3487. writable: true
  3488. });
  3489. } else {
  3490. obj[key] = value;
  3491. }
  3492. return obj;
  3493. }
  3494. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3495. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3496. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3497. return value;
  3498. }
  3499. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3500. if (descriptor.set) {
  3501. descriptor.set.call(receiver, value);
  3502. } else {
  3503. if (!descriptor.writable) {
  3504. throw new TypeError('attempted to set read only private field');
  3505. }
  3506. descriptor.value = value;
  3507. }
  3508. }
  3509. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3510. if (!privateSet.has(receiver)) {
  3511. throw new TypeError('attempted to get private field on non-instance');
  3512. }
  3513. return fn;
  3514. }
  3515. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3516. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3517. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3518. }
  3519. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3520. if (!privateMap.has(receiver)) {
  3521. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3522. }
  3523. return privateMap.get(receiver);
  3524. }
  3525. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3526. if (descriptor.get) {
  3527. return descriptor.get.call(receiver);
  3528. }
  3529. return descriptor.value;
  3530. }
  3531. const Vk_defaultTasks = {
  3532. names: []
  3533. };
  3534. var _username = new WeakMap();
  3535. var Vk_cache = new WeakMap();
  3536. var Vk_initialized = new WeakMap();
  3537. var Vk_verifyAuth = new WeakSet();
  3538. var _toggleGroup = new WeakSet();
  3539. var _togglePublic = new WeakSet();
  3540. var _sendWall = new WeakSet();
  3541. var _deleteWall = new WeakSet();
  3542. var _getId = new WeakSet();
  3543. var _toggleVk = new WeakSet();
  3544. var Vk_setCache = new WeakSet();
  3545. class Vk extends social_Social {
  3546. constructor() {
  3547. var _GM_getValue;
  3548. super(...arguments);
  3549. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3550. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3551. Vk_classPrivateMethodInitSpec(this, _getId);
  3552. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3553. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3554. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3555. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3556. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3557. Vk_defineProperty(this, 'tasks', {
  3558. ...Vk_defaultTasks
  3559. });
  3560. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || {
  3561. ...Vk_defaultTasks
  3562. });
  3563. Vk_classPrivateFieldInitSpec(this, _username, {
  3564. writable: true,
  3565. value: ''
  3566. });
  3567. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3568. writable: true,
  3569. value: GM_getValue('vkCache') || {}
  3570. });
  3571. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3572. writable: true,
  3573. value: false
  3574. });
  3575. }
  3576. async init() {
  3577. try {
  3578. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3579. return true;
  3580. }
  3581. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3582. if (isVerified) {
  3583. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3584. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3585. return true;
  3586. }
  3587. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3588. return false;
  3589. } catch (error) {
  3590. throwError(error, 'Vk.init');
  3591. return false;
  3592. }
  3593. }
  3594. async toggle(_ref) {
  3595. let {
  3596. doTask = true,
  3597. nameLinks = []
  3598. } = _ref;
  3599. try {
  3600. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3601. scripts_echoLog({
  3602. text: i18n('needInit')
  3603. });
  3604. return false;
  3605. }
  3606. const prom = [];
  3607. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3608. scripts_echoLog({
  3609. type: 'globalOptionsSkip',
  3610. text: 'vk.names'
  3611. });
  3612. } else {
  3613. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3614. var _link$match;
  3615. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3616. });
  3617. if (realNames.length > 0) {
  3618. for (const name of realNames) {
  3619. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3620. name: name,
  3621. doTask: doTask
  3622. }));
  3623. await delay(1e3);
  3624. }
  3625. }
  3626. }
  3627. return Promise.all(prom).then(() => true);
  3628. } catch (error) {
  3629. throwError(error, 'Vk.toggle');
  3630. return false;
  3631. }
  3632. }
  3633. }
  3634. async function Vk_verifyAuth2() {
  3635. try {
  3636. const logStatus = scripts_echoLog({
  3637. text: i18n('verifyAuth', 'Vk')
  3638. });
  3639. const {
  3640. result,
  3641. statusText,
  3642. status,
  3643. data
  3644. } = await tools_httpRequest({
  3645. url: 'https://vk.com/im',
  3646. method: 'GET'
  3647. });
  3648. if (result === 'Success') {
  3649. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3650. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3651. return false;
  3652. }
  3653. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3654. var _data$responseText$ma;
  3655. 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]) || '');
  3656. logStatus.success();
  3657. return true;
  3658. }
  3659. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3660. return false;
  3661. }
  3662. logStatus.error(`${result}:${statusText}(${status})`);
  3663. return false;
  3664. } catch (error) {
  3665. throwError(error, 'Vk.verifyAuth');
  3666. return false;
  3667. }
  3668. }
  3669. async function _toggleGroup2(name, dataParam) {
  3670. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3671. try {
  3672. const logStatus = scripts_echoLog({
  3673. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3674. text: name
  3675. });
  3676. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3677. logStatus.success();
  3678. return true;
  3679. }
  3680. const reqData = {
  3681. act: doTask ? 'enter' : 'leave',
  3682. al: 1,
  3683. gid: dataParam.groupId,
  3684. hash: dataParam.groupHash
  3685. };
  3686. if (doTask) {
  3687. reqData.context = '_';
  3688. }
  3689. const {
  3690. result,
  3691. statusText,
  3692. status,
  3693. data
  3694. } = await tools_httpRequest({
  3695. url: 'https://vk.com/al_groups.php',
  3696. method: 'POST',
  3697. headers: {
  3698. origin: 'https://vk.com',
  3699. referer: `https://vk.com/${name}`,
  3700. 'content-type': 'application/x-www-form-urlencoded'
  3701. },
  3702. data: $.param(reqData)
  3703. });
  3704. if (result === 'Success') {
  3705. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3706. logStatus.success();
  3707. if (doTask) {
  3708. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3709. }
  3710. return true;
  3711. }
  3712. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3713. return false;
  3714. }
  3715. logStatus.error(`${result}:${statusText}(${status})`);
  3716. return false;
  3717. } catch (error) {
  3718. throwError(error, 'Vk.toggleGroup');
  3719. return false;
  3720. }
  3721. }
  3722. async function _togglePublic2(name, dataParam) {
  3723. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3724. try {
  3725. const logStatus = scripts_echoLog({
  3726. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3727. text: name
  3728. });
  3729. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3730. logStatus.success();
  3731. return true;
  3732. }
  3733. const {
  3734. result,
  3735. statusText,
  3736. status,
  3737. data
  3738. } = await tools_httpRequest({
  3739. url: 'https://vk.com/al_public.php',
  3740. method: 'POST',
  3741. headers: {
  3742. origin: 'https://vk.com',
  3743. referer: `https://vk.com/${name}`,
  3744. 'content-type': 'application/x-www-form-urlencoded'
  3745. },
  3746. data: $.param({
  3747. act: doTask ? 'a_enter' : 'a_leave',
  3748. al: 1,
  3749. pid: dataParam.publicPid,
  3750. hash: dataParam.publicHash
  3751. })
  3752. });
  3753. if (result === 'Success') {
  3754. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3755. logStatus.success();
  3756. if (doTask) {
  3757. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3758. }
  3759. return true;
  3760. }
  3761. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3762. return false;
  3763. }
  3764. logStatus.error(`${result}:${statusText}(${status})`);
  3765. return false;
  3766. } catch (error) {
  3767. throwError(error, 'Vk.togglePublic');
  3768. return false;
  3769. }
  3770. }
  3771. async function _sendWall2(name) {
  3772. try {
  3773. const logStatus = scripts_echoLog({
  3774. type: 'sendingVkWall',
  3775. text: name
  3776. });
  3777. const {
  3778. result,
  3779. statusText,
  3780. status,
  3781. data
  3782. } = await tools_httpRequest({
  3783. url: 'https://vk.com/like.php',
  3784. method: 'POST',
  3785. headers: {
  3786. origin: 'https://vk.com',
  3787. referer: `https://vk.com/${name}`,
  3788. 'content-type': 'application/x-www-form-urlencoded'
  3789. },
  3790. data: $.param({
  3791. act: 'publish_box',
  3792. al: 1,
  3793. object: name
  3794. })
  3795. });
  3796. if (result === 'Success') {
  3797. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3798. var _data$responseText$ma2;
  3799. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3800. if (hash) {
  3801. const {
  3802. result: resultR,
  3803. statusText: statusTextR,
  3804. status: statusR,
  3805. data: dataR
  3806. } = await tools_httpRequest({
  3807. url: 'https://vk.com/like.php',
  3808. method: 'POST',
  3809. headers: {
  3810. origin: 'https://vk.com',
  3811. referer: `https://vk.com/${name}`,
  3812. 'content-type': 'application/x-www-form-urlencoded'
  3813. },
  3814. data: $.param({
  3815. Message: '',
  3816. act: 'a_do_publish',
  3817. al: 1,
  3818. close_comments: 0,
  3819. friends_only: 0,
  3820. from: 'box',
  3821. hash: hash,
  3822. list: '',
  3823. mark_as_ads: 0,
  3824. mute_notifications: 0,
  3825. object: name,
  3826. ret_data: 1,
  3827. to: 0
  3828. })
  3829. });
  3830. if (resultR === 'Success') {
  3831. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3832. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3833. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3834. 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) {
  3835. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3836. logStatus.success();
  3837. 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);
  3838. 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);
  3839. if (postId && ownerId) {
  3840. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3841. }
  3842. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3843. return true;
  3844. }
  3845. }
  3846. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3847. return false;
  3848. }
  3849. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3850. return false;
  3851. }
  3852. logStatus.error('Error: Get "hash" failed');
  3853. return false;
  3854. }
  3855. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3856. return false;
  3857. }
  3858. logStatus.error(`${result}:${statusText}(${status})`);
  3859. return false;
  3860. } catch (error) {
  3861. throwError(error, 'Vk.sendWall');
  3862. return false;
  3863. }
  3864. }
  3865. async function _deleteWall2(name, dataParams) {
  3866. try {
  3867. const logStatus = scripts_echoLog({
  3868. type: 'deletingVkWall',
  3869. text: name
  3870. });
  3871. const {
  3872. result,
  3873. statusText,
  3874. status,
  3875. data
  3876. } = await tools_httpRequest({
  3877. url: 'https://vk.com/al_wall.php?act=delete',
  3878. method: 'POST',
  3879. headers: {
  3880. origin: 'https://vk.com',
  3881. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3882. 'content-type': 'application/x-www-form-urlencoded'
  3883. },
  3884. data: $.param({
  3885. act: 'delete',
  3886. al: 1,
  3887. confirm: 0,
  3888. from: 'wkview',
  3889. hash: dataParams.wallHash,
  3890. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3891. })
  3892. });
  3893. if (result === 'Success') {
  3894. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3895. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3896. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3897. 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]) {
  3898. logStatus.success();
  3899. return true;
  3900. }
  3901. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3902. return false;
  3903. }
  3904. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3905. return false;
  3906. }
  3907. logStatus.error(`${result}:${statusText}(${status})`);
  3908. return false;
  3909. } catch (error) {
  3910. throwError(error, 'Vk.deleteWall');
  3911. return false;
  3912. }
  3913. }
  3914. async function _getId2(name, doTask) {
  3915. try {
  3916. let url = `https://vk.com/${name}`;
  3917. if (/^wall-/.test(name)) {
  3918. if (doTask) {
  3919. return {
  3920. type: 'sendWall'
  3921. };
  3922. }
  3923. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3924. return {
  3925. type: 'unSupport'
  3926. };
  3927. }
  3928. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3929. }
  3930. const logStatus = scripts_echoLog({
  3931. type: 'gettingVkId',
  3932. text: name
  3933. });
  3934. const {
  3935. result,
  3936. statusText,
  3937. status,
  3938. data
  3939. } = await tools_httpRequest({
  3940. url: url,
  3941. method: 'GET'
  3942. });
  3943. if (result === 'Success') {
  3944. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3945. var _data$responseText$ma3, _data$responseText$ma4;
  3946. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3947. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3948. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3949. const publicJoined = !data.responseText.includes('Public.subscribe');
  3950. if (groupAct && groupId && groupHash) {
  3951. logStatus.success();
  3952. return {
  3953. groupAct: groupAct,
  3954. groupId: groupId,
  3955. groupHash: groupHash,
  3956. type: 'group'
  3957. };
  3958. } else if (publicHash && publicPid) {
  3959. logStatus.success();
  3960. return {
  3961. publicHash: publicHash,
  3962. publicPid: publicPid,
  3963. publicJoined: publicJoined,
  3964. type: 'public'
  3965. };
  3966. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3967. var _data$responseText$ma5;
  3968. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3969. if (wallHash) {
  3970. logStatus.success();
  3971. return {
  3972. type: 'deleteWall',
  3973. wallHash: wallHash
  3974. };
  3975. }
  3976. } else if (name.includes('wall') && doTask) {
  3977. logStatus.success();
  3978. return {
  3979. type: 'sendWall'
  3980. };
  3981. }
  3982. logStatus.error('Error: Parameters not found!');
  3983. return false;
  3984. }
  3985. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3986. return false;
  3987. }
  3988. logStatus.error(`${result}:${statusText}(${status})`);
  3989. return false;
  3990. } catch (error) {
  3991. throwError(error, 'Vk.getId');
  3992. return false;
  3993. }
  3994. }
  3995. async function _toggleVk2(_ref2) {
  3996. let {
  3997. name,
  3998. doTask = true
  3999. } = _ref2;
  4000. try {
  4001. if (!doTask && this.whiteList.names.includes(name)) {
  4002. scripts_echoLog({
  4003. type: 'whiteList',
  4004. text: 'Vk.undoTask',
  4005. id: name
  4006. });
  4007. return true;
  4008. }
  4009. const formatName = name.replace(/\/$/, '');
  4010. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4011. if (!data) {
  4012. return false;
  4013. }
  4014. switch (data.type) {
  4015. case 'group':
  4016. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4017.  
  4018. case 'public':
  4019. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4020.  
  4021. case 'sendWall':
  4022. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4023.  
  4024. case 'deleteWall':
  4025. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4026.  
  4027. default:
  4028. return false;
  4029. }
  4030. } catch (error) {
  4031. throwError(error, 'Vk.toggleVk');
  4032. return false;
  4033. }
  4034. }
  4035. function Vk_setCache2(name, postId) {
  4036. try {
  4037. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4038. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4039. } catch (error) {
  4040. throwError(error, 'Vk.setCache');
  4041. }
  4042. }
  4043. const social_Vk = Vk;
  4044. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4045. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4046. privateSet.add(obj);
  4047. }
  4048. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4049. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4050. privateMap.set(obj, value);
  4051. }
  4052. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4053. if (privateCollection.has(obj)) {
  4054. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4055. }
  4056. }
  4057. function Youtube_defineProperty(obj, key, value) {
  4058. if (key in obj) {
  4059. Object.defineProperty(obj, key, {
  4060. value: value,
  4061. enumerable: true,
  4062. configurable: true,
  4063. writable: true
  4064. });
  4065. } else {
  4066. obj[key] = value;
  4067. }
  4068. return obj;
  4069. }
  4070. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4071. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4072. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4073. return value;
  4074. }
  4075. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4076. if (descriptor.set) {
  4077. descriptor.set.call(receiver, value);
  4078. } else {
  4079. if (!descriptor.writable) {
  4080. throw new TypeError('attempted to set read only private field');
  4081. }
  4082. descriptor.value = value;
  4083. }
  4084. }
  4085. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4086. if (!privateSet.has(receiver)) {
  4087. throw new TypeError('attempted to get private field on non-instance');
  4088. }
  4089. return fn;
  4090. }
  4091. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4092. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4093. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4094. }
  4095. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4096. if (!privateMap.has(receiver)) {
  4097. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4098. }
  4099. return privateMap.get(receiver);
  4100. }
  4101. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4102. if (descriptor.get) {
  4103. return descriptor.get.call(receiver);
  4104. }
  4105. return descriptor.value;
  4106. }
  4107. const Youtube_defaultTasks = {
  4108. channels: [],
  4109. likes: []
  4110. };
  4111. const getInfo = async function(link, type) {
  4112. try {
  4113. const logStatus = scripts_echoLog({
  4114. text: i18n('gettingYtbToken')
  4115. });
  4116. const {
  4117. result,
  4118. statusText,
  4119. status,
  4120. data
  4121. } = await tools_httpRequest({
  4122. url: link,
  4123. method: 'GET'
  4124. });
  4125. if (result === 'Success') {
  4126. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4127. var _data$responseText$ma, _ref;
  4128. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4129. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4130. return {
  4131. needLogin: true
  4132. };
  4133. }
  4134. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4135. 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]) || '{}';
  4136. const {
  4137. client,
  4138. request
  4139. } = JSON.parse(context);
  4140. if (apiKey && client && request) {
  4141. client.hl = 'en';
  4142. if (type === 'channel') {
  4143. var _data$responseText$ma2;
  4144. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4145. if (channelId) {
  4146. logStatus.success();
  4147. return {
  4148. params: {
  4149. apiKey: apiKey,
  4150. client: client,
  4151. request: request,
  4152. channelId: channelId
  4153. }
  4154. };
  4155. }
  4156. logStatus.error('Error: Get "channelId" failed!');
  4157. return {};
  4158. } else if (type === 'likeVideo') {
  4159. var _data$responseText$ma3, _data$responseText$ma4;
  4160. 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];
  4161. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4162. if (videoId) {
  4163. logStatus.success();
  4164. return {
  4165. params: {
  4166. apiKey: apiKey,
  4167. client: client,
  4168. request: request,
  4169. videoId: videoId,
  4170. likeParams: likeParams
  4171. }
  4172. };
  4173. }
  4174. logStatus.error('Error: Get "videoId" failed!');
  4175. return {};
  4176. }
  4177. logStatus.error('Error: Unknown type');
  4178. return {};
  4179. }
  4180. logStatus.error('Error: Parameter "apiKey" not found!');
  4181. return {};
  4182. }
  4183. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4184. return {};
  4185. }
  4186. logStatus.error(`${result}:${statusText}(${status})`);
  4187. return {};
  4188. } catch (error) {
  4189. throwError(error, 'Youtube.getInfo');
  4190. return {};
  4191. }
  4192. };
  4193. var Youtube_auth = new WeakMap();
  4194. var Youtube_initialized = new WeakMap();
  4195. var _verifyChannel = new WeakMap();
  4196. var Youtube_verifyAuth = new WeakSet();
  4197. var Youtube_updateAuth = new WeakSet();
  4198. var _getInfo = new WeakSet();
  4199. var Youtube_toggleChannel = new WeakSet();
  4200. var _toggleLikeVideo = new WeakSet();
  4201. class Youtube extends social_Social {
  4202. constructor() {
  4203. var _GM_getValue;
  4204. super(...arguments);
  4205. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4206. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4207. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4208. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4209. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4210. Youtube_defineProperty(this, 'tasks', {
  4211. ...Youtube_defaultTasks
  4212. });
  4213. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || {
  4214. ...Youtube_defaultTasks
  4215. });
  4216. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4217. writable: true,
  4218. value: GM_getValue('youtubeAuth') || {}
  4219. });
  4220. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4221. writable: true,
  4222. value: false
  4223. });
  4224. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4225. writable: true,
  4226. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4227. });
  4228. }
  4229. async init() {
  4230. try {
  4231. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4232. return true;
  4233. }
  4234. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4235. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4236. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4237. return true;
  4238. }
  4239. return false;
  4240. }
  4241. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4242. if (isVerified) {
  4243. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4244. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4245. return true;
  4246. }
  4247. GM_setValue('youtubeAuth', null);
  4248. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4249. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4250. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4251. return true;
  4252. }
  4253. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4254. return false;
  4255. } catch (error) {
  4256. throwError(error, 'Youtube.init');
  4257. return false;
  4258. }
  4259. }
  4260. async toggle(_ref2) {
  4261. let {
  4262. doTask = true,
  4263. channelLinks = [],
  4264. videoLinks = []
  4265. } = _ref2;
  4266. try {
  4267. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4268. scripts_echoLog({
  4269. text: i18n('needInit')
  4270. });
  4271. return false;
  4272. }
  4273. const prom = [];
  4274. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4275. scripts_echoLog({
  4276. type: 'globalOptionsSkip',
  4277. text: 'youtube.channels'
  4278. });
  4279. } else {
  4280. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4281. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4282. var _link$match;
  4283. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4284. }
  4285. return link;
  4286. });
  4287. if (realChannels.length > 0) {
  4288. for (const channel of realChannels) {
  4289. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4290. link: channel,
  4291. doTask: doTask
  4292. }));
  4293. await delay(1e3);
  4294. }
  4295. }
  4296. }
  4297. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4298. scripts_echoLog({
  4299. type: 'globalOptionsSkip',
  4300. text: 'youtube.likes'
  4301. });
  4302. } else {
  4303. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4304. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4305. var _link$match2;
  4306. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4307. }
  4308. return link;
  4309. });
  4310. if (realLikes.length > 0) {
  4311. for (const video of realLikes) {
  4312. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4313. link: video,
  4314. doTask: doTask
  4315. }));
  4316. await delay(1e3);
  4317. }
  4318. }
  4319. }
  4320. return Promise.all(prom).then(() => true);
  4321. } catch (error) {
  4322. throwError(error, 'Youtube.toggle');
  4323. return false;
  4324. }
  4325. }
  4326. }
  4327. async function Youtube_verifyAuth2() {
  4328. try {
  4329. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4330. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4331. doTask: true,
  4332. verify: true
  4333. });
  4334. } catch (error) {
  4335. throwError(error, 'Youtube.verifyAuth');
  4336. return false;
  4337. }
  4338. }
  4339. async function Youtube_updateAuth2() {
  4340. try {
  4341. const logStatus = scripts_echoLog({
  4342. text: i18n('updatingAuth', 'Youtube')
  4343. });
  4344. return await new Promise(resolve => {
  4345. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4346. active: true,
  4347. insert: true,
  4348. setParent: true
  4349. });
  4350. newTab.onclose = async () => {
  4351. const auth = GM_getValue('youtubeAuth');
  4352. if (auth) {
  4353. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4354. logStatus.success();
  4355. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4356. resolve(result);
  4357. });
  4358. } else {
  4359. logStatus.error('Error: Update youtube auth failed!');
  4360. resolve(false);
  4361. }
  4362. };
  4363. });
  4364. } catch (error) {
  4365. throwError(error, 'Discord.updateAuth');
  4366. return false;
  4367. }
  4368. }
  4369. function _getInfo2(link, type) {
  4370. return getInfo(link, type);
  4371. }
  4372. async function Youtube_toggleChannel2(_ref3) {
  4373. let {
  4374. link,
  4375. doTask = true,
  4376. verify = false
  4377. } = _ref3;
  4378. try {
  4379. const {
  4380. params,
  4381. needLogin
  4382. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4383. const {
  4384. apiKey,
  4385. client,
  4386. request,
  4387. channelId
  4388. } = params || {};
  4389. if (needLogin) {
  4390. scripts_echoLog({
  4391. html: i18n('loginYtb')
  4392. });
  4393. return false;
  4394. }
  4395. if (!(apiKey && client && request && channelId)) {
  4396. scripts_echoLog({
  4397. text: '"getYtbToken" failed'
  4398. });
  4399. return false;
  4400. }
  4401. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4402. scripts_echoLog({
  4403. type: 'whiteList',
  4404. text: 'Youtube.unfollowChannel',
  4405. id: channelId
  4406. });
  4407. return true;
  4408. }
  4409. const logStatus = verify ? scripts_echoLog({
  4410. text: i18n('verifyingAuth', 'Youtube')
  4411. }) : scripts_echoLog({
  4412. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4413. text: channelId
  4414. });
  4415. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4416. const {
  4417. result,
  4418. statusText,
  4419. status,
  4420. data
  4421. } = await tools_httpRequest({
  4422. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4423. method: 'POST',
  4424. headers: {
  4425. origin: 'https://www.youtube.com',
  4426. referer: `https://www.youtube.com/channel/${channelId}`,
  4427. 'content-type': 'application/json',
  4428. 'x-goog-authuser': '0',
  4429. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4430. 'x-origin': 'https://www.youtube.com',
  4431. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4432. },
  4433. data: JSON.stringify({
  4434. context: {
  4435. client: client,
  4436. request: {
  4437. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4438. internalExperimentFlags: [],
  4439. consistencyTokenJars: []
  4440. },
  4441. user: {}
  4442. },
  4443. channelIds: [ channelId ],
  4444. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4445. })
  4446. });
  4447. if (result === 'Success') {
  4448. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4449. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4450. logStatus.success();
  4451. if (doTask && !verify) {
  4452. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4453. }
  4454. return true;
  4455. }
  4456. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4457. return false;
  4458. }
  4459. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4460. return false;
  4461. }
  4462. logStatus.error(`${result}:${statusText}(${status})`);
  4463. return false;
  4464. } catch (error) {
  4465. throwError(error, 'Youtube.toggleChannel');
  4466. return false;
  4467. }
  4468. }
  4469. async function _toggleLikeVideo2(_ref4) {
  4470. let {
  4471. link,
  4472. doTask = true
  4473. } = _ref4;
  4474. try {
  4475. const {
  4476. params,
  4477. needLogin
  4478. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4479. const {
  4480. apiKey,
  4481. client,
  4482. request,
  4483. videoId,
  4484. likeParams
  4485. } = params || {};
  4486. if (needLogin) {
  4487. scripts_echoLog({
  4488. html: `${i18n('loginYtb')}`
  4489. });
  4490. return false;
  4491. }
  4492. if (!(apiKey && client && request && videoId && likeParams)) {
  4493. scripts_echoLog({
  4494. text: '"getYtbToken" failed'
  4495. });
  4496. return false;
  4497. }
  4498. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4499. scripts_echoLog({
  4500. type: 'whiteList',
  4501. text: 'Youtube.unlikeVideo',
  4502. id: videoId
  4503. });
  4504. return true;
  4505. }
  4506. const logStatus = scripts_echoLog({
  4507. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4508. text: videoId
  4509. });
  4510. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4511. const likeVideoData = {
  4512. context: {
  4513. client: client,
  4514. request: {
  4515. sessionId: request.sessionId,
  4516. internalExperimentFlags: [],
  4517. consistencyTokenJars: []
  4518. },
  4519. user: {}
  4520. },
  4521. target: {
  4522. videoId: videoId
  4523. }
  4524. };
  4525. if (doTask) {
  4526. if (likeParams) {
  4527. likeVideoData.params = likeParams;
  4528. } else {
  4529. logStatus.error('Empty likeParams');
  4530. return false;
  4531. }
  4532. }
  4533. const {
  4534. result,
  4535. statusText,
  4536. status,
  4537. data
  4538. } = await tools_httpRequest({
  4539. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4540. method: 'POST',
  4541. headers: {
  4542. origin: 'https://www.youtube.com',
  4543. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4544. 'content-type': 'application/json',
  4545. 'x-goog-authuser': '0',
  4546. 'x-goog-visitor-id': client.visitorData,
  4547. 'x-origin': 'https://www.youtube.com',
  4548. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4549. },
  4550. data: JSON.stringify(likeVideoData)
  4551. });
  4552. if (result === 'Success') {
  4553. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4554. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4555. logStatus.success();
  4556. if (doTask) {
  4557. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4558. }
  4559. return true;
  4560. }
  4561. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4562. return false;
  4563. }
  4564. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4565. return false;
  4566. }
  4567. logStatus.error(`${result}:${statusText}(${status})`);
  4568. return false;
  4569. } catch (error) {
  4570. throwError(error, 'Youtube.toggleLikeVideo');
  4571. return false;
  4572. }
  4573. }
  4574. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4575. Steam_checkPrivateRedeclaration(obj, privateSet);
  4576. privateSet.add(obj);
  4577. }
  4578. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4579. Steam_checkPrivateRedeclaration(obj, privateMap);
  4580. privateMap.set(obj, value);
  4581. }
  4582. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4583. if (privateCollection.has(obj)) {
  4584. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4585. }
  4586. }
  4587. function Steam_defineProperty(obj, key, value) {
  4588. if (key in obj) {
  4589. Object.defineProperty(obj, key, {
  4590. value: value,
  4591. enumerable: true,
  4592. configurable: true,
  4593. writable: true
  4594. });
  4595. } else {
  4596. obj[key] = value;
  4597. }
  4598. return obj;
  4599. }
  4600. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4601. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4602. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4603. return value;
  4604. }
  4605. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4606. if (descriptor.set) {
  4607. descriptor.set.call(receiver, value);
  4608. } else {
  4609. if (!descriptor.writable) {
  4610. throw new TypeError('attempted to set read only private field');
  4611. }
  4612. descriptor.value = value;
  4613. }
  4614. }
  4615. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4616. if (!privateSet.has(receiver)) {
  4617. throw new TypeError('attempted to get private field on non-instance');
  4618. }
  4619. return fn;
  4620. }
  4621. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4622. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4623. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4624. }
  4625. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4626. if (!privateMap.has(receiver)) {
  4627. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4628. }
  4629. return privateMap.get(receiver);
  4630. }
  4631. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4632. if (descriptor.get) {
  4633. return descriptor.get.call(receiver);
  4634. }
  4635. return descriptor.value;
  4636. }
  4637. const Steam_defaultTasks = {
  4638. groups: [],
  4639. wishlists: [],
  4640. follows: [],
  4641. forums: [],
  4642. workshops: [],
  4643. workshopVotes: [],
  4644. curators: [],
  4645. curatorLikes: [],
  4646. announcements: []
  4647. };
  4648. var Steam_cache = new WeakMap();
  4649. var Steam_auth = new WeakMap();
  4650. var Steam_initialized = new WeakMap();
  4651. var _area = new WeakMap();
  4652. var _updateStoreAuth = new WeakSet();
  4653. var _updateCommunityAuth = new WeakSet();
  4654. var _getAreaInfo = new WeakSet();
  4655. var _changeArea = new WeakSet();
  4656. var _joinGroup = new WeakSet();
  4657. var _leaveGroup = new WeakSet();
  4658. var _getGroupId = new WeakSet();
  4659. var _addToWishlist = new WeakSet();
  4660. var _removeFromWishlist = new WeakSet();
  4661. var _toggleFollowGame = new WeakSet();
  4662. var _isFollowedGame = new WeakSet();
  4663. var _toggleForum = new WeakSet();
  4664. var _getForumId = new WeakSet();
  4665. var _toggleFavoriteWorkshop = new WeakSet();
  4666. var _getWorkshopAppId = new WeakSet();
  4667. var _voteUpWorkshop = new WeakSet();
  4668. var _toggleCurator = new WeakSet();
  4669. var _toggleCuratorLike = new WeakSet();
  4670. var _getAnnouncementParams = new WeakSet();
  4671. var _likeAnnouncement = new WeakSet();
  4672. var Steam_setCache = new WeakSet();
  4673. class Steam extends social_Social {
  4674. constructor() {
  4675. var _GM_getValue;
  4676. super(...arguments);
  4677. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4678. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4679. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4680. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4681. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4682. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4683. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4684. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4685. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4686. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4687. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4688. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4689. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4690. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4691. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4692. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4693. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4694. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4695. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4696. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4697. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4698. Steam_defineProperty(this, 'tasks', {
  4699. ...Steam_defaultTasks
  4700. });
  4701. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || {
  4702. ...Steam_defaultTasks
  4703. });
  4704. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4705. writable: true,
  4706. value: GM_getValue('steamCache') || {
  4707. group: {},
  4708. forum: {},
  4709. workshop: {},
  4710. curator: {}
  4711. }
  4712. });
  4713. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4714. writable: true,
  4715. value: {}
  4716. });
  4717. Steam_classPrivateFieldInitSpec(this, Steam_initialized, {
  4718. writable: true,
  4719. value: false
  4720. });
  4721. Steam_classPrivateFieldInitSpec(this, _area, {
  4722. writable: true,
  4723. value: 'CN'
  4724. });
  4725. }
  4726. async init() {
  4727. try {
  4728. if (Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4729. return true;
  4730. }
  4731. const isVerified = await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this) && await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this);
  4732. if (isVerified) {
  4733. Steam_classPrivateFieldSet(this, Steam_initialized, true);
  4734. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4735. return true;
  4736. }
  4737. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4738. return false;
  4739. } catch (error) {
  4740. throwError(error, 'Steam.init');
  4741. return false;
  4742. }
  4743. }
  4744. async getCuratorId(path, name) {
  4745. try {
  4746. const logStatus = scripts_echoLog({
  4747. type: 'gettingCuratorId',
  4748. text: `${path}/${name}`
  4749. });
  4750. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4751. if (curatorId) {
  4752. logStatus.success();
  4753. return curatorId;
  4754. }
  4755. const {
  4756. result,
  4757. statusText,
  4758. status,
  4759. data
  4760. } = await tools_httpRequest({
  4761. url: `https://store.steampowered.com/${path}/${name}`,
  4762. method: 'GET',
  4763. headers: {
  4764. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4765. }
  4766. });
  4767. if (result === 'Success') {
  4768. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4769. var _data$responseText$ma;
  4770. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4771. if (curatorId) {
  4772. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4773. logStatus.success();
  4774. return curatorId;
  4775. }
  4776. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4777. return false;
  4778. }
  4779. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4780. return false;
  4781. }
  4782. logStatus.error(`${result}:${statusText}(${status})`);
  4783. return false;
  4784. } catch (error) {
  4785. throwError(error, 'Steam.getCuratorID');
  4786. return false;
  4787. }
  4788. }
  4789. async toggle(_ref) {
  4790. let {
  4791. doTask = true,
  4792. groupLinks = [],
  4793. wishlistLinks = [],
  4794. followLinks = [],
  4795. forumLinks = [],
  4796. workshopLinks = [],
  4797. workshopVoteLinks = [],
  4798. curatorLinks = [],
  4799. curatorLikeLinks = [],
  4800. announcementLinks = []
  4801. } = _ref;
  4802. try {
  4803. if (!Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4804. scripts_echoLog({
  4805. text: i18n('needInit')
  4806. });
  4807. return false;
  4808. }
  4809. const prom = [];
  4810. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4811. scripts_echoLog({
  4812. type: 'globalOptionsSkip',
  4813. text: 'steam.groups'
  4814. });
  4815. } else {
  4816. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4817. var _link$match;
  4818. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4819. });
  4820. if (realGroups.length > 0) {
  4821. for (const group of realGroups) {
  4822. if (doTask) {
  4823. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4824. } else {
  4825. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4826. }
  4827. await delay(1e3);
  4828. }
  4829. }
  4830. }
  4831. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4832. scripts_echoLog({
  4833. type: 'globalOptionsSkip',
  4834. text: 'steam.wishlists'
  4835. });
  4836. } else {
  4837. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4838. var _link$match2;
  4839. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4840. });
  4841. if (realWishlists.length > 0) {
  4842. for (const game of realWishlists) {
  4843. if (doTask) {
  4844. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4845. } else {
  4846. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4847. }
  4848. await delay(1e3);
  4849. }
  4850. }
  4851. }
  4852. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4853. scripts_echoLog({
  4854. type: 'globalOptionsSkip',
  4855. text: 'steam.follows'
  4856. });
  4857. } else {
  4858. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4859. var _link$match3;
  4860. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4861. });
  4862. if (realFollows.length > 0) {
  4863. for (const game of realFollows) {
  4864. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4865. await delay(1e3);
  4866. }
  4867. }
  4868. }
  4869. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4870. scripts_echoLog({
  4871. type: 'globalOptionsSkip',
  4872. text: 'steam.forums'
  4873. });
  4874. } else {
  4875. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4876. var _link$match4;
  4877. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4878. });
  4879. if (realForums.length > 0) {
  4880. for (const forum of realForums) {
  4881. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4882. await delay(1e3);
  4883. }
  4884. }
  4885. }
  4886. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4887. scripts_echoLog({
  4888. type: 'globalOptionsSkip',
  4889. text: 'steam.workshops'
  4890. });
  4891. } else {
  4892. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4893. var _link$match5;
  4894. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4895. });
  4896. if (realWorkshops.length > 0) {
  4897. for (const workshop of realWorkshops) {
  4898. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4899. await delay(1e3);
  4900. }
  4901. }
  4902. }
  4903. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4904. scripts_echoLog({
  4905. type: 'globalOptionsSkip',
  4906. text: 'steam.workshopVotes'
  4907. });
  4908. } else {
  4909. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4910. var _link$match6;
  4911. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4912. });
  4913. if (doTask && realworkshopVotes.length > 0) {
  4914. for (const workshop of realworkshopVotes) {
  4915. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4916. await delay(1e3);
  4917. }
  4918. }
  4919. }
  4920. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4921. scripts_echoLog({
  4922. type: 'globalOptionsSkip',
  4923. text: 'steam.curators'
  4924. });
  4925. } else {
  4926. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4927. var _link$match7;
  4928. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4929. });
  4930. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4931. var _link$match8;
  4932. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4933. });
  4934. if (realCurators.length > 0) {
  4935. for (const curator of realCurators) {
  4936. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4937. await delay(1e3);
  4938. }
  4939. }
  4940. if (realCuratorLikes.length > 0) {
  4941. for (const curatorLike of realCuratorLikes) {
  4942. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4943. await delay(1e3);
  4944. }
  4945. }
  4946. }
  4947. if (doTask && !globalOptions.doTask.steam.announcements) {
  4948. scripts_echoLog({
  4949. type: 'globalOptionsSkip',
  4950. text: 'steam.announcements'
  4951. });
  4952. } else {
  4953. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  4954. var _link$match10;
  4955. if (link.includes('store.steampowered.com')) {
  4956. var _link$match9;
  4957. 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('/');
  4958. }
  4959. 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('/');
  4960. });
  4961. if (doTask && realAnnouncements.length > 0) {
  4962. for (const id of realAnnouncements) {
  4963. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  4964. await delay(1e3);
  4965. }
  4966. }
  4967. }
  4968. return Promise.all(prom).then(async () => {
  4969. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  4970. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  4971. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  4972. }
  4973. return true;
  4974. });
  4975. } catch (error) {
  4976. throwError(error, 'Steam.toggle');
  4977. return false;
  4978. }
  4979. }
  4980. }
  4981. async function _updateStoreAuth2() {
  4982. try {
  4983. const logStatus = scripts_echoLog({
  4984. text: i18n('updatingAuth', i18n('steamStore'))
  4985. });
  4986. const {
  4987. result,
  4988. statusText,
  4989. status,
  4990. data
  4991. } = await tools_httpRequest({
  4992. url: 'https://store.steampowered.com/stats/',
  4993. method: 'GET'
  4994. });
  4995. if (result === 'Success') {
  4996. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4997. var _data$responseText$ma2;
  4998. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  4999. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5000. return false;
  5001. }
  5002. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5003. if (storeSessionID) {
  5004. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5005. logStatus.success();
  5006. return true;
  5007. }
  5008. logStatus.error('Error: Get "sessionID" failed');
  5009. return false;
  5010. }
  5011. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5012. return false;
  5013. }
  5014. logStatus.error(`${result}:${statusText}(${status})`);
  5015. return false;
  5016. } catch (error) {
  5017. throwError(error, 'Steam.updateStoreAuth');
  5018. return false;
  5019. }
  5020. }
  5021. async function _updateCommunityAuth2() {
  5022. try {
  5023. const logStatus = scripts_echoLog({
  5024. text: i18n('updatingAuth', i18n('steamCommunity'))
  5025. });
  5026. const {
  5027. result,
  5028. statusText,
  5029. status,
  5030. data
  5031. } = await tools_httpRequest({
  5032. url: 'https://steamcommunity.com/my',
  5033. method: 'GET'
  5034. });
  5035. if (result === 'Success') {
  5036. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5037. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5038. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5039. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5040. return false;
  5041. }
  5042. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5043. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5044. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5045. if (steam64Id) {
  5046. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5047. }
  5048. if (userName) {
  5049. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5050. }
  5051. if (communitySessionID) {
  5052. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5053. logStatus.success();
  5054. return true;
  5055. }
  5056. logStatus.error('Error: Get "sessionID" failed');
  5057. return false;
  5058. }
  5059. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5060. return false;
  5061. }
  5062. logStatus.error(`${result}:${statusText}(${status})`);
  5063. return false;
  5064. } catch (error) {
  5065. throwError(error, 'Steam.updateCommunityAuth');
  5066. return false;
  5067. }
  5068. }
  5069. async function _getAreaInfo2() {
  5070. try {
  5071. const logStatus = scripts_echoLog({
  5072. text: i18n('gettingAreaInfo')
  5073. });
  5074. const {
  5075. result,
  5076. statusText,
  5077. status,
  5078. data
  5079. } = await tools_httpRequest({
  5080. url: 'https://store.steampowered.com/cart/',
  5081. method: 'GET'
  5082. });
  5083. if (result === 'Success') {
  5084. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5085. var _data$responseText$ma6;
  5086. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5087. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5088. if (currentArea && areas.length > 0) {
  5089. Steam_classPrivateFieldSet(this, _area, currentArea);
  5090. logStatus.success();
  5091. return {
  5092. currentArea: currentArea,
  5093. areas: areas
  5094. };
  5095. }
  5096. logStatus.error('Error: get country info filed');
  5097. return {};
  5098. }
  5099. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5100. return {};
  5101. }
  5102. logStatus.error(`${result}:${statusText}(${status})`);
  5103. return {};
  5104. } catch (error) {
  5105. throwError(error, 'Steam.getAreaInfo');
  5106. return {};
  5107. }
  5108. }
  5109. async function _changeArea2(area) {
  5110. try {
  5111. let aimedArea = area;
  5112. if (!aimedArea) {
  5113. const {
  5114. currentArea,
  5115. areas
  5116. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5117. if (!currentArea || !areas) {
  5118. return false;
  5119. }
  5120. if (currentArea !== 'CN') {
  5121. scripts_echoLog({
  5122. text: 'notNeededChangeArea'
  5123. });
  5124. return 'skip';
  5125. }
  5126. const anotherArea = areas.filter(area => area && area !== 'CN');
  5127. if (!anotherArea || anotherArea.length === 0) {
  5128. scripts_echoLog({
  5129. text: 'noAnotherArea'
  5130. });
  5131. return false;
  5132. }
  5133. [ aimedArea ] = anotherArea;
  5134. }
  5135. const logStatus = scripts_echoLog({
  5136. text: i18n('changingArea', aimedArea)
  5137. });
  5138. const {
  5139. result,
  5140. statusText,
  5141. status,
  5142. data
  5143. } = await tools_httpRequest({
  5144. url: 'https://store.steampowered.com/account/setcountry',
  5145. method: 'POST',
  5146. headers: {
  5147. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5148. },
  5149. data: $.param({
  5150. cc: aimedArea,
  5151. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5152. })
  5153. });
  5154. if (result === 'Success') {
  5155. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5156. const {
  5157. currentArea
  5158. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5159. if (currentArea === aimedArea) {
  5160. logStatus.success();
  5161. return currentArea;
  5162. }
  5163. logStatus.error('Error: change country filed');
  5164. return 'CN';
  5165. }
  5166. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5167. return 'CN';
  5168. }
  5169. logStatus.error(`${result}:${statusText}(${status})`);
  5170. return 'CN';
  5171. } catch (error) {
  5172. throwError(error, 'Steam.changeArea');
  5173. return false;
  5174. }
  5175. }
  5176. async function _joinGroup2(groupName) {
  5177. try {
  5178. const logStatus = scripts_echoLog({
  5179. type: 'joiningSteamGroup',
  5180. text: groupName
  5181. });
  5182. const {
  5183. result,
  5184. statusText,
  5185. status,
  5186. data
  5187. } = await tools_httpRequest({
  5188. url: `https://steamcommunity.com/groups/${groupName}`,
  5189. method: 'POST',
  5190. headers: {
  5191. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5192. },
  5193. data: $.param({
  5194. action: 'join',
  5195. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5196. })
  5197. });
  5198. if (result === 'Success') {
  5199. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5200. logStatus.success();
  5201. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5202. return true;
  5203. }
  5204. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5205. return false;
  5206. }
  5207. logStatus.error(`${result}:${statusText}(${status})`);
  5208. return false;
  5209. } catch (error) {
  5210. throwError(error, 'Steam.joinGroup');
  5211. return false;
  5212. }
  5213. }
  5214. async function _leaveGroup2(groupName) {
  5215. try {
  5216. if (this.whiteList.groups.includes(groupName)) {
  5217. scripts_echoLog({
  5218. type: 'whiteList',
  5219. text: 'Steam.leaveGroup',
  5220. id: groupName
  5221. });
  5222. return true;
  5223. }
  5224. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5225. if (!groupId) {
  5226. return false;
  5227. }
  5228. const logStatus = scripts_echoLog({
  5229. type: 'leavingSteamGroup',
  5230. text: groupName
  5231. });
  5232. const {
  5233. result,
  5234. statusText,
  5235. status,
  5236. data
  5237. } = await tools_httpRequest({
  5238. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5239. method: 'POST',
  5240. headers: {
  5241. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5242. },
  5243. data: $.param({
  5244. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5245. action: 'leaveGroup',
  5246. groupId: groupId
  5247. })
  5248. });
  5249. if (result === 'Success') {
  5250. 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) {
  5251. logStatus.success();
  5252. return true;
  5253. }
  5254. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5255. return false;
  5256. }
  5257. logStatus.error(`${result}:${statusText}(${status})`);
  5258. return false;
  5259. } catch (error) {
  5260. throwError(error, 'Steam.leaveGroup');
  5261. return false;
  5262. }
  5263. }
  5264. async function _getGroupId2(groupName) {
  5265. try {
  5266. const logStatus = scripts_echoLog({
  5267. type: 'gettingSteamGroupId',
  5268. text: groupName
  5269. });
  5270. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5271. if (groupId) {
  5272. logStatus.success();
  5273. return groupId;
  5274. }
  5275. const {
  5276. result,
  5277. statusText,
  5278. status,
  5279. data
  5280. } = await tools_httpRequest({
  5281. url: `https://steamcommunity.com/groups/${groupName}`,
  5282. method: 'GET',
  5283. headers: {
  5284. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5285. }
  5286. });
  5287. if (result === 'Success') {
  5288. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5289. var _data$responseText$ma7;
  5290. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5291. if (groupId) {
  5292. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5293. logStatus.success();
  5294. return groupId;
  5295. }
  5296. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5297. return false;
  5298. }
  5299. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5300. return false;
  5301. }
  5302. logStatus.error(`${result}:${statusText}(${status})`);
  5303. return false;
  5304. } catch (error) {
  5305. throwError(error, 'Steam.getGroupID');
  5306. return false;
  5307. }
  5308. }
  5309. async function _addToWishlist2(gameId) {
  5310. try {
  5311. var _data$response;
  5312. const logStatus = scripts_echoLog({
  5313. type: 'addingToWishlist',
  5314. text: gameId
  5315. });
  5316. const {
  5317. result,
  5318. data
  5319. } = await tools_httpRequest({
  5320. url: 'https://store.steampowered.com/api/addtowishlist',
  5321. method: 'POST',
  5322. headers: {
  5323. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5324. },
  5325. data: $.param({
  5326. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5327. appid: gameId
  5328. }),
  5329. dataType: 'json'
  5330. });
  5331. 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) {
  5332. logStatus.success();
  5333. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5334. return true;
  5335. }
  5336. const {
  5337. result: resultR,
  5338. statusText: statusTextR,
  5339. status: statusR,
  5340. data: dataR
  5341. } = await tools_httpRequest({
  5342. url: `https://store.steampowered.com/app/${gameId}`,
  5343. method: 'GET'
  5344. });
  5345. if (resultR === 'Success') {
  5346. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5347. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5348. logStatus.warning(i18n('changeAreaNotice'));
  5349. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5350. return false;
  5351. }
  5352. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5353. }
  5354. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5355. logStatus.success();
  5356. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5357. return true;
  5358. } 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"')) {
  5359. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5360. return false;
  5361. }
  5362. logStatus.success();
  5363. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5364. return true;
  5365. }
  5366. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5367. return false;
  5368. }
  5369. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5370. return false;
  5371. } catch (error) {
  5372. throwError(error, 'Steam.addToWishlist');
  5373. return false;
  5374. }
  5375. }
  5376. async function _removeFromWishlist2(gameId) {
  5377. try {
  5378. var _data$response2;
  5379. if (this.whiteList.wishlists.includes(gameId)) {
  5380. scripts_echoLog({
  5381. type: 'whiteList',
  5382. text: 'Steam.removeFromWishlist',
  5383. id: gameId
  5384. });
  5385. return true;
  5386. }
  5387. const logStatus = scripts_echoLog({
  5388. type: 'removingFromWishlist',
  5389. text: gameId
  5390. });
  5391. const {
  5392. result,
  5393. data
  5394. } = await tools_httpRequest({
  5395. url: 'https://store.steampowered.com/api/removefromwishlist',
  5396. method: 'POST',
  5397. headers: {
  5398. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5399. },
  5400. data: $.param({
  5401. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5402. appid: gameId
  5403. }),
  5404. dataType: 'json'
  5405. });
  5406. 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) {
  5407. logStatus.success();
  5408. return true;
  5409. }
  5410. const {
  5411. result: resultR,
  5412. statusText: statusTextR,
  5413. status: statusR,
  5414. data: dataR
  5415. } = await tools_httpRequest({
  5416. url: `https://store.steampowered.com/app/${gameId}`,
  5417. method: 'GET'
  5418. });
  5419. if (resultR === 'Success') {
  5420. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5421. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5422. logStatus.warning(i18n('changeAreaNotice'));
  5423. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5424. if (!result || result === 'CN' || result === 'skip') {
  5425. return false;
  5426. }
  5427. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5428. }
  5429. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5430. logStatus.success();
  5431. return true;
  5432. }
  5433. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5434. return false;
  5435. }
  5436. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5437. return false;
  5438. }
  5439. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5440. return false;
  5441. } catch (error) {
  5442. throwError(error, 'Steam.removeFromWishlist');
  5443. return false;
  5444. }
  5445. }
  5446. async function _toggleFollowGame2(gameId, doTask) {
  5447. try {
  5448. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5449. scripts_echoLog({
  5450. type: 'whiteList',
  5451. text: 'Steam.unfollowGame',
  5452. id: gameId
  5453. });
  5454. return true;
  5455. }
  5456. const logStatus = scripts_echoLog({
  5457. type: `${doTask ? '' : 'un'}followingGame`,
  5458. text: gameId
  5459. });
  5460. const requestData = {
  5461. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5462. appid: gameId
  5463. };
  5464. if (!doTask) {
  5465. requestData.unfollow = '1';
  5466. }
  5467. const {
  5468. result,
  5469. data
  5470. } = await tools_httpRequest({
  5471. url: 'https://store.steampowered.com/explore/followgame/',
  5472. method: 'POST',
  5473. headers: {
  5474. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5475. },
  5476. data: $.param(requestData)
  5477. });
  5478. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5479. logStatus.success();
  5480. return true;
  5481. }
  5482. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5483. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5484. logStatus.warning(i18n('changeAreaNotice'));
  5485. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5486. return false;
  5487. }
  5488. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5489. }
  5490. if (doTask === followed) {
  5491. logStatus.success();
  5492. if (doTask) {
  5493. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5494. }
  5495. return true;
  5496. }
  5497. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5498. return false;
  5499. } catch (error) {
  5500. throwError(error, 'Steam.toggleFollowGame');
  5501. return false;
  5502. }
  5503. }
  5504. async function _isFollowedGame2(gameId) {
  5505. try {
  5506. const {
  5507. result,
  5508. data
  5509. } = await tools_httpRequest({
  5510. url: `https://store.steampowered.com/app/${gameId}`,
  5511. method: 'GET'
  5512. });
  5513. if (result === 'Success') {
  5514. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5515. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5516. return 'areaLocked';
  5517. }
  5518. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5519. return true;
  5520. }
  5521. return false;
  5522. }
  5523. return false;
  5524. }
  5525. return false;
  5526. } catch (error) {
  5527. throwError(error, 'Steam.isFollowedGame');
  5528. return false;
  5529. }
  5530. }
  5531. async function _toggleForum2(gameId) {
  5532. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5533. try {
  5534. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5535. scripts_echoLog({
  5536. type: 'whiteList',
  5537. text: 'Steam.unsubscribForum',
  5538. id: gameId
  5539. });
  5540. return true;
  5541. }
  5542. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5543. if (!forumId) {
  5544. return false;
  5545. }
  5546. const logStatus = scripts_echoLog({
  5547. type: `${doTask ? '' : 'un'}subscribingForum`,
  5548. text: gameId
  5549. });
  5550. const [ id, feature ] = forumId.split('_');
  5551. const {
  5552. result,
  5553. statusText,
  5554. status,
  5555. data
  5556. } = await tools_httpRequest({
  5557. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5558. method: 'POST',
  5559. responseType: 'json',
  5560. headers: {
  5561. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5562. },
  5563. data: $.param({
  5564. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5565. })
  5566. });
  5567. if (result === 'Success') {
  5568. var _data$response3, _data$response4;
  5569. 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)) {
  5570. if (doTask) {
  5571. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5572. }
  5573. logStatus.success();
  5574. return true;
  5575. }
  5576. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5577. return true;
  5578. }
  5579. logStatus.error(`${result}:${statusText}(${status})`);
  5580. return true;
  5581. } catch (error) {
  5582. throwError(error, 'Steam.toggleForum');
  5583. return true;
  5584. }
  5585. }
  5586. async function _getForumId2(gameId) {
  5587. try {
  5588. const logStatus = scripts_echoLog({
  5589. type: 'gettingForumId',
  5590. text: gameId
  5591. });
  5592. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5593. if (forumId) {
  5594. logStatus.success();
  5595. return forumId;
  5596. }
  5597. const {
  5598. result,
  5599. statusText,
  5600. status,
  5601. data
  5602. } = await tools_httpRequest({
  5603. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5604. method: 'GET'
  5605. });
  5606. if (result === 'Success') {
  5607. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5608. var _data$responseText, _data$responseText$ma8;
  5609. 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];
  5610. if (forumId) {
  5611. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5612. logStatus.success();
  5613. return forumId;
  5614. }
  5615. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5616. return false;
  5617. }
  5618. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5619. return false;
  5620. }
  5621. logStatus.error(`${result}:${statusText}(${status})`);
  5622. return false;
  5623. } catch (error) {
  5624. throwError(error, 'Steam.getForumId');
  5625. return false;
  5626. }
  5627. }
  5628. async function _toggleFavoriteWorkshop2(id) {
  5629. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5630. try {
  5631. if (!doTask && this.whiteList.workshops.includes(id)) {
  5632. scripts_echoLog({
  5633. type: 'whiteList',
  5634. text: 'Steam.unfavoriteWorkshop',
  5635. id: id
  5636. });
  5637. return true;
  5638. }
  5639. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5640. if (!appid) {
  5641. return false;
  5642. }
  5643. const logStatus = scripts_echoLog({
  5644. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5645. text: id
  5646. });
  5647. const {
  5648. result,
  5649. statusText,
  5650. status,
  5651. data
  5652. } = await tools_httpRequest({
  5653. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5654. method: 'POST',
  5655. headers: {
  5656. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5657. },
  5658. data: $.param({
  5659. id: id,
  5660. appid: appid,
  5661. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5662. })
  5663. });
  5664. if (result === 'Success') {
  5665. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5666. if (doTask) {
  5667. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5668. }
  5669. logStatus.success();
  5670. return true;
  5671. }
  5672. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5673. return false;
  5674. }
  5675. logStatus.error(`${result}:${statusText}(${status})`);
  5676. return false;
  5677. } catch (error) {
  5678. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5679. return false;
  5680. }
  5681. }
  5682. async function _getWorkshopAppId2(id) {
  5683. try {
  5684. const logStatus = scripts_echoLog({
  5685. type: 'gettingWorkshopAppId',
  5686. text: id
  5687. });
  5688. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5689. if (appId) {
  5690. logStatus.success();
  5691. return appId;
  5692. }
  5693. const {
  5694. result,
  5695. statusText,
  5696. status,
  5697. data
  5698. } = await tools_httpRequest({
  5699. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5700. method: 'GET'
  5701. });
  5702. if (result === 'Success') {
  5703. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5704. var _data$responseText$ma9;
  5705. 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];
  5706. if (appId) {
  5707. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5708. logStatus.success();
  5709. return appId;
  5710. }
  5711. logStatus.error('Error: getWorkshopAppId failed');
  5712. return false;
  5713. }
  5714. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5715. return false;
  5716. }
  5717. logStatus.error(`${result}:${statusText}(${status})`);
  5718. return false;
  5719. } catch (error) {
  5720. throwError(error, 'Steam.getWorkshopAppId');
  5721. return false;
  5722. }
  5723. }
  5724. async function _voteUpWorkshop2(id) {
  5725. try {
  5726. const logStatus = scripts_echoLog({
  5727. type: 'votingUpWorkshop',
  5728. text: id
  5729. });
  5730. const {
  5731. result,
  5732. statusText,
  5733. status,
  5734. data
  5735. } = await tools_httpRequest({
  5736. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5737. method: 'POST',
  5738. responseType: 'json',
  5739. headers: {
  5740. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5741. },
  5742. data: $.param({
  5743. id: id,
  5744. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5745. })
  5746. });
  5747. if (result === 'Success') {
  5748. var _data$response5;
  5749. 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) {
  5750. logStatus.success();
  5751. return true;
  5752. }
  5753. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5754. return true;
  5755. }
  5756. logStatus.error(`${result}:${statusText}(${status})`);
  5757. return true;
  5758. } catch (error) {
  5759. throwError(error, 'Steam.voteupWorkshop');
  5760. return true;
  5761. }
  5762. }
  5763. async function _toggleCurator2(curatorId) {
  5764. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5765. try {
  5766. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5767. scripts_echoLog({
  5768. type: 'whiteList',
  5769. text: 'Steam.unfollowCurator',
  5770. id: curatorId
  5771. });
  5772. return true;
  5773. }
  5774. const logStatus = scripts_echoLog({
  5775. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5776. text: curatorId
  5777. });
  5778. const {
  5779. result,
  5780. statusText,
  5781. status,
  5782. data
  5783. } = await tools_httpRequest({
  5784. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5785. method: 'POST',
  5786. headers: {
  5787. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5788. },
  5789. data: $.param({
  5790. clanid: curatorId,
  5791. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5792. follow: doTask
  5793. }),
  5794. dataType: 'json'
  5795. });
  5796. if (result === 'Success') {
  5797. var _data$response6, _data$response6$succe, _data$response7;
  5798. 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) {
  5799. logStatus.success();
  5800. return true;
  5801. }
  5802. 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})`);
  5803. return false;
  5804. }
  5805. logStatus.error(`${result}:${statusText}(${status})`);
  5806. return false;
  5807. } catch (error) {
  5808. throwError(error, 'Steam.toggleCurator');
  5809. return false;
  5810. }
  5811. }
  5812. async function _toggleCuratorLike2(link) {
  5813. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5814. try {
  5815. const [ path, name ] = link.split('/');
  5816. if (!(path && name)) {
  5817. scripts_echoLog({
  5818. text: i18n('errorLink', link)
  5819. });
  5820. return false;
  5821. }
  5822. const curatorId = await this.getCuratorId(path, name);
  5823. if (curatorId) {
  5824. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5825. }
  5826. return false;
  5827. } catch (error) {
  5828. throwError(error, 'Steam.toggleCuratorLike');
  5829. return false;
  5830. }
  5831. }
  5832. async function _getAnnouncementParams2(appId, viewId) {
  5833. try {
  5834. const logStatus = scripts_echoLog({
  5835. type: 'gettingAnnouncementParams',
  5836. text: appId,
  5837. id: viewId
  5838. });
  5839. const {
  5840. result,
  5841. statusText,
  5842. status,
  5843. data
  5844. } = await tools_httpRequest({
  5845. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5846. method: 'GET',
  5847. headers: {
  5848. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5849. }
  5850. });
  5851. if (result === 'Success') {
  5852. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5853. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5854. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5855. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5856. 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];
  5857. if (authWgToken && clanId) {
  5858. logStatus.success();
  5859. return {
  5860. authWgToken: authWgToken,
  5861. clanId: clanId,
  5862. gid: gid
  5863. };
  5864. }
  5865. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5866. return {};
  5867. }
  5868. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5869. return {};
  5870. }
  5871. logStatus.error(`${result}:${statusText}(${status})`);
  5872. return {};
  5873. } catch (error) {
  5874. throwError(error, 'Steam.likeAnnouncement');
  5875. return {};
  5876. }
  5877. }
  5878. async function _likeAnnouncement2(id) {
  5879. try {
  5880. const [ appId, viewId ] = id.split('/');
  5881. if (!(appId && viewId)) {
  5882. scripts_echoLog({
  5883. type: 'lost params',
  5884. text: id
  5885. });
  5886. return false;
  5887. }
  5888. const {
  5889. authWgToken,
  5890. clanId,
  5891. gid
  5892. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5893. if (!(authWgToken && clanId)) {
  5894. return false;
  5895. }
  5896. const logStatus = scripts_echoLog({
  5897. type: 'likingAnnouncement',
  5898. text: appId,
  5899. id: viewId
  5900. });
  5901. const {
  5902. result,
  5903. statusText,
  5904. status,
  5905. data
  5906. } = await tools_httpRequest({
  5907. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5908. method: 'POST',
  5909. headers: {
  5910. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5911. Host: 'store.steampowered.com',
  5912. Origin: 'https://store.steampowered.com',
  5913. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5914. },
  5915. data: $.param({
  5916. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5917. wgauthtoken: authWgToken,
  5918. voteup: 1,
  5919. clanid: clanId,
  5920. ajax: 1
  5921. }),
  5922. dataType: 'json'
  5923. });
  5924. if (result === 'Success') {
  5925. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5926. logStatus.success();
  5927. return true;
  5928. }
  5929. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5930. return false;
  5931. }
  5932. logStatus.error(`${result}:${statusText}(${status})`);
  5933. return false;
  5934. } catch (error) {
  5935. throwError(error, 'Steam.likeAnnouncement');
  5936. return false;
  5937. }
  5938. }
  5939. function Steam_setCache2(type, name, id) {
  5940. try {
  5941. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  5942. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  5943. } catch (error) {
  5944. throwError(error, 'Steam.setCache');
  5945. }
  5946. }
  5947. const social_Steam = Steam;
  5948. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  5949. Website_checkPrivateRedeclaration(obj, privateSet);
  5950. privateSet.add(obj);
  5951. }
  5952. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  5953. if (privateCollection.has(obj)) {
  5954. throw new TypeError('Cannot initialize the same private elements twice on an object');
  5955. }
  5956. }
  5957. function Website_defineProperty(obj, key, value) {
  5958. if (key in obj) {
  5959. Object.defineProperty(obj, key, {
  5960. value: value,
  5961. enumerable: true,
  5962. configurable: true,
  5963. writable: true
  5964. });
  5965. } else {
  5966. obj[key] = value;
  5967. }
  5968. return obj;
  5969. }
  5970. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  5971. if (!privateSet.has(receiver)) {
  5972. throw new TypeError('attempted to get private field on non-instance');
  5973. }
  5974. return fn;
  5975. }
  5976. var _bind = new WeakSet();
  5977. class Website {
  5978. constructor() {
  5979. Website_classPrivateMethodInitSpec(this, _bind);
  5980. Website_defineProperty(this, 'undoneTasks', void 0);
  5981. Website_defineProperty(this, 'socialTasks', void 0);
  5982. Website_defineProperty(this, 'giveawayId', void 0);
  5983. Website_defineProperty(this, 'socialInitialized', {
  5984. discord: false,
  5985. instagram: false,
  5986. reddit: false,
  5987. twitch: false,
  5988. twitter: false,
  5989. vk: false,
  5990. youtube: false,
  5991. steam: false
  5992. });
  5993. Website_defineProperty(this, 'initialized', false);
  5994. Website_defineProperty(this, 'social', {});
  5995. }
  5996. async initSocial(action) {
  5997. try {
  5998. const pro = [];
  5999. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6000. if (tasks.discord) {
  6001. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6002. if (hasDiscord && !this.socialInitialized.discord) {
  6003. this.social.discord = new social_Discord();
  6004. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6005. }
  6006. }
  6007. if (tasks.instagram) {
  6008. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6009. if (hasInstagram && !this.socialInitialized.instagram) {
  6010. this.social.instagram = new social_Instagram();
  6011. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6012. }
  6013. }
  6014. if (tasks.reddit) {
  6015. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6016. if (hasReddit && !this.socialInitialized.reddit) {
  6017. this.social.reddit = new social_Reddit();
  6018. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6019. }
  6020. }
  6021. if (tasks.twitch) {
  6022. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6023. if (hasTwitch && !this.socialInitialized.twitch) {
  6024. this.social.twitch = new social_Twitch();
  6025. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6026. }
  6027. }
  6028. if (tasks.twitter) {
  6029. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6030. if (hasTwitter && !this.socialInitialized.twitter) {
  6031. this.social.twitter = new social_Twitter();
  6032. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6033. }
  6034. }
  6035. if (tasks.vk) {
  6036. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6037. if (hasVk && !this.socialInitialized.vk) {
  6038. this.social.vk = new social_Vk();
  6039. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6040. }
  6041. }
  6042. if (tasks.youtube) {
  6043. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6044. if (hasYoutube && !this.socialInitialized.youtube) {
  6045. this.social.youtube = new Youtube();
  6046. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6047. }
  6048. }
  6049. if (tasks.steam) {
  6050. const hasSteam = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6051. if (hasSteam && !this.socialInitialized.steam) {
  6052. this.social.steam = new social_Steam();
  6053. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steam', this.social.steam.init()));
  6054. }
  6055. }
  6056. if (tasks.links && tasks.links.length > 0) {
  6057. this.social.visitLink = visitLink;
  6058. }
  6059. return await Promise.all(pro).then(result => {
  6060. let checked = true;
  6061. for (const data of result) {
  6062. if (data.result) {
  6063. this.socialInitialized[data.name] = data.result;
  6064. } else {
  6065. checked = false;
  6066. }
  6067. }
  6068. return checked;
  6069. });
  6070. } catch (error) {
  6071. throwError(error, 'Website.initSocial');
  6072. return false;
  6073. }
  6074. }
  6075. uniqueTasks(allTasks) {
  6076. const result = {};
  6077. for (const [ social, types ] of Object.entries(allTasks)) {
  6078. result[social] = {};
  6079. for (const [ type, tasks ] of Object.entries(types)) {
  6080. result[social][type] = unique(tasks);
  6081. }
  6082. }
  6083. return result;
  6084. }
  6085. async toggleTask(action) {
  6086. try {
  6087. if (!this.initialized && !this.init()) {
  6088. return false;
  6089. }
  6090. if (!await this.classifyTask(action)) {
  6091. return false;
  6092. }
  6093. if (!await this.initSocial(action)) {
  6094. return false;
  6095. }
  6096. const pro = [];
  6097. const doTask = action === 'do';
  6098. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6099. if (this.social.discord) {
  6100. pro.push(this.social.discord.toggle({
  6101. doTask: doTask,
  6102. ...tasks.discord
  6103. }));
  6104. }
  6105. if (this.social.instagram) {
  6106. pro.push(this.social.instagram.toggle({
  6107. doTask: doTask,
  6108. ...tasks.instagram
  6109. }));
  6110. }
  6111. if (this.social.reddit) {
  6112. pro.push(this.social.reddit.toggle({
  6113. doTask: doTask,
  6114. ...tasks.reddit
  6115. }));
  6116. }
  6117. if (this.social.twitch) {
  6118. pro.push(this.social.twitch.toggle({
  6119. doTask: doTask,
  6120. ...tasks.twitch
  6121. }));
  6122. }
  6123. if (this.social.twitter) {
  6124. pro.push(this.social.twitter.toggle({
  6125. doTask: doTask,
  6126. ...tasks.twitter
  6127. }));
  6128. }
  6129. if (this.social.vk) {
  6130. pro.push(this.social.vk.toggle({
  6131. doTask: doTask,
  6132. ...tasks.vk
  6133. }));
  6134. }
  6135. if (this.social.youtube) {
  6136. pro.push(this.social.youtube.toggle({
  6137. doTask: doTask,
  6138. ...tasks.youtube
  6139. }));
  6140. }
  6141. if (this.social.steam) {
  6142. pro.push(this.social.steam.toggle({
  6143. doTask: doTask,
  6144. ...tasks.steam
  6145. }));
  6146. }
  6147. if (this.social.visitLink && tasks.links && doTask) {
  6148. for (const link of tasks.links) {
  6149. pro.push(this.social.visitLink(link));
  6150. }
  6151. }
  6152. if (doTask && tasks.extra && this.extraDoTask) {
  6153. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6154. if (hasExtra) {
  6155. pro.push(this.extraDoTask(tasks.extra));
  6156. }
  6157. }
  6158. await Promise.all(pro);
  6159. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6160. return true;
  6161. } catch (error) {
  6162. throwError(error, 'Website.toggleTask');
  6163. return false;
  6164. }
  6165. }
  6166. async doTask() {
  6167. try {
  6168. return await this.toggleTask('do');
  6169. } catch (error) {
  6170. throwError(error, 'Website.doTask');
  6171. return false;
  6172. }
  6173. }
  6174. async undoTask() {
  6175. try {
  6176. return await this.toggleTask('undo');
  6177. } catch (error) {
  6178. throwError(error, 'Website.undoTask');
  6179. return false;
  6180. }
  6181. }
  6182. }
  6183. async function _bind2(name, init) {
  6184. try {
  6185. return {
  6186. name: name,
  6187. result: await init
  6188. };
  6189. } catch (error) {
  6190. throwError(error, 'Website.bind');
  6191. return {
  6192. name: name,
  6193. result: false
  6194. };
  6195. }
  6196. }
  6197. const website_Website = Website;
  6198. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6199. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6200. privateSet.add(obj);
  6201. }
  6202. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6203. if (privateCollection.has(obj)) {
  6204. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6205. }
  6206. }
  6207. function FreeAnyWhere_defineProperty(obj, key, value) {
  6208. if (key in obj) {
  6209. Object.defineProperty(obj, key, {
  6210. value: value,
  6211. enumerable: true,
  6212. configurable: true,
  6213. writable: true
  6214. });
  6215. } else {
  6216. obj[key] = value;
  6217. }
  6218. return obj;
  6219. }
  6220. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6221. if (!privateSet.has(receiver)) {
  6222. throw new TypeError('attempted to get private field on non-instance');
  6223. }
  6224. return fn;
  6225. }
  6226. const FreeAnyWhere_defaultTasks = {
  6227. steam: {
  6228. groupLinks: [],
  6229. wishlistLinks: [],
  6230. curatorLinks: [],
  6231. followLinks: []
  6232. },
  6233. vk: {
  6234. nameLinks: []
  6235. }
  6236. };
  6237. var _getGiveawayId = new WeakSet();
  6238. var _verify = new WeakSet();
  6239. class FreeAnyWhere extends website_Website {
  6240. constructor() {
  6241. super(...arguments);
  6242. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6243. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6244. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6245. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6246. FreeAnyWhere_defineProperty(this, 'socialTasks', {
  6247. ...FreeAnyWhere_defaultTasks
  6248. });
  6249. FreeAnyWhere_defineProperty(this, 'undoneTasks', {
  6250. ...FreeAnyWhere_defaultTasks
  6251. });
  6252. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6253. }
  6254. static test() {
  6255. return window.location.host === 'freeanywhere.net';
  6256. }
  6257. init() {
  6258. try {
  6259. const logStatus = scripts_echoLog({
  6260. text: i18n('initing')
  6261. });
  6262. if ($('a[href="#/login"]').length > 0) {
  6263. window.open('/#/login', '_self');
  6264. logStatus.warning(i18n('needLogin'));
  6265. return false;
  6266. }
  6267. if (window.location.href.includes('/login')) {
  6268. logStatus.warning(i18n('needLogin'));
  6269. return false;
  6270. }
  6271. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6272. var _window$location$href;
  6273. 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];
  6274. if (!id) {
  6275. logStatus.error(i18n('getFailed', 'Id'));
  6276. return false;
  6277. }
  6278. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6279. }
  6280. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6281. return false;
  6282. }
  6283. this.initialized = true;
  6284. logStatus.success();
  6285. return true;
  6286. } catch (error) {
  6287. throwError(error, 'Freeanywhere.init');
  6288. return false;
  6289. }
  6290. }
  6291. async classifyTask(action) {
  6292. try {
  6293. const logStatus = scripts_echoLog({
  6294. text: i18n('getTasksInfo')
  6295. });
  6296. if (action === 'undo') {
  6297. var _GM_getValue;
  6298. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  6299. ...FreeAnyWhere_defaultTasks
  6300. };
  6301. }
  6302. const {
  6303. result,
  6304. statusText,
  6305. status,
  6306. data
  6307. } = await tools_httpRequest({
  6308. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6309. method: 'GET',
  6310. headers: {
  6311. authorization: `Token ${window.localStorage.getItem('token')}`,
  6312. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6313. },
  6314. responseType: 'json'
  6315. });
  6316. if (result === 'Success') {
  6317. var _data$response;
  6318. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6319. if (tasks) {
  6320. if (action === 'verify') {
  6321. this.tasks = [];
  6322. }
  6323. for (const task of tasks) {
  6324. const type = task.challenge;
  6325. const social = task.challenge_provider;
  6326. const taskInfo = {
  6327. id: task.id,
  6328. title: task.title
  6329. };
  6330. if (action === 'verify' && !task.is_success) {
  6331. this.tasks.push(taskInfo);
  6332. continue;
  6333. }
  6334. switch (social) {
  6335. case 'steam':
  6336. taskInfo.social = 'steam';
  6337. switch (type) {
  6338. case 'WL':
  6339. if (action === 'undo') {
  6340. this.socialTasks.steam.wishlistLinks.push(task.link);
  6341. }
  6342. if (action === 'do' && !task.is_success) {
  6343. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6344. }
  6345. break;
  6346.  
  6347. case 'JTG':
  6348. if (action === 'undo') {
  6349. this.socialTasks.steam.groupLinks.push(task.link);
  6350. }
  6351. if (action === 'do' && !task.is_success) {
  6352. this.undoneTasks.steam.groupLinks.push(task.link);
  6353. }
  6354. break;
  6355.  
  6356. case 'STC':
  6357. if (action === 'undo') {
  6358. this.socialTasks.steam.curatorLinks.push(task.link);
  6359. }
  6360. if (action === 'do' && !task.is_success) {
  6361. this.undoneTasks.steam.curatorLinks.push(task.link);
  6362. }
  6363. break;
  6364.  
  6365. case 'GF':
  6366. if (action === 'undo') {
  6367. this.socialTasks.steam.followLinks.push(task.link);
  6368. }
  6369. if (action === 'do' && !task.is_success) {
  6370. this.undoneTasks.steam.followLinks.push(task.link);
  6371. }
  6372. break;
  6373. }
  6374. break;
  6375.  
  6376. case 'vk-oauth2':
  6377. if (action === 'undo') {
  6378. this.socialTasks.vk.nameLinks.push(task.link);
  6379. }
  6380. if (action === 'do' && !task.is_success) {
  6381. this.undoneTasks.vk.nameLinks.push(task.link);
  6382. }
  6383. break;
  6384.  
  6385. case 'website':
  6386. break;
  6387.  
  6388. default:
  6389. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6390. break;
  6391. }
  6392. }
  6393. logStatus.success();
  6394. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6395. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6396. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6397. tasks: this.socialTasks,
  6398. time: new Date().getTime()
  6399. });
  6400. return true;
  6401. }
  6402. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6403. console.error(data);
  6404. return false;
  6405. }
  6406. logStatus.error(`${result}:${statusText}(${status})`);
  6407. return false;
  6408. } catch (error) {
  6409. throwError(error, 'Freeanywhere.classifyTask');
  6410. return false;
  6411. }
  6412. }
  6413. async verifyTask() {
  6414. try {
  6415. if (!this.initialized && !this.init()) {
  6416. return false;
  6417. }
  6418. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6419. return false;
  6420. }
  6421. const pro = [];
  6422. for (const task of this.tasks) {
  6423. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6424. await delay(1e3);
  6425. }
  6426. await Promise.all(pro);
  6427. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6428. return !!await this.getKey(true);
  6429. } catch (error) {
  6430. throwError(error, 'Freeanywhere.verifyTask');
  6431. return false;
  6432. }
  6433. }
  6434. async getKey(initialized) {
  6435. try {
  6436. if (!initialized && !this.initialized && !this.init()) {
  6437. return false;
  6438. }
  6439. const logStatus = scripts_echoLog({
  6440. text: i18n('gettingKey')
  6441. });
  6442. const {
  6443. result,
  6444. statusText,
  6445. status,
  6446. data
  6447. } = await tools_httpRequest({
  6448. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6449. method: 'GET',
  6450. dataType: 'json',
  6451. headers: {
  6452. authorization: `Token ${window.localStorage.getItem('token')}`
  6453. }
  6454. });
  6455. if (result === 'Success') {
  6456. var _data$response2;
  6457. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6458. logStatus.success();
  6459. scripts_echoLog({}).success(data.response.reward);
  6460. return data.response.reward;
  6461. }
  6462. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6463. return false;
  6464. }
  6465. logStatus.error(`${result}:${statusText}(${status})`);
  6466. return false;
  6467. } catch (error) {
  6468. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6469. return false;
  6470. }
  6471. }
  6472. }
  6473. function _getGiveawayId2() {
  6474. try {
  6475. var _window$location$href2;
  6476. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6477. if (giveawayId) {
  6478. this.giveawayId = giveawayId;
  6479. return true;
  6480. }
  6481. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6482. return false;
  6483. } catch (error) {
  6484. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6485. }
  6486. }
  6487. async function _verify2(task) {
  6488. try {
  6489. const logStatus = scripts_echoLog({
  6490. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6491. });
  6492. const {
  6493. result,
  6494. statusText,
  6495. status,
  6496. data
  6497. } = await tools_httpRequest({
  6498. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6499. method: 'GET',
  6500. dataType: 'json',
  6501. headers: {
  6502. authorization: `Token ${window.localStorage.getItem('token')}`,
  6503. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6504. }
  6505. });
  6506. if (result === 'Success') {
  6507. var _data$response3;
  6508. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6509. logStatus.success();
  6510. return true;
  6511. }
  6512. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6513. return false;
  6514. }
  6515. logStatus.error(`${result}:${statusText}(${status})`);
  6516. return false;
  6517. } catch (error) {
  6518. throwError(error, 'Freeanywhere.verify');
  6519. return false;
  6520. }
  6521. }
  6522. const website_FreeAnyWhere = FreeAnyWhere;
  6523. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6524. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6525. privateSet.add(obj);
  6526. }
  6527. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6528. if (privateCollection.has(obj)) {
  6529. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6530. }
  6531. }
  6532. function GiveawaySu_defineProperty(obj, key, value) {
  6533. if (key in obj) {
  6534. Object.defineProperty(obj, key, {
  6535. value: value,
  6536. enumerable: true,
  6537. configurable: true,
  6538. writable: true
  6539. });
  6540. } else {
  6541. obj[key] = value;
  6542. }
  6543. return obj;
  6544. }
  6545. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6546. if (!privateSet.has(receiver)) {
  6547. throw new TypeError('attempted to get private field on non-instance');
  6548. }
  6549. return fn;
  6550. }
  6551. const GiveawaySu_defaultTasks = {
  6552. steam: {
  6553. groupLinks: [],
  6554. wishlistLinks: [],
  6555. curatorLinks: [],
  6556. curatorLikeLinks: [],
  6557. followLinks: [],
  6558. forumLinks: [],
  6559. announcementLinks: [],
  6560. workshopVoteLinks: []
  6561. },
  6562. discord: {
  6563. serverLinks: []
  6564. },
  6565. instagram: {
  6566. userLinks: []
  6567. },
  6568. vk: {
  6569. nameLinks: []
  6570. },
  6571. twitch: {
  6572. channelLinks: []
  6573. },
  6574. reddit: {
  6575. redditLinks: []
  6576. },
  6577. youtube: {
  6578. channelLinks: [],
  6579. likeLinks: []
  6580. }
  6581. };
  6582. var _checkLogin = new WeakSet();
  6583. var _checkLeftKey = new WeakSet();
  6584. var GiveawaySu_getGiveawayId = new WeakSet();
  6585. class GiveawaySu extends website_Website {
  6586. constructor() {
  6587. super(...arguments);
  6588. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6589. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6590. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6591. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6592. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6593. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6594. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6595. }
  6596. static test() {
  6597. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6598. }
  6599. async after() {
  6600. try {
  6601. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6602. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6603. }
  6604. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6605. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6606. }
  6607. } catch (error) {
  6608. throwError(error, 'Giveawaysu.after');
  6609. }
  6610. }
  6611. init() {
  6612. try {
  6613. const logStatus = scripts_echoLog({
  6614. text: i18n('initing')
  6615. });
  6616. if ($('a.steam-login').length > 0) {
  6617. window.open('/steam/redirect', '_self');
  6618. logStatus.warning(i18n('needLogin'));
  6619. return false;
  6620. }
  6621. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6622. return false;
  6623. }
  6624. this.initialized = true;
  6625. logStatus.success();
  6626. return true;
  6627. } catch (error) {
  6628. throwError(error, 'Giveawaysu.init');
  6629. return false;
  6630. }
  6631. }
  6632. async classifyTask(action) {
  6633. try {
  6634. const logStatus = scripts_echoLog({
  6635. text: i18n('getTasksInfo')
  6636. });
  6637. if (action === 'undo') {
  6638. var _GM_getValue;
  6639. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6640. return true;
  6641. }
  6642. const pro = [];
  6643. const tasks = $('#actions tr');
  6644. if ($('div.bind-discord').is(':visible')) {
  6645. $('div.bind-discord a')[0].click();
  6646. }
  6647. if ($('div.bind-twitch').is(':visible')) {
  6648. $('div.bind-twitch a')[0].click();
  6649. }
  6650. for (const task of tasks) {
  6651. pro.push(new Promise(resolve => {
  6652. const td = $(task).find('td:not(".hidden")');
  6653. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6654. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6655. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6656. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6657. const taskName = taskDes.text().trim();
  6658. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6659. return resolve(true);
  6660. }
  6661. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6662. if (!taskLink) {
  6663. return resolve(false);
  6664. }
  6665. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6666. this.undoneTasks.steam.groupLinks.push(taskLink);
  6667. } else if (/like.*announcement/gi.test(taskName)) {
  6668. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6669. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6670. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6671. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6672. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6673. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6674. this.undoneTasks.steam.forumLinks.push(taskLink);
  6675. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6676. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6677. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6678. this.undoneTasks.discord.serverLinks.push(taskLink);
  6679. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6680. this.undoneTasks.instagram.userLinks.push(taskLink);
  6681. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6682. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6683. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6684. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6685. } else if (/watch.*art/gim.test(taskName)) {
  6686. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6687. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6688. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6689. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6690. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6691. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6692. this.undoneTasks.vk.nameLinks.push(taskLink);
  6693. } else {
  6694. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6695. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6696. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6697. }
  6698. if (/follow.*button/gim.test(taskName)) {
  6699. this.undoneTasks.steam.followLinks.push(taskLink);
  6700. }
  6701. }
  6702. }
  6703. resolve(true);
  6704. }).catch(error => {
  6705. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6706. return false;
  6707. });
  6708. }));
  6709. }
  6710. await Promise.all(pro);
  6711. logStatus.success();
  6712. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6713. this.socialTasks = this.undoneTasks;
  6714. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6715. tasks: this.socialTasks,
  6716. time: new Date().getTime()
  6717. });
  6718. return true;
  6719. } catch (error) {
  6720. throwError(error, 'Giveawaysu.classifyTask');
  6721. return false;
  6722. }
  6723. }
  6724. }
  6725. function _checkLogin2() {
  6726. try {
  6727. if (!globalOptions.other.checkLogin) {
  6728. return true;
  6729. }
  6730. if ($('a.steam-login').length > 0) {
  6731. window.open('/steam/redirect', '_self');
  6732. }
  6733. return true;
  6734. } catch (error) {
  6735. throwError(error, 'Giveawaysu.checkLogin');
  6736. return false;
  6737. }
  6738. }
  6739. async function _checkLeftKey2() {
  6740. try {
  6741. if (!globalOptions.other.checkLeftKey) {
  6742. return true;
  6743. }
  6744. if ($('.giveaway-ended').length > 0) {
  6745. await external_Swal_default().fire({
  6746. icon: 'warning',
  6747. title: i18n('notice'),
  6748. text: i18n('noKeysLeft'),
  6749. confirmButtonText: i18n('confirm'),
  6750. cancelButtonText: i18n('cancel'),
  6751. showCancelButton: true
  6752. }).then(_ref => {
  6753. let {
  6754. value
  6755. } = _ref;
  6756. if (value) {
  6757. window.close();
  6758. }
  6759. });
  6760. }
  6761. return true;
  6762. } catch (error) {
  6763. throwError(error, 'Giveawaysu.checkLeftKey');
  6764. return false;
  6765. }
  6766. }
  6767. function GiveawaySu_getGiveawayId2() {
  6768. var _window$location$href;
  6769. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6770. if (giveawayId) {
  6771. this.giveawayId = giveawayId;
  6772. return true;
  6773. }
  6774. scripts_echoLog({
  6775. text: i18n('getFailed', 'GiveawayId')
  6776. });
  6777. return false;
  6778. }
  6779. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6780. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6781. privateSet.add(obj);
  6782. }
  6783. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6784. if (privateCollection.has(obj)) {
  6785. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6786. }
  6787. }
  6788. function Indiedb_defineProperty(obj, key, value) {
  6789. if (key in obj) {
  6790. Object.defineProperty(obj, key, {
  6791. value: value,
  6792. enumerable: true,
  6793. configurable: true,
  6794. writable: true
  6795. });
  6796. } else {
  6797. obj[key] = value;
  6798. }
  6799. return obj;
  6800. }
  6801. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6802. if (!privateSet.has(receiver)) {
  6803. throw new TypeError('attempted to get private field on non-instance');
  6804. }
  6805. return fn;
  6806. }
  6807. var _join = new WeakSet();
  6808. var _do = new WeakSet();
  6809. var Indiedb_checkLogin = new WeakSet();
  6810. var Indiedb_checkLeftKey = new WeakSet();
  6811. class Indiedb {
  6812. constructor() {
  6813. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6814. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6815. Indiedb_classPrivateMethodInitSpec(this, _do);
  6816. Indiedb_classPrivateMethodInitSpec(this, _join);
  6817. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6818. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6819. }
  6820. static test() {
  6821. return window.location.host === 'www.indiedb.com';
  6822. }
  6823. async after() {
  6824. try {
  6825. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  6826. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6827. }
  6828. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  6829. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6830. }
  6831. } catch (error) {
  6832. throwError(error, 'Indiedb.after');
  6833. }
  6834. }
  6835. async doTask() {
  6836. try {
  6837. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  6838. return false;
  6839. }
  6840. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  6841. } catch (error) {
  6842. throwError(error, 'Indiedb.doTask');
  6843. return false;
  6844. }
  6845. }
  6846. }
  6847. async function _join2() {
  6848. try {
  6849. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6850. scripts_echoLog({}).error(i18n('needLogin'));
  6851. return false;
  6852. }
  6853. const currentoption = $('a.buttonenter.buttongiveaway');
  6854. if (/join giveaway/gim.test(currentoption.text())) {
  6855. const logStatus = scripts_echoLog({
  6856. text: `${i18n('joiningGiveaway')}...`
  6857. });
  6858. const {
  6859. result,
  6860. statusText,
  6861. status,
  6862. data
  6863. } = await tools_httpRequest({
  6864. url: currentoption.attr('href'),
  6865. method: 'POST',
  6866. data: 'ajax=t',
  6867. dataType: 'json',
  6868. headers: {
  6869. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6870. accept: 'application/json, text/javascript, */*; q=0.01',
  6871. origin: window.location.origin
  6872. }
  6873. });
  6874. if (result === 'Success') {
  6875. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6876. var _data$response, _data$response4, _data$response5;
  6877. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6878. var _data$response2, _data$response3;
  6879. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6880. $('#giveawaysjoined').slideDown();
  6881. $('#giveawaysrecommend').slideDown();
  6882. 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}` : ''}`);
  6883. return true;
  6884. }
  6885. 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}` : ''}`);
  6886. return false;
  6887. }
  6888. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6889. return false;
  6890. }
  6891. logStatus.error(`${result}:${statusText}(${status})`);
  6892. return false;
  6893. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6894. return true;
  6895. }
  6896. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6897. return false;
  6898. } catch (error) {
  6899. throwError(error, 'Indiedb.init');
  6900. return false;
  6901. }
  6902. }
  6903. async function _do2() {
  6904. try {
  6905. const id = $('script').map((index, script) => {
  6906. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6907. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6908. 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] ];
  6909. }
  6910. return null;
  6911. });
  6912. if (id.length === 2) {
  6913. const pro = [];
  6914. const tasks = $('#giveawaysjoined a[class*=promo]');
  6915. for (const task of tasks) {
  6916. const promo = $(task);
  6917. if (!promo.hasClass('buttonentered')) {
  6918. const status = scripts_echoLog({
  6919. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6920. });
  6921. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6922. let text = '';
  6923. if (promo.hasClass('facebookpromo')) {
  6924. text = 'facebookpromo';
  6925. } else if (promo.hasClass('twitterpromo')) {
  6926. text = 'twitterpromo';
  6927. } else {
  6928. text = 'visitpromo';
  6929. }
  6930. pro.push(new Promise(resolve => {
  6931. $.ajax({
  6932. type: 'POST',
  6933. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6934. timeout: 6e4,
  6935. dataType: 'json',
  6936. data: {
  6937. ajax: 't'
  6938. },
  6939. error(response, error, exception) {
  6940. console.log({
  6941. response: response,
  6942. error: error,
  6943. exception: exception
  6944. });
  6945. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6946. resolve(true);
  6947. },
  6948. success(response) {
  6949. console.log(response);
  6950. if (response.success) {
  6951. status.success(`Success:${response.text}`);
  6952. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6953. resolve(true);
  6954. } else {
  6955. status.error(`Error:${response.text}`);
  6956. resolve(true);
  6957. }
  6958. }
  6959. });
  6960. }));
  6961. } else if (promo.hasClass('emailoptinpromo')) {
  6962. pro.push(new Promise(resolve => {
  6963. $.ajax({
  6964. type: 'POST',
  6965. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6966. timeout: 6e4,
  6967. dataType: 'json',
  6968. data: {
  6969. ajax: 't',
  6970. emailsystoggle: 4
  6971. },
  6972. error(response, error, exception) {
  6973. console.log({
  6974. response: response,
  6975. error: error,
  6976. exception: exception
  6977. });
  6978. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6979. resolve(true);
  6980. },
  6981. success(response) {
  6982. console.log(response);
  6983. if (response.success) {
  6984. status.success(`Success:${response.text}`);
  6985. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6986. resolve(true);
  6987. } else {
  6988. status.error(`Error:${response.text}`);
  6989. resolve(true);
  6990. }
  6991. }
  6992. });
  6993. }));
  6994. } else if (promo.hasClass('watchingpromo')) {
  6995. pro.push(new Promise(resolve => {
  6996. var _promo$attr;
  6997. const data = getUrlQuery(promo.attr('href'));
  6998. data.ajax = 't';
  6999. $.ajax({
  7000. type: 'POST',
  7001. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7002. timeout: 6e4,
  7003. dataType: 'json',
  7004. data: data,
  7005. error(response, error, exception) {
  7006. console.log({
  7007. response: response,
  7008. error: error,
  7009. exception: exception
  7010. });
  7011. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7012. resolve(true);
  7013. },
  7014. success(response) {
  7015. console.log(response);
  7016. if (response.success) {
  7017. status.success(`Success:${response.text}`);
  7018. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7019. resolve(true);
  7020. } else {
  7021. status.error(`Error:${response.text}`);
  7022. resolve(true);
  7023. }
  7024. }
  7025. });
  7026. }));
  7027. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7028. pro.push(new Promise(resolve => {
  7029. $.ajax({
  7030. type: 'POST',
  7031. url: urlPath(promo.attr('href')),
  7032. timeout: 6e4,
  7033. dataType: 'json',
  7034. data: {
  7035. ajax: 't'
  7036. },
  7037. error(response, error, exception) {
  7038. console.log({
  7039. response: response,
  7040. error: error,
  7041. exception: exception
  7042. });
  7043. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7044. resolve(true);
  7045. },
  7046. success(response) {
  7047. console.log(response);
  7048. if (response.success) {
  7049. status.success(`Success:${response.text}`);
  7050. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7051. resolve(true);
  7052. } else {
  7053. status.error(`Error:${response.text}`);
  7054. resolve(true);
  7055. }
  7056. }
  7057. });
  7058. }));
  7059. } else {
  7060. status.error(`Error:${i18n('unKnownTaskType')}`);
  7061. }
  7062. }
  7063. }
  7064. await Promise.all(pro);
  7065. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7066. return true;
  7067. }
  7068. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7069. return false;
  7070. } catch (error) {
  7071. throwError(error, 'Indiedb.classifyTask');
  7072. return false;
  7073. }
  7074. }
  7075. function Indiedb_checkLogin2() {
  7076. try {
  7077. if (!globalOptions.other.checkLogin) {
  7078. return true;
  7079. }
  7080. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7081. window.open('/members/login', '_self');
  7082. }
  7083. return true;
  7084. } catch (error) {
  7085. throwError(error, 'Indiedb.checkLogin');
  7086. return false;
  7087. }
  7088. }
  7089. async function Indiedb_checkLeftKey2() {
  7090. try {
  7091. if (!globalOptions.other.checkLeftKey) {
  7092. return true;
  7093. }
  7094. if ($('a.buttonenter:contains("next time")').length > 0) {
  7095. await external_Swal_default().fire({
  7096. icon: 'warning',
  7097. title: i18n('notice'),
  7098. text: i18n('giveawayEnded'),
  7099. confirmButtonText: i18n('confirm'),
  7100. cancelButtonText: i18n('cancel'),
  7101. showCancelButton: true
  7102. }).then(_ref => {
  7103. let {
  7104. value
  7105. } = _ref;
  7106. if (value) {
  7107. window.close();
  7108. }
  7109. });
  7110. }
  7111. return true;
  7112. } catch (error) {
  7113. throwError(error, 'Indiedb.checkLeftKey');
  7114. return false;
  7115. }
  7116. }
  7117. const website_Indiedb = Indiedb;
  7118. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7119. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7120. privateSet.add(obj);
  7121. }
  7122. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7123. if (privateCollection.has(obj)) {
  7124. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7125. }
  7126. }
  7127. function Keyhub_defineProperty(obj, key, value) {
  7128. if (key in obj) {
  7129. Object.defineProperty(obj, key, {
  7130. value: value,
  7131. enumerable: true,
  7132. configurable: true,
  7133. writable: true
  7134. });
  7135. } else {
  7136. obj[key] = value;
  7137. }
  7138. return obj;
  7139. }
  7140. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7141. if (!privateSet.has(receiver)) {
  7142. throw new TypeError('attempted to get private field on non-instance');
  7143. }
  7144. return fn;
  7145. }
  7146. const Keyhub_defaultTasks = {
  7147. steam: {
  7148. groupLinks: [],
  7149. wishlistLinks: [],
  7150. curatorLinks: []
  7151. },
  7152. discord: {
  7153. serverLinks: []
  7154. },
  7155. links: []
  7156. };
  7157. var Keyhub_getGiveawayId = new WeakSet();
  7158. var Keyhub_checkLeftKey = new WeakSet();
  7159. var Keyhub_checkLogin = new WeakSet();
  7160. class Keyhub extends website_Website {
  7161. constructor() {
  7162. super(...arguments);
  7163. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7164. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7165. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7166. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7167. Keyhub_defineProperty(this, 'socialTasks', {
  7168. ...Keyhub_defaultTasks
  7169. });
  7170. Keyhub_defineProperty(this, 'undoneTasks', {
  7171. ...Keyhub_defaultTasks
  7172. });
  7173. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7174. }
  7175. static test() {
  7176. return window.location.host === 'key-hub.eu';
  7177. }
  7178. async after() {
  7179. try {
  7180. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7181. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7182. }
  7183. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7184. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7185. }
  7186. } catch (error) {
  7187. throwError(error, 'Keyhub.after');
  7188. }
  7189. }
  7190. init() {
  7191. try {
  7192. const logStatus = scripts_echoLog({
  7193. text: i18n('initing')
  7194. });
  7195. if ($('a[href*="/connect/steam"]').length > 0) {
  7196. window.open('/connect/steam', '_self');
  7197. logStatus.warning(i18n('needLogin'));
  7198. return false;
  7199. }
  7200. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7201. return false;
  7202. }
  7203. $('#VPNoverlay').hide();
  7204. $('#mainArticleSection').show();
  7205. this.initialized = true;
  7206. logStatus.success();
  7207. return true;
  7208. } catch (error) {
  7209. throwError(error, 'Keyhub.init');
  7210. return false;
  7211. }
  7212. }
  7213. async classifyTask(action) {
  7214. try {
  7215. const logStatus = scripts_echoLog({
  7216. text: i18n('getTasksInfo')
  7217. });
  7218. if (action === 'undo') {
  7219. var _GM_getValue;
  7220. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  7221. ...Keyhub_defaultTasks
  7222. };
  7223. }
  7224. const tasks = $('.task a');
  7225. for (const task of tasks) {
  7226. let link = $(task).attr('href');
  7227. const taskDes = $(task).text().trim();
  7228. if (!link) {
  7229. continue;
  7230. }
  7231. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7232. link = await getRedirectLink(link) || link;
  7233. }
  7234. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7235. window.open(link, '_blank');
  7236. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7237. if (action === 'undo') {
  7238. this.socialTasks.steam.groupLinks.push(link);
  7239. }
  7240. if (action === 'do') {
  7241. this.undoneTasks.steam.groupLinks.push(link);
  7242. }
  7243. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7244. if (action === 'undo') {
  7245. this.socialTasks.steam.wishlistLinks.push(link);
  7246. }
  7247. if (action === 'do') {
  7248. this.undoneTasks.steam.wishlistLinks.push(link);
  7249. }
  7250. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7251. if (action === 'undo') {
  7252. this.socialTasks.steam.curatorLinks.push(link);
  7253. }
  7254. if (action === 'do') {
  7255. this.undoneTasks.steam.curatorLinks.push(link);
  7256. }
  7257. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7258. if (action === 'undo') {
  7259. this.socialTasks.discord.serverLinks.push(link);
  7260. }
  7261. if (action === 'do') {
  7262. this.undoneTasks.discord.serverLinks.push(link);
  7263. }
  7264. } else {
  7265. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7266. }
  7267. }
  7268. logStatus.success();
  7269. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7270. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7271. GM_setValue(`khTasks-${this.giveawayId}`, {
  7272. tasks: this.socialTasks,
  7273. time: new Date().getTime()
  7274. });
  7275. return true;
  7276. } catch (error) {
  7277. throwError(error, 'Keyhub.classifyTask');
  7278. return false;
  7279. }
  7280. }
  7281. verifyTask() {
  7282. try {
  7283. scripts_echoLog({
  7284. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7285. });
  7286. $.get(window.location.href, res => {
  7287. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7288. });
  7289. } catch (error) {
  7290. throwError(error, 'keyhub.verifyTask');
  7291. }
  7292. }
  7293. }
  7294. function Keyhub_getGiveawayId2() {
  7295. try {
  7296. var _window$location$href;
  7297. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7298. if (giveawayId) {
  7299. this.giveawayId = giveawayId;
  7300. return true;
  7301. }
  7302. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7303. return false;
  7304. } catch (error) {
  7305. throwError(error, 'Keyhub.getGiveawayId');
  7306. return false;
  7307. }
  7308. }
  7309. async function Keyhub_checkLeftKey2() {
  7310. try {
  7311. if (!globalOptions.other.checkLeftKey) {
  7312. return true;
  7313. }
  7314. const leftKey = $('#keysleft').text().trim();
  7315. if (leftKey === '0') {
  7316. await external_Swal_default().fire({
  7317. icon: 'warning',
  7318. title: i18n('notice'),
  7319. text: i18n('noKeysLeft'),
  7320. confirmButtonText: i18n('confirm'),
  7321. cancelButtonText: i18n('cancel'),
  7322. showCancelButton: true
  7323. }).then(_ref => {
  7324. let {
  7325. value
  7326. } = _ref;
  7327. if (value) {
  7328. window.close();
  7329. }
  7330. });
  7331. }
  7332. return true;
  7333. } catch (error) {
  7334. throwError(error, 'Keyhub.checkLeftKey');
  7335. return false;
  7336. }
  7337. }
  7338. function Keyhub_checkLogin2() {
  7339. try {
  7340. if (!globalOptions.other.checkLogin) {
  7341. return true;
  7342. }
  7343. if ($('a[href*="/connect/steam"]').length > 0) {
  7344. window.open('/connect/steam', '_self');
  7345. }
  7346. return true;
  7347. } catch (error) {
  7348. throwError(error, 'Keyhub.checkLogin');
  7349. return false;
  7350. }
  7351. }
  7352. const website_Keyhub = Keyhub;
  7353. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7354. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7355. privateSet.add(obj);
  7356. }
  7357. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7358. if (privateCollection.has(obj)) {
  7359. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7360. }
  7361. }
  7362. function Givekey_defineProperty(obj, key, value) {
  7363. if (key in obj) {
  7364. Object.defineProperty(obj, key, {
  7365. value: value,
  7366. enumerable: true,
  7367. configurable: true,
  7368. writable: true
  7369. });
  7370. } else {
  7371. obj[key] = value;
  7372. }
  7373. return obj;
  7374. }
  7375. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7376. if (!privateSet.has(receiver)) {
  7377. throw new TypeError('attempted to get private field on non-instance');
  7378. }
  7379. return fn;
  7380. }
  7381. const Givekey_defaultTasks = {
  7382. steam: {
  7383. groupLinks: [],
  7384. wishlistLinks: [],
  7385. curatorLinks: [],
  7386. curatorLikeLinks: []
  7387. },
  7388. twitter: {
  7389. userLinks: []
  7390. },
  7391. vk: {
  7392. nameLinks: []
  7393. },
  7394. discord: {
  7395. serverLinks: []
  7396. }
  7397. };
  7398. var Givekey_verify = new WeakSet();
  7399. var Givekey_getGiveawayId = new WeakSet();
  7400. var Givekey_checkLeftKey = new WeakSet();
  7401. class Givekey extends website_Website {
  7402. constructor() {
  7403. super(...arguments);
  7404. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7405. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7406. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7407. Givekey_defineProperty(this, 'name', 'Givekey');
  7408. Givekey_defineProperty(this, 'tasks', []);
  7409. Givekey_defineProperty(this, 'socialTasks', {
  7410. ...Givekey_defaultTasks
  7411. });
  7412. Givekey_defineProperty(this, 'undoneTasks', {
  7413. ...Givekey_defaultTasks
  7414. });
  7415. Givekey_defineProperty(this, 'userId', void 0);
  7416. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7417. }
  7418. static test() {
  7419. return window.location.host === 'givekey.ru';
  7420. }
  7421. async after() {
  7422. try {
  7423. await new Promise(resolve => {
  7424. const checker = setInterval(() => {
  7425. if ($('#navbarDropdown').length > 0) {
  7426. clearInterval(checker);
  7427. resolve(true);
  7428. }
  7429. });
  7430. });
  7431. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7432. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7433. }
  7434. } catch (error) {
  7435. throwError(error, 'Givekey.after');
  7436. return false;
  7437. }
  7438. }
  7439. init() {
  7440. try {
  7441. const logStatus = scripts_echoLog({
  7442. text: i18n('initing')
  7443. });
  7444. if ($('a[href*="/auth/steam"]').length > 0) {
  7445. window.open('/auth/steam', '_self');
  7446. logStatus.warning(i18n('needLogin'));
  7447. return false;
  7448. }
  7449. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7450. return false;
  7451. }
  7452. const userId = $('meta[name="user-id"]').attr('content');
  7453. if (!userId) {
  7454. logStatus.error(i18n('getFailed', i18n('userId')));
  7455. return false;
  7456. }
  7457. this.userId = userId;
  7458. this.initialized = true;
  7459. logStatus.success();
  7460. return true;
  7461. } catch (error) {
  7462. throwError(error, 'Givekey.init');
  7463. return false;
  7464. }
  7465. }
  7466. async classifyTask(action) {
  7467. try {
  7468. const logStatus = scripts_echoLog({
  7469. text: i18n('getTasksInfo')
  7470. });
  7471. if (action === 'undo') {
  7472. var _GM_getValue;
  7473. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || Givekey_defaultTasks;
  7474. }
  7475. const tasks = $('.card-body:has("button") .row');
  7476. for (const task of tasks) {
  7477. const taskEle = $(task);
  7478. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7479. if (isSuccess && action !== 'undo') {
  7480. continue;
  7481. }
  7482. const checkButton = taskEle.find('#task_check');
  7483. const taskId = checkButton.attr('data-id');
  7484. if (taskId) {
  7485. this.tasks.push(taskId);
  7486. }
  7487. if (action === 'verify') {
  7488. continue;
  7489. }
  7490. let href = taskEle.find('a').attr('href') || null;
  7491. const text = taskEle.find('a').text().trim();
  7492. const icon = taskEle.find('i');
  7493. if (!href || !text) {
  7494. continue;
  7495. }
  7496. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7497. href = await getRedirectLink(href);
  7498. }
  7499. if (!href) {
  7500. continue;
  7501. }
  7502. if (/^https?:\/\/vk\.com\//.test(href)) {
  7503. this.socialTasks.vk.nameLinks.push(href);
  7504. if (action === 'do' && !isSuccess) {
  7505. this.undoneTasks.vk.nameLinks.push(href);
  7506. }
  7507. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7508. this.socialTasks.steam.groupLinks.push(href);
  7509. if (action === 'do' && !isSuccess) {
  7510. this.undoneTasks.steam.groupLinks.push(href);
  7511. }
  7512. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7513. this.socialTasks.steam.wishlistLinks.push(href);
  7514. if (action === 'do' && !isSuccess) {
  7515. this.undoneTasks.steam.wishlistLinks.push(href);
  7516. }
  7517. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7518. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7519. this.socialTasks.steam.curatorLinks.push(href);
  7520. if (action === 'do' && !isSuccess) {
  7521. this.undoneTasks.steam.curatorLinks.push(href);
  7522. }
  7523. } else {
  7524. this.socialTasks.steam.curatorLikeLinks.push(href);
  7525. if (action === 'do' && !isSuccess) {
  7526. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7527. }
  7528. }
  7529. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7530. this.socialTasks.twitter.userLinks.push(href);
  7531. if (action === 'do' && !isSuccess) {
  7532. this.undoneTasks.twitter.userLinks.push(href);
  7533. }
  7534. } else if (icon.hasClass('fa-discord')) {
  7535. this.socialTasks.discord.serverLinks.push(href);
  7536. if (action === 'do' && !isSuccess) {
  7537. this.undoneTasks.discord.serverLinks.push(href);
  7538. }
  7539. } else {
  7540. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7541. }
  7542. }
  7543. logStatus.success();
  7544. this.tasks = unique(this.tasks);
  7545. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7546. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7547. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7548. tasks: this.socialTasks,
  7549. time: new Date().getTime()
  7550. });
  7551. return true;
  7552. } catch (error) {
  7553. throwError(error, 'Givekey.classifyTask');
  7554. return false;
  7555. }
  7556. }
  7557. async verifyTask() {
  7558. try {
  7559. if (!this.initialized && !this.init()) {
  7560. return false;
  7561. }
  7562. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7563. return false;
  7564. }
  7565. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7566. const taskLength = this.tasks.length;
  7567. for (let i = 0; i < taskLength; i++) {
  7568. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7569. if (i < taskLength - 1) {
  7570. await delay(15e3);
  7571. }
  7572. }
  7573. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7574. scripts_echoLog({
  7575. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7576. });
  7577. return true;
  7578. } catch (error) {
  7579. throwError(error, 'Givekey.verifyTask');
  7580. return false;
  7581. }
  7582. }
  7583. }
  7584. async function Givekey_verify2(task) {
  7585. try {
  7586. const logStatus = scripts_echoLog({
  7587. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7588. });
  7589. return await new Promise(resolve => {
  7590. $.ajax({
  7591. url: 'https://givekey.ru/giveaway/task',
  7592. method: 'POST',
  7593. data: `id=${task}&user_id=${this.userId}`,
  7594. dataType: 'json',
  7595. headers: {
  7596. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7597. },
  7598. success: data => {
  7599. if (data.btn) {
  7600. $(`button[data-id=${this.userId}]`).html(data.btn);
  7601. }
  7602. if (data.status === 'ok') {
  7603. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7604. logStatus.success();
  7605. resolve(true);
  7606. } else if (data.status === 'end') {
  7607. logStatus.success();
  7608. scripts_echoLog({}).success(data.key);
  7609. resolve(true);
  7610. } else {
  7611. logStatus.error(`Error:${data.msg}`);
  7612. resolve(false);
  7613. }
  7614. },
  7615. error: xhr => {
  7616. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7617. resolve(false);
  7618. }
  7619. });
  7620. });
  7621. } catch (error) {
  7622. throwError(error, 'Givekey.verify');
  7623. return false;
  7624. }
  7625. }
  7626. function Givekey_getGiveawayId2() {
  7627. try {
  7628. var _window$location$href;
  7629. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7630. if (giveawayId) {
  7631. this.giveawayId = giveawayId;
  7632. return true;
  7633. }
  7634. scripts_echoLog({
  7635. text: i18n('getFailed', 'GiveawayId')
  7636. });
  7637. return false;
  7638. } catch (error) {
  7639. throwError(error, 'Givekey.getGiveawayId');
  7640. return false;
  7641. }
  7642. }
  7643. async function Givekey_checkLeftKey2() {
  7644. try {
  7645. if (!globalOptions.other.checkLeftKey) {
  7646. return true;
  7647. }
  7648. if (!$('#keys_count').text()) {
  7649. await external_Swal_default().fire({
  7650. icon: 'warning',
  7651. title: i18n('notice'),
  7652. text: i18n('noKeysLeft'),
  7653. confirmButtonText: i18n('confirm'),
  7654. cancelButtonText: i18n('cancel'),
  7655. showCancelButton: true
  7656. }).then(_ref => {
  7657. let {
  7658. value
  7659. } = _ref;
  7660. if (value) {
  7661. window.close();
  7662. }
  7663. });
  7664. }
  7665. return true;
  7666. } catch (error) {
  7667. throwError(error, 'Givekey.checkLeftKey');
  7668. return false;
  7669. }
  7670. }
  7671. const website_Givekey = Givekey;
  7672. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7673. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7674. privateSet.add(obj);
  7675. }
  7676. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7677. if (privateCollection.has(obj)) {
  7678. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7679. }
  7680. }
  7681. function GiveeClub_defineProperty(obj, key, value) {
  7682. if (key in obj) {
  7683. Object.defineProperty(obj, key, {
  7684. value: value,
  7685. enumerable: true,
  7686. configurable: true,
  7687. writable: true
  7688. });
  7689. } else {
  7690. obj[key] = value;
  7691. }
  7692. return obj;
  7693. }
  7694. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7695. if (!privateSet.has(receiver)) {
  7696. throw new TypeError('attempted to get private field on non-instance');
  7697. }
  7698. return fn;
  7699. }
  7700. var GiveeClub_checkLogin = new WeakSet();
  7701. var GiveeClub_getGiveawayId = new WeakSet();
  7702. var GiveeClub_checkLeftKey = new WeakSet();
  7703. class GiveeClub extends GiveawaySu {
  7704. constructor() {
  7705. super(...arguments);
  7706. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7707. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7708. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7709. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7710. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7711. }
  7712. static test() {
  7713. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7714. }
  7715. async after() {
  7716. try {
  7717. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7718. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7719. }
  7720. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7721. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7722. }
  7723. } catch (error) {
  7724. throwError(error, 'GiveeClub.after');
  7725. }
  7726. }
  7727. init() {
  7728. try {
  7729. const logStatus = scripts_echoLog({
  7730. text: i18n('initing')
  7731. });
  7732. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7733. logStatus.warning(i18n('needLogin'));
  7734. return false;
  7735. }
  7736. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7737. return false;
  7738. }
  7739. this.initialized = true;
  7740. logStatus.success();
  7741. return true;
  7742. } catch (error) {
  7743. throwError(error, 'GiveeClub.init');
  7744. return false;
  7745. }
  7746. }
  7747. async classifyTask(action) {
  7748. try {
  7749. const logStatus = scripts_echoLog({
  7750. text: i18n('getTasksInfo')
  7751. });
  7752. if (action === 'undo') {
  7753. var _GM_getValue;
  7754. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7755. return true;
  7756. }
  7757. const pro = [];
  7758. const tasks = $('.event-actions tr');
  7759. for (const task of tasks) {
  7760. pro.push(new Promise(resolve => {
  7761. const taskDes = $(task).find('.event-action-label a');
  7762. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7763. const taskName = taskDes.text().trim();
  7764. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7765. return resolve(true);
  7766. }
  7767. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7768. if (!taskLink) {
  7769. return resolve(false);
  7770. }
  7771. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7772. this.undoneTasks.steam.groupLinks.push(taskLink);
  7773. } else if (/like.*announcement/gi.test(taskName)) {
  7774. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7775. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7776. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7777. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7778. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7779. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7780. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7781. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7782. this.undoneTasks.steam.forumLinks.push(taskLink);
  7783. } else if (taskIcon.includes('discord')) {
  7784. this.undoneTasks.discord.serverLinks.push(taskLink);
  7785. } else if (taskIcon.includes('instagram')) {
  7786. this.undoneTasks.instagram.userLinks.push(taskLink);
  7787. } else if (taskIcon.includes('twitch')) {
  7788. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7789. } else if (taskIcon.includes('reddit')) {
  7790. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7791. } else if (/watch.*art/gim.test(taskName)) {
  7792. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7793. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7794. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7795. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7796. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7797. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7798. this.undoneTasks.vk.nameLinks.push(taskLink);
  7799. } else {
  7800. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7801. if (/follow.*button/gim.test(taskName)) {
  7802. this.undoneTasks.steam.followLinks.push(taskLink);
  7803. }
  7804. }
  7805. }
  7806. resolve(true);
  7807. }).catch(error => {
  7808. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7809. return false;
  7810. });
  7811. }));
  7812. }
  7813. await Promise.all(pro);
  7814. logStatus.success();
  7815. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7816. this.socialTasks = this.undoneTasks;
  7817. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7818. tasks: this.socialTasks,
  7819. time: new Date().getTime()
  7820. });
  7821. return true;
  7822. } catch (error) {
  7823. throwError(error, 'GiveeClub.classifyTask');
  7824. return false;
  7825. }
  7826. }
  7827. }
  7828. function GiveeClub_checkLogin2() {
  7829. try {
  7830. if (!globalOptions.other.checkLogin) {
  7831. return true;
  7832. }
  7833. if ($('a[href*="/account/auth"]').length > 0) {
  7834. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7835. }
  7836. return true;
  7837. } catch (error) {
  7838. throwError(error, 'GiveeClub.checkLogin');
  7839. return false;
  7840. }
  7841. }
  7842. function GiveeClub_getGiveawayId2() {
  7843. var _window$location$href;
  7844. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7845. if (giveawayId) {
  7846. this.giveawayId = giveawayId;
  7847. return true;
  7848. }
  7849. scripts_echoLog({
  7850. text: i18n('getFailed', 'GiveawayId')
  7851. });
  7852. return false;
  7853. }
  7854. async function GiveeClub_checkLeftKey2() {
  7855. try {
  7856. if (!globalOptions.other.checkLeftKey) {
  7857. return true;
  7858. }
  7859. if ($('.event-ended').length > 0) {
  7860. await external_Swal_default().fire({
  7861. icon: 'warning',
  7862. title: i18n('notice'),
  7863. text: i18n('giveawayEnded'),
  7864. confirmButtonText: i18n('confirm'),
  7865. cancelButtonText: i18n('cancel'),
  7866. showCancelButton: true
  7867. }).then(_ref => {
  7868. let {
  7869. value
  7870. } = _ref;
  7871. if (value) {
  7872. window.close();
  7873. }
  7874. });
  7875. }
  7876. return true;
  7877. } catch (error) {
  7878. throwError(error, 'Giveawaysu.checkLeftKey');
  7879. return false;
  7880. }
  7881. }
  7882. const website_GiveeClub = GiveeClub;
  7883. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  7884. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  7885. privateSet.add(obj);
  7886. }
  7887. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  7888. if (privateCollection.has(obj)) {
  7889. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7890. }
  7891. }
  7892. function OpiumPulses_defineProperty(obj, key, value) {
  7893. if (key in obj) {
  7894. Object.defineProperty(obj, key, {
  7895. value: value,
  7896. enumerable: true,
  7897. configurable: true,
  7898. writable: true
  7899. });
  7900. } else {
  7901. obj[key] = value;
  7902. }
  7903. return obj;
  7904. }
  7905. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  7906. if (!privateSet.has(receiver)) {
  7907. throw new TypeError('attempted to get private field on non-instance');
  7908. }
  7909. return fn;
  7910. }
  7911. const defaultOptions = {
  7912. maxPoint: '99999999'
  7913. };
  7914. var _toggleTask = new WeakSet();
  7915. var OpiumPulses_checkLogin = new WeakSet();
  7916. class OpiumPulses {
  7917. constructor() {
  7918. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  7919. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  7920. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  7921. OpiumPulses_defineProperty(this, 'options', {
  7922. ...defaultOptions,
  7923. ...GM_getValue('OpiumPulsesOptions')
  7924. });
  7925. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  7926. OpiumPulses_defineProperty(this, 'myPoints', 0);
  7927. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  7928. }
  7929. static test() {
  7930. return window.location.host === 'www.opiumpulses.com';
  7931. }
  7932. async after() {
  7933. try {
  7934. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  7935. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7936. }
  7937. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7938. } catch (error) {
  7939. throwError(error, 'OpiumPulses.after');
  7940. }
  7941. }
  7942. async doFreeTask() {
  7943. try {
  7944. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  7945. } catch (error) {
  7946. throwError(error, 'OpiumPulses.doFreeTask');
  7947. }
  7948. }
  7949. async doPointTask() {
  7950. try {
  7951. var _$$text$match;
  7952. 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);
  7953. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  7954. } catch (error) {
  7955. throwError(error, 'OpiumPulses.doPointTask');
  7956. }
  7957. }
  7958. init() {
  7959. return true;
  7960. }
  7961. classifyTask() {
  7962. return true;
  7963. }
  7964. }
  7965. async function _toggleTask2(type) {
  7966. try {
  7967. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7968. for (const item of items) {
  7969. var _$$find$text$match;
  7970. 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);
  7971. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7972. if (type === 'points' && needPoints > this.myPoints) {
  7973. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7974. } else if (type === 'points' && !needPoints) {
  7975. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  7976. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  7977. var _aElement$attr;
  7978. const logStatus = scripts_echoLog({
  7979. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  7980. });
  7981. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  7982. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  7983. var _aElement$attr2, _aElement$attr2$match;
  7984. 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];
  7985. if (giveawayId) {
  7986. checkUser(giveawayId);
  7987. }
  7988. }
  7989. if (!aElement.attr('href')) {
  7990. logStatus.error('Error: No "href".');
  7991. continue;
  7992. }
  7993. const {
  7994. result,
  7995. statusText,
  7996. status,
  7997. data
  7998. } = await tools_httpRequest({
  7999. url: aElement.attr('href'),
  8000. method: 'GET'
  8001. });
  8002. if (result === 'Success') {
  8003. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8004. var _data$responseText$ma;
  8005. logStatus.success();
  8006. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8007. if (type === 'points' && points) {
  8008. this.myPoints = parseInt(points, 10);
  8009. }
  8010. } else {
  8011. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8012. }
  8013. } else {
  8014. logStatus.error(`${result}:${statusText}(${status})`);
  8015. }
  8016. }
  8017. }
  8018. scripts_echoLog({
  8019. text: '-----END-----'
  8020. });
  8021. } catch (error) {
  8022. throwError(error, 'OpiumPulses.toggleTask');
  8023. }
  8024. }
  8025. function OpiumPulses_checkLogin2() {
  8026. try {
  8027. if (!globalOptions.other.checkLogin) {
  8028. return true;
  8029. }
  8030. if ($('a[href*="/site/login"]').length > 1) {
  8031. window.open('/site/login', '_self');
  8032. }
  8033. return true;
  8034. } catch (error) {
  8035. throwError(error, 'OpiumPulses.checkLogin');
  8036. return false;
  8037. }
  8038. }
  8039. const website_OpiumPulses = OpiumPulses;
  8040. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8041. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8042. privateSet.add(obj);
  8043. }
  8044. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8045. if (privateCollection.has(obj)) {
  8046. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8047. }
  8048. }
  8049. function Keylol_defineProperty(obj, key, value) {
  8050. if (key in obj) {
  8051. Object.defineProperty(obj, key, {
  8052. value: value,
  8053. enumerable: true,
  8054. configurable: true,
  8055. writable: true
  8056. });
  8057. } else {
  8058. obj[key] = value;
  8059. }
  8060. return obj;
  8061. }
  8062. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8063. if (!privateSet.has(receiver)) {
  8064. throw new TypeError('attempted to get private field on non-instance');
  8065. }
  8066. return fn;
  8067. }
  8068. const Keylol_defaultTasks = {
  8069. steam: {
  8070. groupLinks: [],
  8071. wishlistLinks: [],
  8072. curatorLinks: [],
  8073. curatorLikeLinks: [],
  8074. followLinks: [],
  8075. forumLinks: [],
  8076. announcementLinks: [],
  8077. workshopVoteLinks: []
  8078. },
  8079. discord: {
  8080. serverLinks: []
  8081. },
  8082. instagram: {
  8083. userLinks: []
  8084. },
  8085. vk: {
  8086. nameLinks: []
  8087. },
  8088. twitch: {
  8089. channelLinks: []
  8090. },
  8091. reddit: {
  8092. redditLinks: []
  8093. },
  8094. twitter: {
  8095. userLinks: [],
  8096. retweetLinks: []
  8097. },
  8098. youtube: {
  8099. channelLinks: [],
  8100. likeLinks: []
  8101. }
  8102. };
  8103. var _addBtn = new WeakSet();
  8104. class Keylol extends website_Website {
  8105. constructor() {
  8106. super(...arguments);
  8107. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8108. Keylol_defineProperty(this, 'name', 'Keylol');
  8109. Keylol_defineProperty(this, 'socialTasks', {
  8110. ...Keylol_defaultTasks
  8111. });
  8112. Keylol_defineProperty(this, 'undoneTasks', {
  8113. ...Keylol_defaultTasks
  8114. });
  8115. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8116. }
  8117. static test() {
  8118. var _$$eq$attr;
  8119. 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'));
  8120. }
  8121. init() {
  8122. return true;
  8123. }
  8124. after() {
  8125. try {
  8126. const selecter = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8127. const mainPost = $(selecter);
  8128. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8129. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8130. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8131. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8132. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8133. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8134. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8135. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8136. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8137. if (discordLinks.length > 0) {
  8138. for (const discordLink of discordLinks) {
  8139. const link = $(discordLink).attr('href');
  8140. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8141. continue;
  8142. }
  8143. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8144. }
  8145. }
  8146. if (redditLinks.length > 0) {
  8147. for (const redditLink of redditLinks) {
  8148. const link = $(redditLink).attr('href');
  8149. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8150. continue;
  8151. }
  8152. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8153. }
  8154. }
  8155. if (insLinks.length > 0) {
  8156. for (const insLink of insLinks) {
  8157. const link = $(insLink).attr('href');
  8158. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8159. continue;
  8160. }
  8161. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8162. }
  8163. }
  8164. if (twitterLinks.length > 0) {
  8165. for (const twitterLink of twitterLinks) {
  8166. const link = $(twitterLink).attr('href');
  8167. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8168. continue;
  8169. }
  8170. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8171. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8172. } else {
  8173. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8174. }
  8175. }
  8176. }
  8177. if (twitchLinks.length > 0) {
  8178. for (const twitchLink of twitchLinks) {
  8179. const link = $(twitchLink).attr('href');
  8180. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8181. continue;
  8182. }
  8183. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8184. }
  8185. }
  8186. if (vkLinks.length > 0) {
  8187. for (const vkLink of vkLinks) {
  8188. const link = $(vkLink).attr('href');
  8189. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8190. continue;
  8191. }
  8192. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8193. }
  8194. }
  8195. if (steamStoreLinks.length > 0) {
  8196. for (const steamStoreLink of steamStoreLinks) {
  8197. const link = $(steamStoreLink).attr('href');
  8198. if (!link) {
  8199. continue;
  8200. }
  8201. if (/app\/[\d]+/.test(link)) {
  8202. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8203. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8204. } else if (/curator\/[\d]+/.test(link)) {
  8205. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8206. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8207. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8208. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8209. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8210. }
  8211. }
  8212. }
  8213. if (steamCommunityLinks.length > 0) {
  8214. for (const steamCommunityLink of steamCommunityLinks) {
  8215. const link = $(steamCommunityLink).attr('href');
  8216. if (!link) {
  8217. continue;
  8218. }
  8219. if (/groups\/.+/.test(link)) {
  8220. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8221. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8222. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8223. }
  8224. }
  8225. }
  8226. if (ytbLinks.length > 0) {
  8227. for (const ytbLink of ytbLinks) {
  8228. const link = $(ytbLink).attr('href');
  8229. if (!link) {
  8230. continue;
  8231. }
  8232. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8233. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8234. }
  8235. }
  8236. } catch (error) {
  8237. throwError(error, 'keylol.after');
  8238. }
  8239. }
  8240. classifyTask(action) {
  8241. try {
  8242. this.socialTasks = {
  8243. ...Keylol_defaultTasks
  8244. };
  8245. this.undoneTasks = {
  8246. ...Keylol_defaultTasks
  8247. };
  8248. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8249. for (const btn of selectedBtns) {
  8250. const button = $(btn);
  8251. const social = button.attr('data-social');
  8252. const type = button.attr('data-type');
  8253. const link = button.attr('data-link');
  8254. if (!(social && type && link)) {
  8255. continue;
  8256. }
  8257. if (action === 'do') {
  8258. this.undoneTasks[social][type].push(link);
  8259. }
  8260. if (action === 'undo') {
  8261. this.socialTasks[social][type].push(link);
  8262. }
  8263. }
  8264. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8265. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8266. return true;
  8267. } catch (error) {
  8268. throwError(error, 'Keylol.classifyTask');
  8269. return false;
  8270. }
  8271. }
  8272. selectAll() {
  8273. try {
  8274. $('.auto-task-keylol').attr('selected', 'selected');
  8275. } catch (error) {
  8276. throwError(error, 'Keylol.selectAll');
  8277. }
  8278. }
  8279. selectNone() {
  8280. try {
  8281. $('.auto-task-keylol').removeAttr('selected');
  8282. } catch (error) {
  8283. throwError(error, 'Keylol.selectNone');
  8284. }
  8285. }
  8286. invertSelect() {
  8287. try {
  8288. $('.auto-task-keylol').each((index, element) => {
  8289. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8290. });
  8291. } catch (error) {
  8292. throwError(error, 'Keylol.invertSelect');
  8293. }
  8294. }
  8295. }
  8296. function _addBtn2(before, social, linkType, link) {
  8297. try {
  8298. $(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>`);
  8299. } catch (error) {
  8300. throwError(error, 'keylol.addBtn');
  8301. }
  8302. }
  8303. const website_Keylol = Keylol;
  8304. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8305. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8306. privateSet.add(obj);
  8307. }
  8308. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8309. if (privateCollection.has(obj)) {
  8310. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8311. }
  8312. }
  8313. function Opquests_defineProperty(obj, key, value) {
  8314. if (key in obj) {
  8315. Object.defineProperty(obj, key, {
  8316. value: value,
  8317. enumerable: true,
  8318. configurable: true,
  8319. writable: true
  8320. });
  8321. } else {
  8322. obj[key] = value;
  8323. }
  8324. return obj;
  8325. }
  8326. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8327. if (!privateSet.has(receiver)) {
  8328. throw new TypeError('attempted to get private field on non-instance');
  8329. }
  8330. return fn;
  8331. }
  8332. const Opquests_defaultTasks = {
  8333. steam: {
  8334. groupLinks: [],
  8335. wishlistLinks: [],
  8336. followLinks: [],
  8337. curatorLikeLinks: []
  8338. }
  8339. };
  8340. var Opquests_getGiveawayId = new WeakSet();
  8341. var Opquests_checkLogin = new WeakSet();
  8342. class Opquests extends website_Website {
  8343. constructor() {
  8344. super(...arguments);
  8345. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8346. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8347. Opquests_defineProperty(this, 'name', 'Opquests');
  8348. Opquests_defineProperty(this, 'undoneTasks', {
  8349. ...Opquests_defaultTasks
  8350. });
  8351. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8352. }
  8353. static test() {
  8354. return window.location.host === 'opquests.com';
  8355. }
  8356. async after() {
  8357. try {
  8358. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8359. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8360. }
  8361. } catch (error) {
  8362. throwError(error, 'Opquests.after');
  8363. }
  8364. }
  8365. init() {
  8366. try {
  8367. const logStatus = scripts_echoLog({
  8368. text: i18n('initing')
  8369. });
  8370. if ($('a[href*="/auth/redirect"]').length > 0) {
  8371. window.open('/auth/redirect', '_self');
  8372. logStatus.warning(i18n('needLogin'));
  8373. return false;
  8374. }
  8375. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8376. return false;
  8377. }
  8378. this.initialized = true;
  8379. logStatus.success();
  8380. return true;
  8381. } catch (error) {
  8382. throwError(error, 'Opquests.init');
  8383. return false;
  8384. }
  8385. }
  8386. async classifyTask(action) {
  8387. try {
  8388. if (action === 'undo') {
  8389. scripts_echoLog({
  8390. text: i18n('cannotUndo')
  8391. });
  8392. return false;
  8393. }
  8394. const logStatus = scripts_echoLog({
  8395. text: i18n('getTasksInfo')
  8396. });
  8397. const tasks = $('.w-full:contains("Validate") .items-center');
  8398. for (const task of tasks) {
  8399. const link = $(task).find('a:contains("Open")').attr('href');
  8400. const taskDes = $(task).find('div').eq(1).text().trim();
  8401. if (!link) {
  8402. continue;
  8403. }
  8404. if (/steamcommunity\.com\/groups\//.test(link)) {
  8405. this.undoneTasks.steam.groupLinks.push(link);
  8406. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8407. if (/wishlist/gim.test(taskDes)) {
  8408. this.undoneTasks.steam.wishlistLinks.push(link);
  8409. } else if (/follow/gim.test(taskDes)) {
  8410. this.undoneTasks.steam.followLinks.push(link);
  8411. }
  8412. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8413. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8414. } else {
  8415. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8416. }
  8417. }
  8418. logStatus.success();
  8419. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8420. return true;
  8421. } catch (error) {
  8422. throwError(error, 'Opquests.classifyTask');
  8423. return false;
  8424. }
  8425. }
  8426. }
  8427. function Opquests_getGiveawayId2() {
  8428. try {
  8429. var _window$location$href;
  8430. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8431. if (giveawayId) {
  8432. this.giveawayId = giveawayId;
  8433. return true;
  8434. }
  8435. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8436. return false;
  8437. } catch (error) {
  8438. throwError(error, 'Opquests.getGiveawayId');
  8439. return false;
  8440. }
  8441. }
  8442. function Opquests_checkLogin2() {
  8443. try {
  8444. if (!globalOptions.other.checkLogin) {
  8445. return true;
  8446. }
  8447. if ($('a[href*="/auth/redirect"]').length > 0) {
  8448. window.open('/auth/redirect', '_self');
  8449. }
  8450. return true;
  8451. } catch (error) {
  8452. throwError(error, 'Opquests.checkLogin');
  8453. return false;
  8454. }
  8455. }
  8456. const website_Opquests = Opquests;
  8457. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8458. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8459. privateSet.add(obj);
  8460. }
  8461. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8462. if (privateCollection.has(obj)) {
  8463. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8464. }
  8465. }
  8466. function Gleam_defineProperty(obj, key, value) {
  8467. if (key in obj) {
  8468. Object.defineProperty(obj, key, {
  8469. value: value,
  8470. enumerable: true,
  8471. configurable: true,
  8472. writable: true
  8473. });
  8474. } else {
  8475. obj[key] = value;
  8476. }
  8477. return obj;
  8478. }
  8479. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8480. if (!privateSet.has(receiver)) {
  8481. throw new TypeError('attempted to get private field on non-instance');
  8482. }
  8483. return fn;
  8484. }
  8485. const Gleam_defaultTasks = {
  8486. steam: {
  8487. groupLinks: [],
  8488. wishlistLinks: [],
  8489. followLinks: [],
  8490. curatorLinks: [],
  8491. curatorLikeLinks: []
  8492. },
  8493. twitter: {
  8494. userLinks: [],
  8495. retweetLinks: []
  8496. },
  8497. twitch: {
  8498. channelLinks: []
  8499. },
  8500. discord: {
  8501. serverLinks: []
  8502. },
  8503. youtube: {
  8504. channelLinks: []
  8505. },
  8506. extra: {
  8507. gleam: []
  8508. }
  8509. };
  8510. const Gleam_defaultOptions = {
  8511. vlootUsername: '',
  8512. gameroundUsername: ''
  8513. };
  8514. var _checkSync = new WeakSet();
  8515. var _doGleamTask = new WeakSet();
  8516. var Gleam_getGiveawayId = new WeakSet();
  8517. var _getGleamLink = new WeakSet();
  8518. var Gleam_checkLeftKey = new WeakSet();
  8519. class Gleam extends website_Website {
  8520. constructor() {
  8521. super(...arguments);
  8522. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8523. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8524. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8525. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8526. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8527. Gleam_defineProperty(this, 'name', 'Gleam');
  8528. Gleam_defineProperty(this, 'undoneTasks', {
  8529. ...Gleam_defaultTasks
  8530. });
  8531. Gleam_defineProperty(this, 'socialTasks', {
  8532. ...Gleam_defaultTasks
  8533. });
  8534. Gleam_defineProperty(this, 'options', {
  8535. ...Gleam_defaultOptions,
  8536. ...GM_getValue('GleamOptions')
  8537. });
  8538. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8539. }
  8540. static test() {
  8541. return window.location.host === 'gleam.io';
  8542. }
  8543. async after() {
  8544. try {
  8545. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8546. const checkComplete = setInterval(() => {
  8547. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8548. clearInterval(checkComplete);
  8549. window.close();
  8550. }
  8551. });
  8552. for (const task of $('.entry-content .entry-method')) {
  8553. const taskInfo = $(task).find('.user-links');
  8554. const expandInfo = $(task).find('.expandable');
  8555. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8556. if (aElements.length > 0) {
  8557. for (const element of aElements) {
  8558. const $element = $(element);
  8559. const href = $element.attr('href');
  8560. $element.removeAttr('href')[0].click();
  8561. $element.attr('href', href);
  8562. await delay(1e3);
  8563. }
  8564. }
  8565. taskInfo[0].click();
  8566. await delay(1e3);
  8567. }
  8568. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8569. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8570. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8571. }
  8572. } catch (error) {
  8573. throwError(error, 'Gleam.after');
  8574. return false;
  8575. }
  8576. }
  8577. init() {
  8578. try {
  8579. const logStatus = scripts_echoLog({
  8580. text: i18n('initing')
  8581. });
  8582. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  8583. return false;
  8584. }
  8585. this.initialized = true;
  8586. logStatus.success();
  8587. return true;
  8588. } catch (error) {
  8589. throwError(error, 'Gleam.init');
  8590. return false;
  8591. }
  8592. }
  8593. async classifyTask(action) {
  8594. try {
  8595. const logStatus = scripts_echoLog({
  8596. text: i18n('getTasksInfo')
  8597. });
  8598. if (action === 'undo') {
  8599. var _GM_getValue;
  8600. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  8601. ...Gleam_defaultTasks
  8602. };
  8603. }
  8604. const tasks = $('.entry-content .entry-method');
  8605. for (const task of tasks) {
  8606. var _socialIcon$attr;
  8607. const $task = $(task);
  8608. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8609. continue;
  8610. }
  8611. const socialIcon = $task.find('.icon-wrapper i');
  8612. const taskInfo = $task.find('.user-links');
  8613. const taskText = taskInfo.text().trim();
  8614. const expandInfo = $task.find('.expandable');
  8615. const aElements = expandInfo.find('a.btn');
  8616. if (aElements.length > 0) {
  8617. for (const element of aElements) {
  8618. const $element = $(element);
  8619. const href = $element.attr('href');
  8620. $element.removeAttr('href')[0].click();
  8621. $element.attr('href', href);
  8622. }
  8623. }
  8624. if (socialIcon.hasClass('fa-twitter')) {
  8625. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8626. if (!link) {
  8627. continue;
  8628. }
  8629. if (/follow/gi.test(taskText)) {
  8630. if (action === 'undo') {
  8631. this.socialTasks.twitter.userLinks.push(link);
  8632. }
  8633. if (action === 'do') {
  8634. this.undoneTasks.twitter.userLinks.push(link);
  8635. }
  8636. } else if (/retweet/gim.test(taskText)) {
  8637. if (action === 'undo') {
  8638. this.socialTasks.twitter.retweetLinks.push(link);
  8639. }
  8640. if (action === 'do') {
  8641. this.undoneTasks.twitter.retweetLinks.push(link);
  8642. }
  8643. }
  8644. } else if (socialIcon.hasClass('fa-twitch')) {
  8645. if (/follow/gim.test(taskText)) {
  8646. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8647. if (!link) {
  8648. continue;
  8649. }
  8650. if (action === 'undo') {
  8651. this.socialTasks.twitch.channelLinks.push(link);
  8652. }
  8653. if (action === 'do') {
  8654. this.undoneTasks.twitch.channelLinks.push(link);
  8655. }
  8656. }
  8657. } else if (socialIcon.hasClass('fa-discord')) {
  8658. if (/join/gim.test(taskText)) {
  8659. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8660. if (!link) {
  8661. var _$task$find$attr, _$task$find$attr$matc;
  8662. 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];
  8663. if (!ggLink) {
  8664. continue;
  8665. }
  8666. link = `https://discord.com/invite/${ggLink}`;
  8667. }
  8668. if (action === 'undo') {
  8669. this.socialTasks.discord.serverLinks.push(link);
  8670. }
  8671. if (action === 'do') {
  8672. this.undoneTasks.discord.serverLinks.push(link);
  8673. }
  8674. }
  8675. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8676. continue;
  8677. } else if (socialIcon.hasClass('fa-youtube')) {
  8678. if (/subscribe/gim.test(taskText)) {
  8679. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8680. if (!link) {
  8681. continue;
  8682. }
  8683. if (action === 'undo') {
  8684. this.socialTasks.youtube.channelLinks.push(link);
  8685. }
  8686. if (action === 'do') {
  8687. this.undoneTasks.youtube.channelLinks.push(link);
  8688. }
  8689. }
  8690. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8691. if (/join.*group/gi.test(taskText)) {
  8692. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8693. if (!link) {
  8694. continue;
  8695. }
  8696. if (action === 'undo') {
  8697. this.socialTasks.steam.groupLinks.push(link);
  8698. }
  8699. if (action === 'do') {
  8700. this.undoneTasks.steam.groupLinks.push(link);
  8701. }
  8702. } else if (/follow.*curator/gi.test(taskText)) {
  8703. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8704. if (!link) {
  8705. continue;
  8706. }
  8707. if (action === 'undo') {
  8708. this.socialTasks.steam.curatorLinks.push(link);
  8709. }
  8710. if (action === 'do') {
  8711. this.undoneTasks.steam.curatorLinks.push(link);
  8712. }
  8713. }
  8714. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  8715. expandInfo.find('input').val(this.options.vlootUsername);
  8716. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8717. expandInfo.find('input').val(this.options.gameroundUsername);
  8718. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  8719. if (action !== 'do') {
  8720. continue;
  8721. }
  8722. const link = aElements.attr('href');
  8723. if (!link) {
  8724. continue;
  8725. }
  8726. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  8727. if (!gleamLink) {
  8728. continue;
  8729. }
  8730. this.undoneTasks.extra.gleam.push(gleamLink);
  8731. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  8732. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  8733. }
  8734. }
  8735. logStatus.success();
  8736. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8737. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8738. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8739. tasks: this.socialTasks,
  8740. time: new Date().getTime()
  8741. });
  8742. return true;
  8743. } catch (error) {
  8744. throwError(error, 'Gleam.classifyTask');
  8745. return false;
  8746. }
  8747. }
  8748. async extraDoTask(_ref) {
  8749. let {
  8750. gleam
  8751. } = _ref;
  8752. try {
  8753. const pro = [];
  8754. for (const link of gleam) {
  8755. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  8756. }
  8757. return Promise.all(pro).then(() => true);
  8758. } catch (error) {
  8759. throwError(error, 'Gleam.extraDoTask');
  8760. return false;
  8761. }
  8762. }
  8763. async verifyTask() {
  8764. try {
  8765. scripts_echoLog({
  8766. text: `${i18n('verifyingTask')}...`
  8767. });
  8768. const tasks = $('.entry-content .entry-method');
  8769. for (const task of tasks) {
  8770. const $task = $(task);
  8771. if ($task.find('i.fa-question').length === 0) {
  8772. continue;
  8773. }
  8774. const taskInfo = $task.find('.user-links');
  8775. taskInfo[0].click();
  8776. await delay(500);
  8777. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8778. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  8779. for (const button of continueBtn) {
  8780. button.click();
  8781. await delay(500);
  8782. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8783. }
  8784. }
  8785. scripts_echoLog({
  8786. text: i18n('verifiedGleamTasks')
  8787. });
  8788. } catch (error) {
  8789. throwError(error, 'Gleam.verifyTask');
  8790. return false;
  8791. }
  8792. }
  8793. }
  8794. async function _checkSync2() {
  8795. try {
  8796. return await new Promise(resolve => {
  8797. const checker = setInterval(() => {
  8798. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  8799. clearInterval(checker);
  8800. resolve(true);
  8801. }
  8802. }, 500);
  8803. });
  8804. } catch (error) {
  8805. throwError(error, 'Gleam.checkSync');
  8806. return false;
  8807. }
  8808. }
  8809. async function _doGleamTask2(link) {
  8810. try {
  8811. const logStatus = scripts_echoLog({
  8812. text: i18n('doingGleamTask')
  8813. });
  8814. return await new Promise(resolve => {
  8815. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  8816. active: true,
  8817. insert: true,
  8818. setParent: true
  8819. }).onclose = () => {
  8820. logStatus.success();
  8821. resolve(true);
  8822. };
  8823. });
  8824. } catch (error) {
  8825. throwError(error, 'Gleam.doGleamTask');
  8826. return false;
  8827. }
  8828. }
  8829. function Gleam_getGiveawayId2() {
  8830. try {
  8831. const giveawayId = window.location.pathname;
  8832. if (giveawayId) {
  8833. this.giveawayId = giveawayId;
  8834. return true;
  8835. }
  8836. scripts_echoLog({
  8837. text: i18n('getFailed', 'GiveawayId')
  8838. });
  8839. return false;
  8840. } catch (error) {
  8841. throwError(error, 'Gleam.getGiveawayId');
  8842. return false;
  8843. }
  8844. }
  8845. async function _getGleamLink2(link) {
  8846. try {
  8847. const logStatus = scripts_echoLog({
  8848. text: i18n('gettingGleamLink')
  8849. });
  8850. const {
  8851. result,
  8852. statusText,
  8853. status,
  8854. data
  8855. } = await tools_httpRequest({
  8856. url: link,
  8857. method: 'GET'
  8858. });
  8859. if (result === 'Success') {
  8860. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  8861. var _data$responseText$ma;
  8862. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8863. if (gleamLink) {
  8864. logStatus.success();
  8865. return gleamLink;
  8866. }
  8867. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  8868. return false;
  8869. }
  8870. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8871. return false;
  8872. }
  8873. logStatus.error(`${result}:${statusText}(${status})`);
  8874. return false;
  8875. } catch (error) {
  8876. throwError(error, 'Gleam.getGleamLink');
  8877. return false;
  8878. }
  8879. }
  8880. async function Gleam_checkLeftKey2() {
  8881. try {
  8882. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  8883. if (!globalOptions.other.checkLeftKey) {
  8884. return true;
  8885. }
  8886. 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];
  8887. if (!campaignString) {
  8888. return false;
  8889. }
  8890. const {
  8891. campaign,
  8892. incentive
  8893. } = JSON.parse(campaignString);
  8894. 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];
  8895. let ownedKey = false;
  8896. if (controllerString) {
  8897. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  8898. 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) {
  8899. ownedKey = true;
  8900. }
  8901. }
  8902. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  8903. await external_Swal_default().fire({
  8904. icon: 'warning',
  8905. title: i18n('notice'),
  8906. text: i18n('giveawayNotWork'),
  8907. confirmButtonText: i18n('confirm'),
  8908. cancelButtonText: i18n('cancel'),
  8909. showCancelButton: true
  8910. }).then(_ref2 => {
  8911. let {
  8912. value
  8913. } = _ref2;
  8914. if (value) {
  8915. window.close();
  8916. }
  8917. });
  8918. }
  8919. return true;
  8920. } catch (error) {
  8921. throwError(error, 'Gleam.checkLeftKey');
  8922. return false;
  8923. }
  8924. }
  8925. const website_Gleam = Gleam;
  8926. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  8927. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  8928. privateSet.add(obj);
  8929. }
  8930. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  8931. if (privateCollection.has(obj)) {
  8932. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8933. }
  8934. }
  8935. function SweepWidget_defineProperty(obj, key, value) {
  8936. if (key in obj) {
  8937. Object.defineProperty(obj, key, {
  8938. value: value,
  8939. enumerable: true,
  8940. configurable: true,
  8941. writable: true
  8942. });
  8943. } else {
  8944. obj[key] = value;
  8945. }
  8946. return obj;
  8947. }
  8948. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  8949. if (!privateSet.has(receiver)) {
  8950. throw new TypeError('attempted to get private field on non-instance');
  8951. }
  8952. return fn;
  8953. }
  8954. const SweepWidget_defaultOptions = {
  8955. username: '',
  8956. email: ''
  8957. };
  8958. var SweepWidget_checkLogin = new WeakSet();
  8959. var SweepWidget_getGiveawayId = new WeakSet();
  8960. var _checkEnter = new WeakSet();
  8961. var _checkFinish = new WeakSet();
  8962. class SweepWidget extends website_Website {
  8963. constructor() {
  8964. super(...arguments);
  8965. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  8966. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  8967. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  8968. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  8969. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  8970. SweepWidget_defineProperty(this, 'options', {
  8971. ...SweepWidget_defaultOptions,
  8972. ...GM_getValue('SweepWidgetOptions')
  8973. });
  8974. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  8975. }
  8976. static test() {
  8977. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  8978. }
  8979. async after() {
  8980. try {
  8981. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  8982. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8983. }
  8984. } catch (error) {
  8985. throwError(error, 'SweepWidget.after');
  8986. }
  8987. }
  8988. init() {
  8989. try {
  8990. const logStatus = scripts_echoLog({
  8991. text: i18n('initing')
  8992. });
  8993. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  8994. logStatus.warning(i18n('needLogin'));
  8995. return false;
  8996. }
  8997. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  8998. return false;
  8999. }
  9000. this.initialized = true;
  9001. logStatus.success();
  9002. return true;
  9003. } catch (error) {
  9004. throwError(error, 'SweepWidget.init');
  9005. return false;
  9006. }
  9007. }
  9008. classifyTask() {
  9009. return true;
  9010. }
  9011. async doTask() {
  9012. try {
  9013. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9014. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9015. $('input[name="sw__login_name"]').val(this.options.username);
  9016. }
  9017. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9018. $('input[name="sw__login_email"]').val(this.options.email);
  9019. }
  9020. if ($('#sw_login_button:visible').length > 0) {
  9021. $('#sw_login_button')[0].click();
  9022. }
  9023. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9024. return false;
  9025. }
  9026. }
  9027. const logStatus = scripts_echoLog({
  9028. text: i18n('SweepWidgetNotice')
  9029. });
  9030. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9031. for (const task of tasks) {
  9032. var _aElement$, _$task$find$removeAtt;
  9033. const $task = $(task);
  9034. if ($task.find('i.fa-check:visible').length > 0) {
  9035. continue;
  9036. }
  9037. const title = $task.find('.sw_text_inner');
  9038. title[0].click();
  9039. const aElement = $task.find('a.sw_link');
  9040. const link = aElement.attr('href');
  9041. aElement.attr('href', '#a').attr('target', '_self');
  9042. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9043. await delay(300);
  9044. aElement.attr('href', link).attr('target', '_blank');
  9045. $task.find('input[type="text"]').val('test');
  9046. const verifyBtn = $task.find('input.sw_verify');
  9047. if (verifyBtn.prop('disabled') === true) {
  9048. title[0].click();
  9049. await delay(300);
  9050. title[0].click();
  9051. await delay(300);
  9052. }
  9053. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9054. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9055. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9056. }
  9057. logStatus.success();
  9058. return true;
  9059. } catch (error) {
  9060. throwError(error, 'SweepWidget.doTask');
  9061. return false;
  9062. }
  9063. }
  9064. }
  9065. function SweepWidget_checkLogin2() {
  9066. try {
  9067. if ($('#twitter_login_button').length > 0) {
  9068. $('#twitter_login_button')[0].click();
  9069. }
  9070. return true;
  9071. } catch (error) {
  9072. throwError(error, 'SweepWidget.checkLogin');
  9073. return false;
  9074. }
  9075. }
  9076. function SweepWidget_getGiveawayId2() {
  9077. try {
  9078. var _window$location$href;
  9079. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9080. if (giveawayId) {
  9081. this.giveawayId = giveawayId;
  9082. return true;
  9083. }
  9084. scripts_echoLog({
  9085. text: i18n('getFailed', 'GiveawayId')
  9086. });
  9087. return false;
  9088. } catch (error) {
  9089. throwError(error, 'SweepWidget.getGiveawayId');
  9090. return false;
  9091. }
  9092. }
  9093. async function _checkEnter2() {
  9094. try {
  9095. return new Promise(resolve => {
  9096. const checker = setInterval(() => {
  9097. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9098. clearInterval(checker);
  9099. resolve(true);
  9100. }
  9101. });
  9102. });
  9103. } catch (error) {
  9104. throwError(error, 'SweepWidget.checkEnter');
  9105. return false;
  9106. }
  9107. }
  9108. async function _checkFinish2($task) {
  9109. try {
  9110. return new Promise(resolve => {
  9111. const checker = setInterval(() => {
  9112. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9113. clearInterval(checker);
  9114. resolve(true);
  9115. }
  9116. });
  9117. });
  9118. } catch (error) {
  9119. throwError(error, 'SweepWidget.checkFinish');
  9120. return false;
  9121. }
  9122. }
  9123. const website_SweepWidget = SweepWidget;
  9124. const defaultWhiteList = {
  9125. discord: {
  9126. servers: []
  9127. },
  9128. instagram: {
  9129. users: []
  9130. },
  9131. twitch: {
  9132. channels: []
  9133. },
  9134. twitter: {
  9135. users: [],
  9136. retweets: [],
  9137. likes: []
  9138. },
  9139. vk: {
  9140. names: []
  9141. },
  9142. youtube: {
  9143. channels: [],
  9144. likes: []
  9145. },
  9146. reddit: {
  9147. reddits: []
  9148. },
  9149. steam: {
  9150. groups: [],
  9151. wishlists: [],
  9152. follows: [],
  9153. forums: [],
  9154. workshops: [],
  9155. curators: [],
  9156. workshopVotes: [],
  9157. curatorLikes: [],
  9158. announcements: []
  9159. }
  9160. };
  9161. const link2id = async function(type) {
  9162. 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;
  9163. try {
  9164. const link = $('#socialLink').val();
  9165. let id = '';
  9166. switch (type) {
  9167. case 'discord.servers':
  9168. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9169. break;
  9170.  
  9171. case 'instagram.users':
  9172. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9173. break;
  9174.  
  9175. case 'twitch.channels':
  9176. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9177. break;
  9178.  
  9179. case 'twitter.users':
  9180. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9181. break;
  9182.  
  9183. case 'twitter.retweets':
  9184. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9185. break;
  9186.  
  9187. case 'vk.names':
  9188. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9189. break;
  9190.  
  9191. case 'youtube.channels':
  9192. 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) || '';
  9193. break;
  9194.  
  9195. case 'youtube.likes':
  9196. 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) || '';
  9197. break;
  9198.  
  9199. case 'reddit.reddits':
  9200. 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]) || '';
  9201. break;
  9202.  
  9203. case 'steam.groups':
  9204. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9205. break;
  9206.  
  9207. case 'steam.wishlists':
  9208. case 'steam.follows':
  9209. case 'steam.forums':
  9210. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9211. break;
  9212.  
  9213. case 'steam.workshops':
  9214. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9215. break;
  9216.  
  9217. case 'steam.curators':
  9218. {
  9219. if (link.includes('curator')) {
  9220. var _link$match12;
  9221. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9222. } else {
  9223. var _link$match13;
  9224. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9225. if (!param || param.length !== 2) {
  9226. break;
  9227. }
  9228. const steam = new social_Steam();
  9229. if (await steam.init()) {
  9230. id = await steam.getCuratorId(param[0], param[1]) || '';
  9231. }
  9232. }
  9233. }
  9234. break;
  9235. }
  9236. return id;
  9237. } catch (error) {
  9238. throwError(error, 'link2id');
  9239. return i18n('getFailed', 'id');
  9240. }
  9241. };
  9242. const disabledType = {
  9243. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9244. twitter: [ 'likes' ]
  9245. };
  9246. const whiteListOptions = function(showType) {
  9247. try {
  9248. const whiteList = {
  9249. ...defaultWhiteList,
  9250. ...GM_getValue('whiteList') || {}
  9251. };
  9252. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9253. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9254. for (const [ social, types ] of Object.entries(whiteList)) {
  9255. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9256. var _disabledType$social;
  9257. 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>`;
  9258. }).join('');
  9259. }
  9260. whiteListOptionsForm += '</tbody></table></form>';
  9261. if (showType === 'swal') {
  9262. external_Swal_default().fire({
  9263. title: i18n('whiteListOptions'),
  9264. html: whiteListOptionsForm,
  9265. showConfirmButton: false,
  9266. showCloseButton: true
  9267. });
  9268. } else {
  9269. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9270. }
  9271. $('.editWhiteList').on('click', function() {
  9272. var _whiteList$social;
  9273. const value = $(this).attr('data-value');
  9274. if (!value) {
  9275. return;
  9276. }
  9277. const [ social, type ] = value.split('.');
  9278. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9279. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9280. return;
  9281. }
  9282. external_Swal_default().fire({
  9283. title: i18n('changeWhiteListOption', value),
  9284. input: 'textarea',
  9285. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9286. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9287. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9288. inputValue: whiteList[social][type].join('\n'),
  9289. showConfirmButton: true,
  9290. confirmButtonText: i18n('save'),
  9291. showCancelButton: true,
  9292. cancelButtonText: i18n('close'),
  9293. showDenyButton: true,
  9294. denyButtonText: i18n('return')
  9295. }).then(_ref => {
  9296. let {
  9297. isDenied,
  9298. isConfirmed,
  9299. value
  9300. } = _ref;
  9301. if (isDenied) {
  9302. if (showType === 'swal') {
  9303. whiteListOptions(showType);
  9304. }
  9305. return;
  9306. } else if (isConfirmed) {
  9307. whiteList[social][type] = value.split('\n');
  9308. GM_setValue('whiteList', whiteList);
  9309. external_Swal_default().fire({
  9310. title: i18n('changeWhiteListSuccess'),
  9311. icon: 'success'
  9312. });
  9313. }
  9314. });
  9315. $('#link2id').on('click', async function() {
  9316. const type = $(this).attr('data-type');
  9317. $('#socialLink').val(await link2id(type));
  9318. });
  9319. });
  9320. } catch (error) {
  9321. throwError(error, 'whiteListOptions');
  9322. }
  9323. };
  9324. const whiteList = whiteListOptions;
  9325. const setGistData = async (token, gistId, fileName, content) => {
  9326. try {
  9327. const logStatus = scripts_echoLog({
  9328. text: i18n('settingData')
  9329. });
  9330. const contentData = JSON.stringify({
  9331. files: {
  9332. [fileName]: {
  9333. content: JSON.stringify(content)
  9334. }
  9335. }
  9336. });
  9337. const {
  9338. result,
  9339. statusText,
  9340. status,
  9341. data
  9342. } = await tools_httpRequest({
  9343. url: `https://api.github.com/gists/${gistId}`,
  9344. headers: {
  9345. Accept: 'application/vnd.github.v3+json',
  9346. Authorization: `token ${token}`
  9347. },
  9348. data: contentData,
  9349. responseType: 'json',
  9350. method: 'POST',
  9351. timeout: 3e4
  9352. });
  9353. if (result === 'Success') {
  9354. var _data$response$files, _data$response$files$;
  9355. 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)) {
  9356. logStatus.success();
  9357. return true;
  9358. }
  9359. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9360. return false;
  9361. }
  9362. logStatus.error(`${result}:${statusText}(${status})`);
  9363. return false;
  9364. } catch (error) {
  9365. throwError(error, 'setGistData');
  9366. return false;
  9367. }
  9368. };
  9369. const getGistData = async (token, gistId, fileName) => {
  9370. try {
  9371. const logStatus = scripts_echoLog({
  9372. text: i18n('gettingData')
  9373. });
  9374. const {
  9375. result,
  9376. statusText,
  9377. status,
  9378. data
  9379. } = await tools_httpRequest({
  9380. url: `https://api.github.com/gists/${gistId}`,
  9381. headers: {
  9382. Accept: 'application/vnd.github.v3+json',
  9383. Authorization: `token ${token}`
  9384. },
  9385. responseType: 'json',
  9386. method: 'GET',
  9387. timeout: 3e4
  9388. });
  9389. if (result === 'Success') {
  9390. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9391. var _data$response, _data$response$files2, _data$response$files3;
  9392. logStatus.success();
  9393. 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);
  9394. }
  9395. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9396. return false;
  9397. }
  9398. logStatus.error(`${result}:${statusText}(${status})`);
  9399. return false;
  9400. } catch (error) {
  9401. throwError(error, 'getGistData');
  9402. return false;
  9403. }
  9404. };
  9405. const syncOptions = () => {
  9406. try {
  9407. const {
  9408. TOKEN,
  9409. GIST_ID,
  9410. FILE_NAME,
  9411. SYNC_HISTORY
  9412. } = GM_getValue('gistOptions') || {
  9413. TOKEN: '',
  9414. GIST_ID: '',
  9415. FILE_NAME: '',
  9416. SYNC_HISTORY: true
  9417. };
  9418. external_Swal_default().fire({
  9419. title: i18n('gistOptions'),
  9420. 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;">
  9421. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9422. ${i18n('downloadFromGist')}</button></p>`,
  9423. focusConfirm: false,
  9424. showLoaderOnConfirm: true,
  9425. 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>`,
  9426. preConfirm: async () => {
  9427. const token = $('#github-token').val();
  9428. const gistId = $('#gist-id').val();
  9429. const fileName = $('#file-name').val();
  9430. const syncHistory = $('#sync-history').prop('checked');
  9431. GM_setValue('gistOptions', {
  9432. TOKEN: token,
  9433. GIST_ID: gistId,
  9434. FILE_NAME: fileName,
  9435. SYNC_HISTORY: syncHistory
  9436. });
  9437. return await getGistData(token, gistId, fileName);
  9438. },
  9439. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9440. confirmButtonText: i18n('saveAndTest'),
  9441. showCancelButton: true,
  9442. cancelButtonText: i18n('close')
  9443. }).then(_ref => {
  9444. let {
  9445. value
  9446. } = _ref;
  9447. if (value) {
  9448. external_Swal_default().fire({
  9449. icon: 'success',
  9450. title: i18n('testSuccess')
  9451. }).then(syncOptions);
  9452. } else if (value !== undefined) {
  9453. external_Swal_default().fire({
  9454. icon: 'error',
  9455. title: i18n('testFailed')
  9456. }).then(syncOptions);
  9457. }
  9458. });
  9459. $('#upload-data').on('click', async () => {
  9460. const {
  9461. TOKEN,
  9462. GIST_ID,
  9463. FILE_NAME
  9464. } = GM_getValue('gistOptions') || {};
  9465. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9466. return external_Swal_default().fire({
  9467. icon: 'error',
  9468. title: i18n('saveAndTestNotice')
  9469. }).then(syncOptions);
  9470. }
  9471. external_Swal_default().fire({
  9472. icon: 'info',
  9473. title: i18n('processingData')
  9474. });
  9475. const data = {};
  9476. const names = GM_listValues();
  9477. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9478. for (const name of names) {
  9479. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9480. continue;
  9481. }
  9482. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9483. continue;
  9484. }
  9485. data[name] = GM_getValue(name);
  9486. }
  9487. external_Swal_default().update({
  9488. icon: 'info',
  9489. title: i18n('updatingData')
  9490. });
  9491. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9492. external_Swal_default().fire({
  9493. icon: 'success',
  9494. title: i18n('syncDataSuccess')
  9495. });
  9496. } else {
  9497. external_Swal_default().fire({
  9498. icon: 'error',
  9499. title: i18n('syncDataFailed')
  9500. });
  9501. }
  9502. });
  9503. $('#download-data').on('click', async () => {
  9504. const {
  9505. TOKEN,
  9506. GIST_ID,
  9507. FILE_NAME
  9508. } = GM_getValue('gistOptions') || {};
  9509. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9510. return external_Swal_default().fire({
  9511. icon: 'error',
  9512. title: i18n('saveAndTestNotice')
  9513. }).then(syncOptions);
  9514. }
  9515. external_Swal_default().fire({
  9516. icon: 'info',
  9517. title: i18n('downloadingData')
  9518. });
  9519. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9520. if (!data) {
  9521. return external_Swal_default().fire({
  9522. icon: 'error',
  9523. title: i18n('checkedNoData')
  9524. }).then(syncOptions);
  9525. }
  9526. external_Swal_default().update({
  9527. icon: 'info',
  9528. title: i18n('savingData')
  9529. });
  9530. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9531. for (const [ name, value ] of Object.entries(data)) {
  9532. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9533. continue;
  9534. }
  9535. GM_setValue(name, value);
  9536. }
  9537. external_Swal_default().fire({
  9538. icon: 'success',
  9539. title: i18n('syncDataSuccess')
  9540. });
  9541. });
  9542. } catch (error) {
  9543. throwError(error, 'syncOptions');
  9544. }
  9545. };
  9546. const dataSync = syncOptions;
  9547. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9548. Setting_checkPrivateRedeclaration(obj, privateSet);
  9549. privateSet.add(obj);
  9550. }
  9551. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9552. if (privateCollection.has(obj)) {
  9553. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9554. }
  9555. }
  9556. function Setting_defineProperty(obj, key, value) {
  9557. if (key in obj) {
  9558. Object.defineProperty(obj, key, {
  9559. value: value,
  9560. enumerable: true,
  9561. configurable: true,
  9562. writable: true
  9563. });
  9564. } else {
  9565. obj[key] = value;
  9566. }
  9567. return obj;
  9568. }
  9569. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9570. if (!privateSet.has(receiver)) {
  9571. throw new TypeError('attempted to get private field on non-instance');
  9572. }
  9573. return fn;
  9574. }
  9575. var Setting_getId = new WeakSet();
  9576. var _environment = new WeakSet();
  9577. class Setting {
  9578. constructor() {
  9579. Setting_classPrivateMethodInitSpec(this, _environment);
  9580. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  9581. Setting_defineProperty(this, 'name', 'Setting');
  9582. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  9583. Setting_defineProperty(this, 'dataSync', dataSync);
  9584. }
  9585. tasksHistory() {
  9586. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9587. }
  9588. static test() {
  9589. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9590. }
  9591. before() {
  9592. $('body').html('').addClass('auto-task-options');
  9593. }
  9594. after() {
  9595. try {
  9596. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  9597. changeGlobalOptions('page');
  9598. whiteList('page');
  9599. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9600. $('#getTwitterUserId').on('click', () => {
  9601. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  9602. });
  9603. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9604. $('#getYoutubeChannelId').on('click', () => {
  9605. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  9606. });
  9607. $('input[name^="position"]').on('input', function() {
  9608. const type = $(this).attr('name').replace('position.', '');
  9609. const xLabel = 'rightleft';
  9610. const yLabel = 'topbottpm';
  9611. switch (type) {
  9612. case 'buttonSideX':
  9613. case 'buttonSideY':
  9614. case 'buttonDistance':
  9615. {
  9616. const distance = $('input[name="position.buttonDistance"]').val();
  9617. const sideX = $('input[name="position.buttonSideX"]').val();
  9618. const sideY = $('input[name="position.buttonSideY"]').val();
  9619. if (![ 'right', 'left' ].includes(sideX)) {
  9620. break;
  9621. }
  9622. if (![ 'top', 'bottom' ].includes(sideY)) {
  9623. break;
  9624. }
  9625. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9626. break;
  9627. }
  9628. const distanceArr = distance.split(',');
  9629. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9630. break;
  9631. }
  9632.  
  9633. case 'showButtonSideX':
  9634. case 'showButtonSideY':
  9635. case 'showButtonDistance':
  9636. {
  9637. const distance = $('input[name="position.showButtonDistance"]').val();
  9638. const sideX = $('input[name="position.showButtonSideX"]').val();
  9639. const sideY = $('input[name="position.showButtonSideY"]').val();
  9640. if (![ 'right', 'left' ].includes(sideX)) {
  9641. break;
  9642. }
  9643. if (![ 'top', 'bottom' ].includes(sideY)) {
  9644. break;
  9645. }
  9646. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9647. break;
  9648. }
  9649. const distanceArr = distance.split(',');
  9650. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9651. break;
  9652. }
  9653.  
  9654. case 'logSideX':
  9655. case 'logSideY':
  9656. case 'logDistance':
  9657. {
  9658. const distance = $('input[name="position.logDistance"]').val();
  9659. const sideX = $('input[name="position.logSideX"]').val();
  9660. const sideY = $('input[name="position.logSideY"]').val();
  9661. if (![ 'right', 'left' ].includes(sideX)) {
  9662. break;
  9663. }
  9664. if (![ 'top', 'bottom' ].includes(sideY)) {
  9665. break;
  9666. }
  9667. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9668. break;
  9669. }
  9670. const distanceArr = distance.split(',');
  9671. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9672. break;
  9673. }
  9674.  
  9675. default:
  9676. break;
  9677. }
  9678. });
  9679. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9680. let functionKey = '';
  9681. if (event.altKey) {
  9682. functionKey += 'alt + ';
  9683. } else if (event.ctrlKey) {
  9684. functionKey += 'ctrl + ';
  9685. } else if (event.shiftKey) {
  9686. functionKey += 'shift + ';
  9687. }
  9688. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9689. });
  9690. } catch (error) {
  9691. throwError(error, 'Setting.after');
  9692. }
  9693. }
  9694. saveGlobalOptions() {
  9695. saveData();
  9696. }
  9697. }
  9698. function Setting_getId2(social) {
  9699. try {
  9700. external_Swal_default().fire({
  9701. title: i18n('getId', i18n(social)),
  9702. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9703. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9704. showCancelButton: true,
  9705. cancelButtonText: i18n('close'),
  9706. showConfirmButton: false
  9707. });
  9708. $('#link2id').on('click', async function() {
  9709. const link = $('#socialLink').val();
  9710. if (!link) {
  9711. return;
  9712. }
  9713. const type = $(this).attr('data-type');
  9714. if (type === 'twitterUser') {
  9715. var _link$match;
  9716. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9717. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9718. } else if (type === 'youtubeChannel') {
  9719. var _link$match2, _await$getInfo, _await$getInfo$params;
  9720. 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;
  9721. $('#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) || '');
  9722. }
  9723. });
  9724. } catch (error) {
  9725. throwError(error, 'Setting.getId');
  9726. }
  9727. }
  9728. function _environment2() {
  9729. try {
  9730. const userAgent = (0, javascript_utils_umd_min.ua)();
  9731. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9732. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9733. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9734. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9735. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9736. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9737. </tbody></table></form>`;
  9738. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9739. } catch (error) {
  9740. throwError(error, 'Setting.environment');
  9741. }
  9742. }
  9743. const website_Setting = Setting;
  9744. const external_dayjs_namespaceObject = dayjs;
  9745. function History_classPrivateMethodInitSpec(obj, privateSet) {
  9746. History_checkPrivateRedeclaration(obj, privateSet);
  9747. privateSet.add(obj);
  9748. }
  9749. function History_checkPrivateRedeclaration(obj, privateCollection) {
  9750. if (privateCollection.has(obj)) {
  9751. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9752. }
  9753. }
  9754. function History_defineProperty(obj, key, value) {
  9755. if (key in obj) {
  9756. Object.defineProperty(obj, key, {
  9757. value: value,
  9758. enumerable: true,
  9759. configurable: true,
  9760. writable: true
  9761. });
  9762. } else {
  9763. obj[key] = value;
  9764. }
  9765. return obj;
  9766. }
  9767. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  9768. if (!privateSet.has(receiver)) {
  9769. throw new TypeError('attempted to get private field on non-instance');
  9770. }
  9771. return fn;
  9772. }
  9773. var _addItem = new WeakSet();
  9774. class History extends website_Keylol {
  9775. constructor() {
  9776. super(...arguments);
  9777. History_classPrivateMethodInitSpec(this, _addItem);
  9778. History_defineProperty(this, 'name', 'History');
  9779. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  9780. }
  9781. static test() {
  9782. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9783. }
  9784. before() {
  9785. try {
  9786. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  9787. const data = GM_listValues() || [];
  9788. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9789. for (const item of tasksHistory) {
  9790. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  9791. }
  9792. } catch (error) {
  9793. throwError(error, 'History.before');
  9794. }
  9795. }
  9796. clearHistory() {
  9797. try {
  9798. const data = GM_listValues() || [];
  9799. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9800. for (const item of tasksHistory) {
  9801. GM_deleteValue(item);
  9802. }
  9803. external_Swal_default().fire({
  9804. title: i18n('clearHistoryFinished'),
  9805. icon: 'success'
  9806. });
  9807. } catch (error) {
  9808. throwError(error, 'History.after');
  9809. }
  9810. }
  9811. }
  9812. function _addItem2(item) {
  9813. try {
  9814. const tasksData = GM_getValue(item);
  9815. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9816. return;
  9817. }
  9818. let html = '';
  9819. let title = '';
  9820. let link = '';
  9821. const [ website, id ] = item.split('-');
  9822. switch (website) {
  9823. case 'fawTasks':
  9824. title = `Freeanywhere[${id}]`;
  9825. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9826. break;
  9827.  
  9828. case 'gasTasks':
  9829. title = `Giveawaysu[${id}]`;
  9830. link = `https://giveaway.su/giveaway/view/${id}`;
  9831. break;
  9832.  
  9833. case 'gcTasks':
  9834. title = `GiveeClub[${id}]`;
  9835. link = `https://givee.club/event/${id}`;
  9836. break;
  9837.  
  9838. case 'gkTasks':
  9839. title = `Givekey[${id}]`;
  9840. link = `https://givekey.ru/giveaway/${id}`;
  9841. break;
  9842.  
  9843. case 'gleamTasks':
  9844. title = `Gleam[${id}]`;
  9845. link = `https://gleam.io${id}`;
  9846. break;
  9847.  
  9848. case 'khTasks':
  9849. title = `keyhub[${id}]`;
  9850. link = `https://key-hub.eu/giveaway/${id}`;
  9851. break;
  9852.  
  9853. case 'prysTasks':
  9854. title = `Prys[${id}]`;
  9855. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  9856. break;
  9857.  
  9858. default:
  9859. return;
  9860. }
  9861. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  9862. for (const [ type, tasks ] of Object.entries(types)) {
  9863. for (const task of tasks) {
  9864. 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>`;
  9865. }
  9866. }
  9867. }
  9868. $('.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>`);
  9869. $('span.delete-task').on('click', function() {
  9870. const itemName = $(this).attr('data-name');
  9871. if (itemName) {
  9872. GM_deleteValue(itemName);
  9873. external_Swal_default().fire({
  9874. title: i18n('clearTaskFinished'),
  9875. text: itemName,
  9876. icon: 'success'
  9877. });
  9878. } else {
  9879. external_Swal_default().fire({
  9880. title: i18n('clearTaskFailed'),
  9881. icon: 'error'
  9882. });
  9883. }
  9884. });
  9885. } catch (error) {
  9886. throwError(error, 'History.addItem');
  9887. }
  9888. }
  9889. const website_History = History;
  9890. 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 ];
  9891. const websiteOptions = function(website, options) {
  9892. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  9893. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  9894. for (const [ option, value ] of Object.entries(options)) {
  9895. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  9896. }
  9897. websiteOptionsForm += '</tbody></table></form>';
  9898. external_Swal_default().fire({
  9899. title: i18n('websiteOptions'),
  9900. html: websiteOptionsForm,
  9901. showConfirmButton: true,
  9902. confirmButtonText: i18n('save'),
  9903. showCancelButton: true,
  9904. cancelButtonText: i18n('close')
  9905. }).then(_ref => {
  9906. let {
  9907. isConfirmed
  9908. } = _ref;
  9909. if (isConfirmed) {
  9910. $('#websiteOptionsForm').serializeArray().map(value => {
  9911. options[value.name] = value.value;
  9912. return value;
  9913. });
  9914. GM_setValue(`${website}Options`, options);
  9915. external_Swal_default().fire({
  9916. title: i18n('changeWebsiteOptionsSuccess'),
  9917. icon: 'success'
  9918. });
  9919. }
  9920. });
  9921. };
  9922. const options = websiteOptions;
  9923. const external_keyboardJS_namespaceObject = keyboardJS;
  9924. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  9925. const checkUpdate = async (updateLink, auto) => {
  9926. try {
  9927. const checkUrl = `${updateLink}package.json`;
  9928. const {
  9929. result,
  9930. statusText,
  9931. status,
  9932. data
  9933. } = await tools_httpRequest({
  9934. url: checkUrl,
  9935. responseType: 'json',
  9936. method: 'GET',
  9937. timeout: 3e4
  9938. });
  9939. if (result === 'Success') {
  9940. var _data$response;
  9941. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  9942. return data.response;
  9943. }
  9944. if (!auto) {
  9945. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  9946. }
  9947. return false;
  9948. }
  9949. if (!auto) {
  9950. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  9951. }
  9952. return false;
  9953. } catch (error) {
  9954. throwError(error, 'checkUpdate');
  9955. return false;
  9956. }
  9957. };
  9958. const updateChecker = async () => {
  9959. try {
  9960. const currentVersion = GM_info.script.version;
  9961. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  9962. const updateLinks = {
  9963. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  9964. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  9965. standby: 'https://auto-task-v4.hclonely.com/'
  9966. };
  9967. let version;
  9968. let updateLink = '';
  9969. let packageData;
  9970. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  9971. updateLink = updateLinks[updateSource];
  9972. packageData = await checkUpdate(updateLink, false);
  9973. } else {
  9974. updateLink = updateLinks.github;
  9975. packageData = await checkUpdate(updateLink, true);
  9976. if (!packageData) {
  9977. updateLink = updateLinks.jsdelivr;
  9978. packageData = await checkUpdate(updateLink, true);
  9979. if (!packageData) {
  9980. updateLink = updateLinks.standby;
  9981. packageData = await checkUpdate(updateLink, true);
  9982. }
  9983. }
  9984. }
  9985. if (packageData) {
  9986. version = packageData.version || currentVersion;
  9987. } else {
  9988. version = currentVersion;
  9989. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  9990. }
  9991. if (packageData && version !== currentVersion) {
  9992. var _packageData$change;
  9993. scripts_echoLog({
  9994. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  9995. });
  9996. scripts_echoLog({
  9997. 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>`
  9998. });
  9999. }
  10000. } catch (error) {
  10001. throwError(error, 'updateChecker');
  10002. }
  10003. };
  10004. const scripts_updateChecker = updateChecker;
  10005. if (window.location.hostname === 'discord.com') {
  10006. var _window$localStorage, _window$localStorage$;
  10007. 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, '');
  10008. GM_setValue('discordAuth', {
  10009. auth: discordAuth
  10010. });
  10011. if (discordAuth && window.location.hash === '#auth') {
  10012. window.close();
  10013. external_Swal_default().fire('', i18n('closePageNotice'));
  10014. }
  10015. }
  10016. const loadScript = async () => {
  10017. var _website, _website2, _website3, _website4, _website5, _website6;
  10018. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10019. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10020. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10021. if (isLogin) {
  10022. var _commonOptions, _commonOptions$header;
  10023. GM_setValue('twitchAuth', {
  10024. authToken: authToken,
  10025. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10026. });
  10027. window.close();
  10028. external_Swal_default().fire('', i18n('closePageNotice'));
  10029. } else {
  10030. external_Swal_default().fire('', i18n('needLogin'));
  10031. }
  10032. }
  10033. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10034. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10035. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10036. if (isLogin && ct0) {
  10037. GM_setValue('twitterAuth', {
  10038. ct0: ct0
  10039. });
  10040. window.close();
  10041. external_Swal_default().fire('', i18n('closePageNotice'));
  10042. } else {
  10043. external_Swal_default().fire('', i18n('needLogin'));
  10044. }
  10045. }
  10046. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10047. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10048. if (PAPISID) {
  10049. GM_setValue('youtubeAuth', {
  10050. PAPISID: PAPISID
  10051. });
  10052. window.close();
  10053. external_Swal_default().fire('', i18n('closePageNotice'));
  10054. } else {
  10055. external_Swal_default().fire('', i18n('needLogin'));
  10056. }
  10057. }
  10058. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10059. const betaButton = $('#redesign-beta-optin-btn');
  10060. if (betaButton.length > 0) {
  10061. GM_setValue('redditAuth', '#auth');
  10062. return betaButton[0].click();
  10063. }
  10064. GM_setValue('redditAuth', null);
  10065. window.close();
  10066. external_Swal_default().fire('', i18n('closePageNotice'));
  10067. }
  10068. let website;
  10069. for (const Website of Websites) {
  10070. if (Website.test()) {
  10071. website = new Website();
  10072. break;
  10073. }
  10074. }
  10075. if (!website) {
  10076. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10077. return;
  10078. }
  10079. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10080. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10081. }
  10082. $('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>`);
  10083. $('div.show-button-div').on('click', () => {
  10084. $('#auto-task-buttons').show();
  10085. $('div.show-button-div').hide();
  10086. });
  10087. const toggleLog = () => {
  10088. const $this = $('#toggle-log');
  10089. const status = $this.attr('data-status');
  10090. if (status === 'show') {
  10091. $('#auto-task-info').hide();
  10092. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10093. } else {
  10094. $('#auto-task-info').show();
  10095. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10096. }
  10097. };
  10098. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10099. if (website.doTask) {
  10100. website.doTask();
  10101. }
  10102. });
  10103. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10104. if (website.undoTask) {
  10105. website.doTask();
  10106. }
  10107. });
  10108. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10109. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10110. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10111. }
  10112. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10113. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10114. for (const button of website.buttons) {
  10115. if (website[button]) {
  10116. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10117. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10118. website[button]();
  10119. });
  10120. $('#auto-task-buttons').append(btnElement);
  10121. }
  10122. }
  10123. }
  10124. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10125. ${i18n('hideButton')}</a></p>`);
  10126. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10127. $('#auto-task-buttons').hide();
  10128. $('div.show-button-div').show();
  10129. });
  10130. 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'}">
  10131. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10132. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10133. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10134. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10135. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10136. options(website.name, website.options);
  10137. });
  10138. }
  10139. if (website.name !== 'Setting') {
  10140. GM_registerMenuCommand(i18n('whiteList'), () => {
  10141. whiteList('swal');
  10142. });
  10143. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10144. changeGlobalOptions('swal');
  10145. });
  10146. GM_registerMenuCommand(i18n('tasksHistory'), () => {
  10147. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10148. });
  10149. GM_registerMenuCommand(i18n('syncData'), dataSync);
  10150. GM_registerMenuCommand(i18n('settingPage'), () => {
  10151. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10152. });
  10153. }
  10154. GM_addStyle(auto_task.Z);
  10155. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10156. if (!GM_getValue('notice')) {
  10157. var _echoLog$font;
  10158. external_Swal_default().fire({
  10159. title: i18n('swalNotice'),
  10160. icon: 'warning'
  10161. }).then(() => {
  10162. window.open(i18n('noticeLink'), '_blank');
  10163. GM_setValue('notice', new Date().getTime());
  10164. });
  10165. (_echoLog$font = scripts_echoLog({
  10166. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10167. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10168. GM_setValue('notice', new Date().getTime());
  10169. });
  10170. }
  10171. scripts_updateChecker();
  10172. };
  10173. if (window.location.hostname === 'opquests.com') {
  10174. loadScript();
  10175. } else {
  10176. $(loadScript);
  10177. }
  10178. }();
  10179. })();