auto-task-v4

赠Key站自动任务

目前为 2022-01-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.4-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 unsafeWindow
  42. // @grant window.close
  43. // @grant window.localStorage
  44.  
  45. // @connect cdn.jsdelivr.net
  46. // @connect store.steampowered.com
  47. // @connect steamcommunity.com
  48. // @connect twitter.com
  49. // @connect api.twitter.com
  50. // @connect youtube.com
  51. // @connect www.youtube.com
  52. // @connect facebook.com
  53. // @connect instagram.com
  54. // @connect vk.com
  55. // @connect twitch.tv
  56. // @connect www.twitch.tv
  57. // @connect gql.twitch.tv
  58. // @connect github.com
  59. // @connect discordapp.com
  60. // @connect discord.gg
  61. // @connect discord.com
  62. // @connect www.reddit.com
  63. // @connect oauth.reddit.com
  64. // @connect raw.githubusercontent.com
  65. // @connect t.me
  66. // @connect bit.ly
  67. // @connect giveaway.su
  68. // @connect google.com
  69. // @connect www.vloot.io
  70. // @connect givee.club
  71. // @connect auto-task-v4.hclonely.com
  72. // @connect *
  73. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  74. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  75. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  76. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  77. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  78. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  79. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  80.  
  81. // @compatible Tampermonkey Only
  82. // @noframes
  83. // ==/UserScript==
  84.  
  85. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  86.  
  87. (function() {
  88. var __webpack_modules__ = {
  89. 514: function(__unused_webpack_module, exports) {
  90. !function(e, n) {
  91. true ? n(exports) : 0;
  92. }(this, function(e) {
  93. 'use strict';
  94. var t = function() {
  95. return (t = Object.assign || function(e) {
  96. for (var n, o = 1, t = arguments.length; o < t; o++) {
  97. for (var r in n = arguments[o]) {
  98. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  99. }
  100. }
  101. return e;
  102. }).apply(this, arguments);
  103. };
  104. function r(e, n, o) {
  105. if (o || 2 === arguments.length) {
  106. for (var t, r = 0, i = n.length; r < i; r++) {
  107. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  108. }
  109. }
  110. return e.concat(t || Array.prototype.slice.call(n));
  111. }
  112. function d(e) {
  113. return '[object Object]' === n(e);
  114. }
  115. function l(e, n) {
  116. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  117. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  118. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  119. });
  120. }
  121. var n = function(e) {
  122. return Object.prototype.toString.call(e);
  123. };
  124. var o = (i.prototype.init = function() {
  125. try {
  126. this.getSystemName(), this.getBrowserName();
  127. } catch (e) {
  128. console.warn('[UA formatter error] '.concat(e));
  129. }
  130. }, i.prototype.getEngine = function() {
  131. var e = this.agent;
  132. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  133. }, i.prototype.getSystemName = function() {
  134. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  135. try {
  136. var o = '';
  137. if (/Windows/i.test(n)) {
  138. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  139. switch (this.info.os = 'Windows', t) {
  140. case '6.3':
  141. o = '8.1';
  142. break;
  143.  
  144. case '6.2':
  145. o = '8';
  146. break;
  147.  
  148. case '6.1':
  149. o = '7';
  150. break;
  151.  
  152. case '5.2':
  153. case '5.1':
  154. o = 'XP';
  155. break;
  156.  
  157. default:
  158. o = t;
  159. }
  160. return this.info.device = 'PC', void (this.info.osVersion = o);
  161. }
  162. if (/^Macintosh/i.test(n)) {
  163. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  164. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  165. }
  166. if (/^iPad/i.test(n)) {
  167. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  168. void (this.info.osVersion = o.replace(/_/g, '.'));
  169. }
  170. if (/^iPhone/i.test(n)) {
  171. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  172. void (this.info.osVersion = o.replace(/_/g, '.'));
  173. }
  174. if (-1 !== n.indexOf('Android')) {
  175. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  176. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  177. }
  178. if (/Linux\s[a-z\d_]+/.test(n)) {
  179. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  180. }
  181. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  182. } catch (e) {
  183. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  184. }
  185. }, i.prototype.getBrowserName = function() {
  186. var e = Object.keys(this.browserNameMap).map(function(e) {
  187. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  188. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  189. return -1 !== e.findIndex(function(e) {
  190. return e.test(n);
  191. });
  192. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  193. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  194. }, i.prototype._formatBrowserVersion = function(e) {
  195. var n, o, t, r;
  196. try {
  197. 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++) {
  198. var d = u[f], l = d[0], h = d[1];
  199. if (new RegExp(l).test(s)) {
  200. c = h;
  201. break;
  202. }
  203. }
  204. var p = {
  205. browserVersion: null != a ? a : 'Unknown',
  206. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  207. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  208. };
  209. return 'Trident' === s && (p.browserVersion = {
  210. '4.0': 8,
  211. '5.0': 9,
  212. '6.0': 10,
  213. '7.0': 11
  214. }[a]), p;
  215. } catch (e) {
  216. return console.warn('[UA formatter error] '.concat(e)), {
  217. browser: 'Unknown',
  218. browserVersion: 'Unknown'
  219. };
  220. }
  221. }, i);
  222. function i(e) {
  223. this.agent = '', this.info = {
  224. browser: '',
  225. browserZH: '',
  226. browserVersion: '',
  227. os: '',
  228. osVersion: '',
  229. device: 'Unknown',
  230. engine: 'WebKit'
  231. }, this.browserNameMap = {
  232. MicroMessenger: {
  233. en: 'MicroMessenger',
  234. zh: '微信'
  235. },
  236. MetaSr: {
  237. en: 'MetaSr',
  238. zh: '搜狗浏览器'
  239. },
  240. 'QQ(Browser)?': {
  241. en: 'QQBrowser',
  242. zh: 'QQ浏览器'
  243. },
  244. UCBrowser: {
  245. en: 'UCBrowser',
  246. zh: 'UC浏览器'
  247. },
  248. '2345Explorer': {
  249. en: '2345Explorer',
  250. zh: '2345极速浏览器'
  251. },
  252. Mb2345Browser: {
  253. en: 'Mb2345Browser',
  254. zh: '2345手机浏览器'
  255. },
  256. Trident: {
  257. en: 'Internet Explorer'
  258. },
  259. 'Edge?': {
  260. en: 'Edge'
  261. },
  262. OPR: {
  263. en: 'Opera'
  264. },
  265. Vivaldi: {
  266. en: 'Vivaldi'
  267. },
  268. Firefox: {
  269. en: 'Firefox'
  270. },
  271. Chrome: {
  272. en: 'Chrome'
  273. },
  274. Safari: {
  275. en: 'Safari'
  276. }
  277. }, this.agent = e, this.init();
  278. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  279. this.info = t(t({}, this.info), {
  280. engine: this.getEngine(),
  281. browserVersion: 'Safari' === o ? n : e
  282. });
  283. }
  284. function s() {
  285. this.cookies = {}, this.init();
  286. }
  287. var a = new (s.prototype.init = function() {
  288. var o = {};
  289. document.cookie.split(/;\s/).forEach(function(e) {
  290. var n = e.split(/=/), e = n[0], n = n[1];
  291. o[e] = n;
  292. }), this.cookies = o;
  293. }, s.prototype.getItem = function(e) {
  294. return this.cookies[e];
  295. }, s.prototype.getAllItems = function() {
  296. return this.cookies;
  297. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  298. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  299. }, s)();
  300. e.countDown = function e(n, o, t, r) {
  301. if (!window) {
  302. throw new Error('window is not defind.');
  303. }
  304. if (0 < n) {
  305. return r && r(), n--, window[o] = window.setTimeout(function() {
  306. e(n, o, t, r);
  307. }, 1e3), function() {
  308. return clearTimeout(window[o]);
  309. };
  310. }
  311. clearTimeout(window[o]), t && t();
  312. }, e.createRandomID = function(e) {
  313. void 0 === e && (e = 12);
  314. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  315. n.push(o[Math.round(Math.random() * t)]);
  316. }
  317. return n.join('');
  318. }, e.dCookie = a, e.debounce = function(o, t, r) {
  319. var i;
  320. void 0 === t && (t = 0);
  321. var s = r = void 0 === r ? !1 : r;
  322. return function() {
  323. var e = this, n = arguments;
  324. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  325. r ? s = !0 : o.apply(e, n);
  326. }, t);
  327. };
  328. }, e.deepCopy = function e(n) {
  329. if (d(n) || Array.isArray(n)) {
  330. var o, t = Array.isArray(n) ? [] : {};
  331. for (o in n) {
  332. t[o] = e(n[o]);
  333. }
  334. return t;
  335. }
  336. return n;
  337. }, e.formatQueryParams = function(e) {
  338. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  339. if (!e) {
  340. return {};
  341. }
  342. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  343. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  344. return t[n] = o, e;
  345. });
  346. }
  347. return t;
  348. }, e.formatThousandth = function(e) {
  349. 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, '$&,');
  350. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  351. }, e.generateTree = function e(n, o, t, r) {
  352. for (var i = [], s = 0; s < n.length; s++) {
  353. var a = n[s];
  354. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  355. }
  356. return i;
  357. }, e.isEmpty = function(e) {
  358. 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);
  359. }, e.isFunction = function(e) {
  360. return '[object Function]' === n(e);
  361. }, e.isImageUrl = function(e) {
  362. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  363. }, e.isObject = d, e.isRegexp = function(e) {
  364. return '[object RegExp]' === n(e);
  365. }, e.objectKeyToCamelCase = function e(n, o, t) {
  366. if (Array.isArray(n)) {
  367. for (var r = [], i = 0; i < n.length; i++) {
  368. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  369. }
  370. } else if (d(n)) {
  371. r = {};
  372. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  373. var f = (u = c[a])[0], u = u[1];
  374. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  375. }
  376. } else {
  377. r = n;
  378. }
  379. return r;
  380. }, e.realType = n, e.searchParams = function(e, n) {
  381. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  382. new URLSearchParams(e).get(n);
  383. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  384. return e.replace(/([A-Z])/g, function(e) {
  385. return '_'.concat(e.toLocaleLowerCase());
  386. });
  387. }, e.ua = function(e) {
  388. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  389. }, Object.defineProperty(e, '__esModule', {
  390. value: !0
  391. });
  392. });
  393. },
  394. 786: function(module, __webpack_exports__, __webpack_require__) {
  395. 'use strict';
  396. __webpack_require__.d(__webpack_exports__, {
  397. Z: function() {
  398. return __WEBPACK_DEFAULT_EXPORT__;
  399. }
  400. });
  401. 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);
  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___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__);
  403. 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);
  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___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__);
  405. 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());
  406. ___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 .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}', '' ]);
  407. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  408. },
  409. 400: function(module) {
  410. 'use strict';
  411. module.exports = function(cssWithMappingToString) {
  412. var list = [];
  413. list.toString = function toString() {
  414. return this.map(function(item) {
  415. var content = '';
  416. var needLayer = typeof item[5] !== 'undefined';
  417. if (item[4]) {
  418. content += '@supports ('.concat(item[4], ') {');
  419. }
  420. if (item[2]) {
  421. content += '@media '.concat(item[2], ' {');
  422. }
  423. if (needLayer) {
  424. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  425. }
  426. content += cssWithMappingToString(item);
  427. if (needLayer) {
  428. content += '}';
  429. }
  430. if (item[2]) {
  431. content += '}';
  432. }
  433. if (item[4]) {
  434. content += '}';
  435. }
  436. return content;
  437. }).join('');
  438. };
  439. list.i = function i(modules, media, dedupe, supports, layer) {
  440. if (typeof modules === 'string') {
  441. modules = [ [ null, modules, undefined ] ];
  442. }
  443. var alreadyImportedModules = {};
  444. if (dedupe) {
  445. for (var k = 0; k < this.length; k++) {
  446. var id = this[k][0];
  447. if (id != null) {
  448. alreadyImportedModules[id] = true;
  449. }
  450. }
  451. }
  452. for (var _k = 0; _k < modules.length; _k++) {
  453. var item = [].concat(modules[_k]);
  454. if (dedupe && alreadyImportedModules[item[0]]) {
  455. continue;
  456. }
  457. if (typeof layer !== 'undefined') {
  458. if (typeof item[5] === 'undefined') {
  459. item[5] = layer;
  460. } else {
  461. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  462. item[5] = layer;
  463. }
  464. }
  465. if (media) {
  466. if (!item[2]) {
  467. item[2] = media;
  468. } else {
  469. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  470. item[2] = media;
  471. }
  472. }
  473. if (supports) {
  474. if (!item[4]) {
  475. item[4] = ''.concat(supports);
  476. } else {
  477. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  478. item[4] = supports;
  479. }
  480. }
  481. list.push(item);
  482. }
  483. };
  484. return list;
  485. };
  486. },
  487. 220: function(module) {
  488. 'use strict';
  489. module.exports = function(i) {
  490. return i[1];
  491. };
  492. }
  493. };
  494. var __webpack_module_cache__ = {};
  495. function __webpack_require__(moduleId) {
  496. var cachedModule = __webpack_module_cache__[moduleId];
  497. if (cachedModule !== undefined) {
  498. return cachedModule.exports;
  499. }
  500. var module = __webpack_module_cache__[moduleId] = {
  501. id: moduleId,
  502. exports: {}
  503. };
  504. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  505. return module.exports;
  506. }
  507. !function() {
  508. __webpack_require__.n = function(module) {
  509. var getter = module && module.__esModule ? function() {
  510. return module['default'];
  511. } : function() {
  512. return module;
  513. };
  514. __webpack_require__.d(getter, {
  515. a: getter
  516. });
  517. return getter;
  518. };
  519. }();
  520. !function() {
  521. __webpack_require__.d = function(exports, definition) {
  522. for (var key in definition) {
  523. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  524. Object.defineProperty(exports, key, {
  525. enumerable: true,
  526. get: definition[key]
  527. });
  528. }
  529. }
  530. };
  531. }();
  532. !function() {
  533. __webpack_require__.o = function(obj, prop) {
  534. return Object.prototype.hasOwnProperty.call(obj, prop);
  535. };
  536. }();
  537. var __webpack_exports__ = {};
  538. !function() {
  539. 'use strict';
  540. const external_Swal_namespaceObject = Swal;
  541. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  542. const external_Cookies_namespaceObject = Cookies;
  543. var auto_task = __webpack_require__(786);
  544. var javascript_utils_umd_min = __webpack_require__(514);
  545. const httpRequest = async function(options) {
  546. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  547. try {
  548. const result = await new Promise(resolve => {
  549. if (options.dataType) {
  550. options.responseType = options.dataType;
  551. }
  552. const requestObj = {
  553. ...{
  554. timeout: 3e4,
  555. ontimeout(data) {
  556. resolve({
  557. result: 'Error',
  558. statusText: 'Timeout',
  559. status: 601,
  560. data: data,
  561. options: options
  562. });
  563. },
  564. onabort(data) {
  565. resolve({
  566. result: 'Error',
  567. statusText: 'Aborted',
  568. status: 602,
  569. data: data,
  570. options: options
  571. });
  572. },
  573. onerror(data) {
  574. resolve({
  575. result: 'Error',
  576. statusText: 'Error',
  577. status: 603,
  578. data: data,
  579. options: options
  580. });
  581. },
  582. onload(data) {
  583. resolve({
  584. result: 'Success',
  585. statusText: 'Load',
  586. status: 600,
  587. data: data,
  588. options: options
  589. });
  590. }
  591. },
  592. ...options
  593. };
  594. GM_xmlhttpRequest(requestObj);
  595. });
  596. console.log('发送请求:', result);
  597. if (result.status !== 600 && times < 2) {
  598. return await httpRequest(options, times + 1);
  599. }
  600. return result;
  601. } catch (error) {
  602. throwError(error, 'httpRequest');
  603. console.log('发送请求:', {
  604. errorMsg: error,
  605. options: options
  606. });
  607. return {
  608. result: 'JsError',
  609. statusText: 'Error',
  610. status: 604,
  611. error: error,
  612. options: options
  613. };
  614. }
  615. };
  616. const tools_httpRequest = httpRequest;
  617. const echoLog = _ref => {
  618. let {
  619. type,
  620. text,
  621. html,
  622. id
  623. } = _ref;
  624. const emptyStatus = {
  625. success: () => emptyStatus,
  626. error: () => emptyStatus,
  627. warning: () => emptyStatus,
  628. info: () => emptyStatus,
  629. view: () => emptyStatus
  630. };
  631. try {
  632. var _ele$;
  633. let ele;
  634. if (type) {
  635. switch (type) {
  636. case 'joiningSteamGroup':
  637. case 'leavingSteamGroup':
  638. case 'gettingSteamGroupId':
  639. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  640. break;
  641.  
  642. case 'subscribingForum':
  643. case 'unsubscribingForum':
  644. case 'gettingForumId':
  645. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  646. break;
  647.  
  648. case 'followingCurator':
  649. case 'unfollowingCurator':
  650. case 'getCuratorId':
  651. 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>`);
  652. break;
  653.  
  654. case 'addingToWishlist':
  655. case 'removingFromWishlist':
  656. case 'followingGame':
  657. case 'unfollowingGame':
  658. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  659. break;
  660.  
  661. case 'favoritingWorkshop':
  662. case 'unfavoritingWorkshop':
  663. case 'gettingWorkshopAppId':
  664. case 'votingUpWorkshop':
  665. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  666. ${text}</a>...<font></font></li>`);
  667. break;
  668.  
  669. case 'gettingAnnouncementParams':
  670. case 'likingAnnouncement':
  671. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  672. ${id}</a>...<font></font></li>`);
  673. break;
  674.  
  675. case 'joiningDiscordServer':
  676. case 'gettingDiscordGuild':
  677. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  678. break;
  679.  
  680. case 'leavingDiscordServer':
  681. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  682. break;
  683.  
  684. case 'updateDiscordAuth':
  685. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  686. break;
  687.  
  688. case 'followingTwitchChannel':
  689. case 'unfollowingTwitchChannel':
  690. case 'gettingTwitchChannelId':
  691. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  692. break;
  693.  
  694. case 'gettingInsUserId':
  695. case 'followingIns':
  696. case 'unfollowingIns':
  697. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  698. break;
  699.  
  700. case 'gettingTwitterUserId':
  701. case 'followingTwitterUser':
  702. case 'unfollowingTwitterUser':
  703. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  704. break;
  705.  
  706. case 'retweetting':
  707. case 'unretweetting':
  708. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  709. break;
  710.  
  711. case 'joiningReddit':
  712. case 'leavingReddit':
  713. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  714. break;
  715.  
  716. case 'followingRedditUser':
  717. case 'unfollowingRedditUser':
  718. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  719. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  720. break;
  721.  
  722. case 'followingYtbChannel':
  723. case 'unfollowingYtbChannel':
  724. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  725. break;
  726.  
  727. case 'likingYtbVideo':
  728. case 'unlikingYtbVideo':
  729. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  730. break;
  731.  
  732. case 'gettingVkId':
  733. case 'joiningVkGroup':
  734. case 'leavingVkGroup':
  735. case 'joiningVkPublic':
  736. case 'leavingVkPublic':
  737. case 'sendingVkWall':
  738. case 'deletingVkWall':
  739. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  740. break;
  741.  
  742. case 'visitingLink':
  743. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  744. break;
  745.  
  746. case 'verifyingInsAuth':
  747. case 'text':
  748. ele = $(`<li>${i18n(text)}<font></font></li>`);
  749. break;
  750.  
  751. case 'html':
  752. ele = $(text || html);
  753. break;
  754.  
  755. case 'whiteList':
  756. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  757. break;
  758.  
  759. case 'globalOptionsSkip':
  760. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  761. break;
  762.  
  763. default:
  764. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  765. break;
  766. }
  767. } else if (text) {
  768. ele = $(`<li>${i18n(text)}<font></font></li>`);
  769. } else if (html) {
  770. ele = $(html);
  771. } else {
  772. ele = $('<li><font></font></li>');
  773. }
  774. ele.addClass('card-text');
  775. $('#auto-task-info').append(ele);
  776. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  777. const font = ele.find('font');
  778. const status = {
  779. font: font,
  780. success() {
  781. var _this$font, _this$font2, _this$font3;
  782. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  783. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  784. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  785. 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);
  786. return this;
  787. },
  788. error() {
  789. var _this$font4, _this$font5, _this$font6;
  790. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  791. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  792. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  793. 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);
  794. return this;
  795. },
  796. warning() {
  797. var _this$font7, _this$font8, _this$font9;
  798. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  799. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  800. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  801. 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);
  802. return this;
  803. },
  804. info() {
  805. var _this$font10, _this$font11, _this$font12;
  806. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  807. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  808. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  809. 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);
  810. return this;
  811. },
  812. view() {
  813. var _this$font13;
  814. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  815. return this;
  816. }
  817. };
  818. return status;
  819. } catch (error) {
  820. throwError(error, 'echoLog');
  821. return emptyStatus;
  822. }
  823. };
  824. const scripts_echoLog = echoLog;
  825. const unique = array => {
  826. try {
  827. return [ ...new Set(array) ];
  828. } catch (error) {
  829. throwError(error, 'unique');
  830. return [];
  831. }
  832. };
  833. const delay = function() {
  834. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  835. return new Promise(resolve => {
  836. setTimeout(() => {
  837. resolve(true);
  838. }, time);
  839. });
  840. };
  841. const getRedirectLink = async link => {
  842. try {
  843. if (!link) {
  844. return null;
  845. }
  846. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  847. if (redirectLinksCache[link]) {
  848. redirectLinksCache[link];
  849. }
  850. return await tools_httpRequest({
  851. url: link,
  852. method: 'GET'
  853. }).then(_ref => {
  854. let {
  855. data
  856. } = _ref;
  857. if (data !== null && data !== void 0 && data.finalUrl) {
  858. redirectLinksCache[link] = data.finalUrl;
  859. GM_setValue('redirectLinks', redirectLinksCache);
  860. return data.finalUrl;
  861. }
  862. return null;
  863. });
  864. } catch (error) {
  865. throwError(error, 'getRedirectLink');
  866. return null;
  867. }
  868. };
  869. const visitLink = async (link, options) => {
  870. try {
  871. const logStatus = scripts_echoLog({
  872. type: 'visitLink',
  873. text: link
  874. });
  875. return await tools_httpRequest({
  876. url: link,
  877. method: 'GET',
  878. ...options
  879. }).then(_ref2 => {
  880. let {
  881. result,
  882. statusText,
  883. status
  884. } = _ref2;
  885. if (result === 'Success') {
  886. logStatus.success();
  887. return true;
  888. }
  889. logStatus.error(`${result}:${statusText}(${status})`);
  890. return false;
  891. });
  892. } catch (error) {
  893. throwError(error, 'visitLink');
  894. return false;
  895. }
  896. };
  897. const getUrlQuery = url => {
  898. try {
  899. const query = {};
  900. if (url) {
  901. if (url.includes('?')) {
  902. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  903. query[key] = value;
  904. return str;
  905. });
  906. }
  907. } else {
  908. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  909. query[key] = value;
  910. return str;
  911. });
  912. }
  913. return query;
  914. } catch (error) {
  915. throwError(error, 'getUrlQuery');
  916. return {};
  917. }
  918. };
  919. const getUuid = () => {
  920. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  921. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  922. };
  923. const stringToColour = str => {
  924. try {
  925. let hash = 0;
  926. for (let i = 0; i < str.length; i++) {
  927. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  928. }
  929. let colour = '#';
  930. for (let i = 0; i < 3; i++) {
  931. const value = hash >> i * 8 & 255;
  932. colour += `00${value.toString(16)}`.slice(-2);
  933. }
  934. return colour;
  935. } catch (error) {
  936. throwError(error, 'stringToColour');
  937. return '#fff';
  938. }
  939. };
  940. const defaultGlobalOptions = {
  941. doTask: {
  942. discord: {
  943. servers: true
  944. },
  945. instagram: {
  946. users: true
  947. },
  948. twitch: {
  949. channels: true
  950. },
  951. twitter: {
  952. users: true,
  953. retweets: true
  954. },
  955. vk: {
  956. names: true
  957. },
  958. youtube: {
  959. channels: true,
  960. likes: true
  961. },
  962. reddit: {
  963. reddits: true
  964. },
  965. steam: {
  966. groups: true,
  967. wishlists: true,
  968. follows: true,
  969. forums: true,
  970. workshops: true,
  971. curators: true,
  972. workshopVotes: true,
  973. announcements: true
  974. }
  975. },
  976. undoTask: {
  977. discord: {
  978. servers: true
  979. },
  980. instagram: {
  981. users: true
  982. },
  983. twitch: {
  984. channels: true
  985. },
  986. twitter: {
  987. users: true,
  988. retweets: true
  989. },
  990. vk: {
  991. names: true
  992. },
  993. youtube: {
  994. channels: true,
  995. likes: true
  996. },
  997. reddit: {
  998. reddits: true
  999. },
  1000. steam: {
  1001. groups: true,
  1002. wishlists: true,
  1003. follows: true,
  1004. forums: true,
  1005. workshops: true,
  1006. curators: true
  1007. }
  1008. },
  1009. position: {
  1010. buttonSideX: 'right',
  1011. buttonSideY: 'top',
  1012. buttonDistance: '15,30',
  1013. showButtonSideX: 'right',
  1014. showButtonSideY: 'top',
  1015. showButtonDistance: '15,30',
  1016. logSideX: 'right',
  1017. logSideY: 'bottom',
  1018. logDistance: '10,10'
  1019. },
  1020. hotKey: {
  1021. doTaskKey: 'alt + d',
  1022. undoTaskKey: 'alt + u',
  1023. toggleLogKey: 'alt + l'
  1024. },
  1025. other: {
  1026. twitterVerifyId: '783214',
  1027. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1028. autoUpdateSource: 'jsdelivr',
  1029. language: 'zh',
  1030. checkLogin: true,
  1031. checkLeftKey: true,
  1032. defaultShowButton: true,
  1033. defaultShowLog: true
  1034. }
  1035. };
  1036. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1037. const assignObject = (obj1, obj2) => {
  1038. try {
  1039. const newObj = {};
  1040. for (const [ key, value ] of Object.entries(obj1)) {
  1041. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1042. newObj[key] = assignObject(value, obj2[key]);
  1043. } else {
  1044. newObj[key] = obj2[key] ?? value;
  1045. }
  1046. }
  1047. return newObj;
  1048. } catch (error) {
  1049. throwError(error, 'assignObject');
  1050. return defaultGlobalOptions;
  1051. }
  1052. };
  1053. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1054. const saveData = () => {
  1055. try {
  1056. const data = {};
  1057. $('#globalOptionsForm').serializeArray().map(value => {
  1058. data[value.name] = value.value;
  1059. return value;
  1060. });
  1061. $.makeArray($('#globalOptionsForm input')).map(element => {
  1062. const name = $(element).attr('name');
  1063. const keys = name.split('.');
  1064. if (keys.length === 3) {
  1065. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1066. } else if (keys.length === 2) {
  1067. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1068. }
  1069. return element;
  1070. });
  1071. GM_setValue('globalOptions', globalOptions);
  1072. external_Swal_default().fire({
  1073. title: i18n('changeGlobalOptionsSuccess'),
  1074. icon: 'success'
  1075. });
  1076. } catch (error) {
  1077. throwError(error, 'saveData');
  1078. }
  1079. };
  1080. const changeGlobalOptions = showType => {
  1081. try {
  1082. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1083. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1084. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1085. for (const [ option, data2 ] of Object.entries(data1)) {
  1086. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1087. if (typeof data2 === 'boolean') {
  1088. 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>`;
  1089. } else {
  1090. 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>`;
  1091. }
  1092. } else {
  1093. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1094. 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>`;
  1095. }
  1096. }
  1097. }
  1098. }
  1099. globalOptionsForm += '</tbody></table></form>';
  1100. if (showType === 'swal') {
  1101. external_Swal_default().fire({
  1102. title: i18n('globalOptions'),
  1103. html: globalOptionsForm,
  1104. showConfirmButton: true,
  1105. confirmButtonText: i18n('save'),
  1106. showCancelButton: true,
  1107. cancelButtonText: i18n('close')
  1108. }).then(_ref => {
  1109. let {
  1110. isConfirmed
  1111. } = _ref;
  1112. if (isConfirmed) {
  1113. saveData();
  1114. }
  1115. });
  1116. } else {
  1117. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1118. }
  1119. } catch (error) {
  1120. throwError(error, 'changeGlobalOptions');
  1121. }
  1122. };
  1123. const data = {
  1124. website: '网站',
  1125. type: '类型',
  1126. edit: '编辑',
  1127. whiteList: '白名单',
  1128. skipTask: '跳过撤销任务',
  1129. whiteListOptions: '白名单设置',
  1130. changeWhiteListOption: '设置白名单(%0)',
  1131. whiteListNotFound: '找不到此项白名单: %0',
  1132. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1133. changeWebsiteOptions: '网站设置',
  1134. changeGlobalOptions: '全局设置',
  1135. ok: '是',
  1136. save: '保存',
  1137. close: '关闭',
  1138. return: '返回',
  1139. option: '选项',
  1140. value: '值',
  1141. websiteOptions: '当前网站设置',
  1142. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1143. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1144. needLogin: '请先登录!',
  1145. getTasksInfo: '正在获取并处理任务信息...',
  1146. gettingKey: '正在获取Key...',
  1147. verifyingTask: '正在验证任务',
  1148. notice: '自动任务脚本提醒',
  1149. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1150. giveawayEnded: '此活动已结束,是否关闭?',
  1151. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1152. confirm: '确定',
  1153. cancel: '取消',
  1154. unKnown: '未知',
  1155. unKnownTaskType: '未识别的任务',
  1156. doing: '正在做任务',
  1157. allTasksComplete: '所有任务已完成!',
  1158. getTaskIdFailed: '获取任务Id失败!',
  1159. initSuccess: '%0 初始化成功!',
  1160. initFailed: '%0 初始化失败!',
  1161. errorLink: '链接错误: %0',
  1162. needInit: '请先初始化',
  1163. verifyingAuth: '正在验证%0凭证...',
  1164. updatingAuth: '正在更新%0凭证...',
  1165. initing: '正在初始化...',
  1166. getFailed: '获取%0失败!',
  1167. checkLoginFailed: '检测登录状态失败!',
  1168. checkLeftKeyFailed: '检测剩余Key失败!',
  1169. userId: '用户Id',
  1170. joiningGiveaway: '正在加入赠Key',
  1171. needJoinGiveaway: '需要先加入赠Key',
  1172. cannotUndo: '此网站不支持取消任务',
  1173. verifyAuth: '正在验证 %0 凭证...',
  1174. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1175. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1176. visitingLink: '正在访问链接: ',
  1177. doTask: '做任务',
  1178. undoTask: '撤销任务',
  1179. verifyTask: '验证任务',
  1180. getKey: '获取Key',
  1181. selectAll: '全选',
  1182. selectNone: '全不选',
  1183. invertSelect: '反选',
  1184. doFreeTask: '加入免费赠品',
  1185. doPointTask: '加入点数赠品',
  1186. skipTaskOption: '设置中已配置跳过任务',
  1187. other: '其他',
  1188. globalOptions: '全局设置',
  1189. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1190. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1191. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214',
  1192. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q',
  1193. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1194. saveGlobalOptions: '保存全局设置',
  1195. settingPage: '设置页面',
  1196. name: '名称',
  1197. version: '版本',
  1198. scriptManager: '脚本管理器',
  1199. script: '脚本',
  1200. environment: '环境',
  1201. os: '系统',
  1202. browser: '浏览器',
  1203. getId: '获取 %0 id',
  1204. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1205. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1206. showButton: '显示按钮',
  1207. hideButton: '隐藏按钮',
  1208. showLog: '显示日志',
  1209. hideLog: '隐藏日志',
  1210. defaultShowButton: '默认显示按钮',
  1211. defaultShowLog: '默认显示日志',
  1212. position: '组件位置',
  1213. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1214. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1215. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1216. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1217. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1218. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1219. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1220. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1221. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1222. hotKey: '快捷键',
  1223. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1224. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1225. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1226. tasksHistory: '任务历史',
  1227. clearHistory: '清空历史',
  1228. clearHistoryFinished: '已清空任务历史!',
  1229. deleteTask: '删除任务',
  1230. lastChangeTime: '最后一次修改时间',
  1231. clearTaskFinished: '删除以下任务完成!',
  1232. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1233. syncData: '数据同步',
  1234. settingData: '正在上传数据...',
  1235. gettingData: '正在获取数据...',
  1236. help: '帮助',
  1237. fileName: '文件名',
  1238. upload2gist: '同步到Gist',
  1239. downloadFromGist: '从Gist同步',
  1240. saveAndTest: '保存配置并测试',
  1241. testSuccess: '测试成功!',
  1242. testFailed: '测试失败!',
  1243. saveAndTestNotice: '请先保存配置并测试!',
  1244. processingData: '正在处理数据...',
  1245. updatingData: '正在上传数据...',
  1246. syncDataSuccess: '同步数据成功!',
  1247. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1248. downloadingData: '正在下载数据...',
  1249. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1250. savingData: '正在保存数据...',
  1251. syncHistory: '同步任务历史',
  1252. checkUpdateFailed: '检测更新失败',
  1253. newVersionNotice: '检测到新版本V%0, <a href="%1" target="_blank">点此更新</a>',
  1254. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1255. gistOptions: 'Gist 设置',
  1256. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1257. echoNotice: '检测到您第一次安装V4版本脚本,请<a href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1258. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1259. toGithub: '前往Github反馈',
  1260. toKeylol: '前往其乐论坛反馈',
  1261. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1262. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1263. updateText: '%0 版本更新内容:',
  1264. groups: '组',
  1265. wishlists: '愿望单',
  1266. follows: '游戏关注',
  1267. forums: '论坛',
  1268. workshops: '创意工坊收藏',
  1269. curators: '鉴赏家',
  1270. workshopVotes: '创意工坊点赞',
  1271. announcements: '社区通知',
  1272. steamCommunity: 'Steam社区',
  1273. steamStore: 'Steam商店',
  1274. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1275. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1276. joiningSteamGroup: '正在加入Steam组',
  1277. leavingSteamGroup: '正在退出Steam组',
  1278. gettingSteamGroupId: '正在获取Steam组Id',
  1279. subscribingForum: '正在订阅Steam论坛',
  1280. unsubscribingForum: '正在取消订阅Steam论坛',
  1281. gettingForumId: '正在获取Steam论坛Id',
  1282. followingCurator: '正在关注Steam鉴赏家',
  1283. unfollowingCurator: '正在取关Steam鉴赏家',
  1284. addingToWishlist: '正在添加游戏到Steam愿望单',
  1285. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1286. followingGame: '正在关注Steam游戏',
  1287. unfollowingGame: '正在取关Steam游戏',
  1288. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1289. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1290. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1291. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1292. gettingAnnouncementParams: '正在获取Steam通知信息',
  1293. likingAnnouncement: '正在点赞Steam通知',
  1294. changingArea: '正在更换Steam地区: %0...',
  1295. notNeededChangeArea: '当前地区不需要更换',
  1296. noAnotherArea: '请检测是否开启正确开启代理',
  1297. gettingAreaInfo: '正在获取Steam地区信息...',
  1298. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1299. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1300. servers: '服务器',
  1301. joiningDiscordServer: '正在加入Discord服务器',
  1302. leavingDiscordServer: '正在退出Discord服务器',
  1303. gettingDiscordGuild: '正在获取Discord服务器Id',
  1304. users: '用户',
  1305. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1306. insBanned: '您的Instagram账户已被封禁',
  1307. verifyingInsAuth: '正在验证Instagram凭证...',
  1308. gettingInsUserId: '正在获取Instagram用户Id',
  1309. followingIns: '正在关注Instagram用户',
  1310. unfollowingIns: '正在取关Instagram用户',
  1311. reddits: '社区/用户',
  1312. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1313. changingRedditVersion: '正在切换Reddit为新版页面...',
  1314. joiningReddit: '正在加入Reddit社区',
  1315. leavingReddit: '正在退出Reddit社区',
  1316. followingRedditUser: '正在关注Reddit用户',
  1317. unfollowingRedditUser: '正在取关Reddit用户',
  1318. channels: '频道',
  1319. followingTwitchChannel: '正在关注Twitch频道',
  1320. unfollowingTwitchChannel: '正在取关Twitch频道',
  1321. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1322. twitterUser: '推特用户',
  1323. retweets: '转推',
  1324. followingTwitterUser: '正在关注推特用户',
  1325. unfollowingTwitterUser: '正在取关推特用户',
  1326. retweetting: '正在转推',
  1327. unretweetting: '正在撤销转推',
  1328. names: '组/社区/动态',
  1329. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1330. gettingVkId: '正在获取Vk任务Id',
  1331. joiningVkGroup: '正在加入Vk组',
  1332. leavingVkGroup: '正在退出Vk组',
  1333. joiningVkPublic: '正在加入Vk社区',
  1334. leavingVkPublic: '正在退出Vk社区',
  1335. sendingVkWall: '正在转发Vk动态',
  1336. deletingVkWall: '正在撤销转发Vk动态',
  1337. youtubeChannel: 'YouTube频道',
  1338. likes: '点赞',
  1339. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1340. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1341. gettingYtbToken: '正在获取YouTube Token...',
  1342. followingYtbChannel: '正在订阅YouTube频道',
  1343. unfollowingYtbChannel: '正在退订YouTube频道',
  1344. likingYtbVideo: '正在点赞YouTube视频',
  1345. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1346. giveKeyNoticeBefore: '每次验证间隔15s',
  1347. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1348. noPoints: '点数不够,跳过抽奖',
  1349. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1350. joiningLottery: '正在加入抽奖',
  1351. doingGleamTask: '正在做Gleam任务...',
  1352. gettingGleamLink: '正在获取Gleam任务链接...',
  1353. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1354. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1355. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1356. };
  1357. const zh_CN = data;
  1358. const en_US_data = {
  1359. website: 'Website',
  1360. type: 'Type',
  1361. edit: 'Edit',
  1362. whiteList: 'Whitelist',
  1363. skipTask: 'Skip undo task',
  1364. whiteListOptions: 'Whitelist options',
  1365. changeWhiteListOption: 'Whitelist option(%0)',
  1366. whiteListNotFound: 'Cannot find this whitelist: %0',
  1367. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1368. changeWebsiteOptions: 'Website options',
  1369. changeGlobalOptions: 'Global options',
  1370. ok: 'OK',
  1371. save: 'Save',
  1372. close: 'Close',
  1373. return: 'Return',
  1374. option: 'Option',
  1375. value: 'Value',
  1376. websiteOptions: 'Current website settings',
  1377. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1378. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1379. needLogin: 'Please log in first!',
  1380. getTasksInfo: 'Obtaining and processing task information...',
  1381. gettingKey: 'Getting Key...',
  1382. verifyingTask: 'Verifying task',
  1383. notice: 'Automatic task script notice',
  1384. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1385. giveawayEnded: 'This event has ended, do you want to close it?',
  1386. 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?',
  1387. confirm: 'Confirm',
  1388. cancel: 'Cancel',
  1389. unKnown: 'Unknown',
  1390. unKnownTaskType: 'Unrecognized task',
  1391. doing: 'Doing a task',
  1392. allTasksComplete: 'All tasks have been completed!',
  1393. getTaskIdFailed: 'Failed to obtain task Id!',
  1394. initSuccess: '%0 was initialized successfully!',
  1395. initFailed: '%0 initialization failed!',
  1396. errorLink: 'Link error: %0',
  1397. needInit: 'Please initialize first',
  1398. verifyingAuth: 'Verifying %0 token...',
  1399. updatingAuth: 'Update %0 token...',
  1400. initing: 'Initializing...',
  1401. getFailed: 'Failed to get %0!',
  1402. checkLoginFailed: 'Failed to detect login status!',
  1403. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1404. userId: 'User Id',
  1405. joiningGiveaway: 'Joining giveaway',
  1406. needJoinGiveaway: 'Need to join the giveaway first',
  1407. cannotUndo: 'This website does not support canceling tasks',
  1408. verifyAuth: 'Verifying %0 token...',
  1409. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1410. errorReport: 'A script error is detected, do you want to report the BUG?',
  1411. visitingLink: 'Visiting link: ',
  1412. doTask: 'DoTask',
  1413. undoTask: 'UndoTask',
  1414. verifyTask: 'Verify',
  1415. getKey: 'GetKey',
  1416. selectAll: 'SelectAll',
  1417. selectNone: 'SelectNone',
  1418. invertSelect: 'InvertSelect',
  1419. doFreeTask: 'FreeTask',
  1420. doPointTask: 'PointTask',
  1421. skipTaskOption: 'Skip task has been configured in the settings',
  1422. other: 'Other',
  1423. globalOptions: 'Global Options',
  1424. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1425. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1426. twitterVerifyId: 'Verify Twitter token by trying to follow the account.</br>The default is the official Twitter account 783214.',
  1427. youtubeVerifyChannel: 'Verify YouTube token by trying to subscribe to the channel.</br>' + 'The default is the official YouTube channel UCrXUsMBcfTVqwAS7DKg9C0Q.',
  1428. 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.',
  1429. saveGlobalOptions: 'SaveSettings',
  1430. settingPage: 'Setting Page',
  1431. name: 'Name',
  1432. version: 'Version',
  1433. scriptManager: 'Script Manager',
  1434. script: 'Script',
  1435. environment: 'Environment',
  1436. os: 'OS',
  1437. browser: 'Browser',
  1438. getId: 'Get %0 id',
  1439. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1440. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1441. showButton: 'ShowButton',
  1442. hideButton: 'HideButton',
  1443. showLog: 'ShowLog',
  1444. hideLog: 'HideLog',
  1445. defaultShowButton: 'Default display button',
  1446. defaultShowLog: 'Display log by default',
  1447. position: 'Component position',
  1448. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1449. 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',
  1450. 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',
  1451. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1452. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1453. 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',
  1454. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1455. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1456. 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',
  1457. hotKey: 'Shortcut key',
  1458. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1459. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1460. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1461. tasksHistory: 'TasksHistory',
  1462. clearHistory: 'Clear history',
  1463. clearHistoryFinished: 'The mission history has been cleared!',
  1464. deleteTask: 'Delete task',
  1465. lastChangeTime: 'Last Change Time',
  1466. clearTaskFinished: 'Delete the following tasks completed!',
  1467. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1468. syncData: 'Data synchronization',
  1469. settingData: 'Uploading data...',
  1470. gettingData: 'Getting data...',
  1471. help: 'Help',
  1472. fileName: 'Filename',
  1473. upload2gist: 'Sync to Gist',
  1474. downloadFromGist: 'Sync from Gist',
  1475. saveAndTest: 'Save configuration and test',
  1476. testSuccess: 'Test success!',
  1477. testFailed: 'Test failed!',
  1478. saveAndTestNotice: 'Please save the configuration and test first!',
  1479. processingData: 'Processing data...',
  1480. updatingData: 'Uploading data...',
  1481. syncDataSuccess: 'Synchronized data successfully!',
  1482. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1483. downloadingData: 'Downloading data...',
  1484. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1485. savingData: 'Saving data...',
  1486. syncHistory: 'Synchronize tasks history',
  1487. checkUpdateFailed: 'Check update failed',
  1488. newVersionNotice: 'Checked a new version V%0, <a href="%1" target="_blank">click to update</a>',
  1489. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1490. gistOptions: 'Gist Settings',
  1491. 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!',
  1492. echoNotice: 'It is detected that you are installing the V4 version script for the first time' + ', please <a href="%0" target="_blank">click here</a> to read the READ ME FIRST content before use!',
  1493. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1494. toGithub: 'Feedback(Github)',
  1495. toKeylol: 'Feedback(Keylol)',
  1496. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1497. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1498. updateText: 'Updates in version %0:',
  1499. groups: 'Group',
  1500. wishlists: 'Wishlist',
  1501. follows: 'Follow Game',
  1502. forums: 'Forum',
  1503. workshops: 'Favorite Workshop',
  1504. curators: 'Curator',
  1505. workshopVotes: 'Voteup Workshop',
  1506. announcements: 'Announcement',
  1507. steamCommunity: 'Steam Community',
  1508. steamStore: 'Steam Store',
  1509. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1510. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1511. joiningSteamGroup: 'Joining Steam Group',
  1512. leavingSteamGroup: 'Leaving Steam Group',
  1513. gettingSteamGroupId: 'Getting Steam Group Id',
  1514. subscribingForum: 'Subscribing the Steam Forum',
  1515. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1516. gettingForumId: 'Getting Steam Forum Id',
  1517. followingCurator: 'Following Steam Curator',
  1518. unfollowingCurator: 'Unfollowing Steam Curator',
  1519. addingToWishlist: 'Adding the game to the Steam wishlist',
  1520. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1521. followingGame: 'Following Steam games',
  1522. unfollowingGame: 'Unfollowing Steam games',
  1523. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1524. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1525. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1526. votingUpWorkshop: 'Liking Steam workshop items',
  1527. gettingAnnouncementParams: 'Getting Steam announcement information',
  1528. likingAnnouncement: 'Liking Steam announcement',
  1529. changingArea: 'Changing Steam area: %0...',
  1530. notNeededChangeArea: 'The current area does not need to be changed',
  1531. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1532. gettingAreaInfo: 'Getting Steam area information...',
  1533. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1534. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1535. servers: 'Server',
  1536. joiningDiscordServer: 'Joining Discord Server',
  1537. leavingDiscordServer: 'Leaving Discord Server',
  1538. gettingDiscordGuild: 'Getting Discord server Id',
  1539. users: 'User',
  1540. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1541. insBanned: 'Your Instagram account has been banned',
  1542. verifyingInsAuth: 'Verifying Instagram token...',
  1543. gettingInsUserId: 'Getting Instagram user Id',
  1544. followingIns: 'Following Instagram user',
  1545. unfollowingIns: 'Unfollowing Instagram user',
  1546. reddits: 'Reddit/User',
  1547. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1548. changingRedditVersion: 'Switching Reddit to a new version page...',
  1549. joiningReddit: 'Joining the Reddit',
  1550. leavingReddit: 'Leaving the Reddit',
  1551. followingRedditUser: 'Following Reddit User',
  1552. unfollowingRedditUser: 'Unfollowing Reddit User',
  1553. channels: 'Channel',
  1554. followingTwitchChannel: 'Following Twitch Channel',
  1555. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1556. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1557. twitterUser: 'Twitter User',
  1558. retweets: 'Retweet',
  1559. followingTwitterUser: 'Following Twitter User',
  1560. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1561. retweetting: 'Retweeting',
  1562. unretweetting: 'Unretweeting',
  1563. names: 'Group/Public/Wall',
  1564. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1565. gettingVkId: 'Getting Vk task Id',
  1566. joiningVkGroup: 'Joining Vk Group',
  1567. leavingVkGroup: 'Leaving Vk Group',
  1568. joiningVkPublic: 'Joining Vk Public',
  1569. leavingVkPublic: 'Leaving Vk Public',
  1570. sendingVkWall: 'Sending Vk Wall',
  1571. deletingVkWall: 'Deleting Vk Wall',
  1572. youtubeChannel: 'YouTube Channel',
  1573. likes: 'Like',
  1574. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1575. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1576. gettingYtbToken: 'Getting YouTube Token...',
  1577. followingYtbChannel: 'Subscribing to YouTube channel',
  1578. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1579. likingYtbVideo: 'Liking YouTube video',
  1580. unlikingYtbVideo: 'Unliking YouTube video',
  1581. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1582. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1583. noPoints: 'Not enough points, skip the lottery',
  1584. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1585. joiningLottery: 'Joining the lottery',
  1586. doingGleamTask: 'Doing Gleam Task...',
  1587. gettingGleamLink: 'Getting Gleam task link...',
  1588. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1589. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1590. 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...'
  1591. };
  1592. const en_US = en_US_data;
  1593. const languages = {
  1594. zh: zh_CN,
  1595. en: en_US
  1596. };
  1597. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1598. const I18n = function(key) {
  1599. var _languages$language;
  1600. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1601. argvs[_key - 1] = arguments[_key];
  1602. }
  1603. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1604. return key;
  1605. }
  1606. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1607. };
  1608. const i18n = I18n;
  1609. function throwError(error, name) {
  1610. external_Swal_default().fire({
  1611. title: i18n('errorReport'),
  1612. icon: 'error',
  1613. showCancelButton: true,
  1614. confirmButtonText: i18n('toGithub'),
  1615. showDenyButton: true,
  1616. denyButtonText: i18n('toKeylol'),
  1617. cancelButtonText: i18n('close')
  1618. }).then(_ref => {
  1619. let {
  1620. isDenied,
  1621. isConfirmed
  1622. } = _ref;
  1623. if (isConfirmed) {
  1624. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1625.  
  1626. 环境:
  1627. \`\`\`
  1628. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1629. \`\`\`
  1630. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1631. 脚本版本: \`${GM_info.script.version}\`
  1632.  
  1633. 报错信息:
  1634. \`\`\`
  1635. ${error.stack}
  1636. \`\`\`
  1637.  
  1638. 执行日志:
  1639. \`\`\`
  1640. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1641. \`\`\`
  1642. `)}`, '_blank');
  1643. } else if (isDenied) {
  1644. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1645.  
  1646. 环境:
  1647.  
  1648. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1649.  
  1650. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1651. 脚本版本: ${GM_info.script.version}
  1652.  
  1653. 报错信息:
  1654. [code]${error.stack}[/code]
  1655.  
  1656. 执行日志:
  1657. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1658. const textarea = $('<textarea>');
  1659. $('body').append(textarea);
  1660. textarea.val(text).trigger('select');
  1661. if (document.execCommand('Copy')) {
  1662. external_Swal_default().fire({
  1663. title: i18n('copySuccess'),
  1664. icon: 'success',
  1665. confirmButtonText: i18n('ok')
  1666. }).then(() => {
  1667. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1668. });
  1669. } else {
  1670. external_Swal_default().fire({
  1671. title: i18n('copyFailed'),
  1672. input: 'textarea',
  1673. inputValue: text,
  1674. confirmButtonText: i18n('ok')
  1675. }).then(() => {
  1676. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1677. });
  1678. }
  1679. textarea.remove();
  1680. }
  1681. });
  1682. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1683. }
  1684. function _defineProperty(obj, key, value) {
  1685. if (key in obj) {
  1686. Object.defineProperty(obj, key, {
  1687. value: value,
  1688. enumerable: true,
  1689. configurable: true,
  1690. writable: true
  1691. });
  1692. } else {
  1693. obj[key] = value;
  1694. }
  1695. return obj;
  1696. }
  1697. class Social {
  1698. constructor() {
  1699. _defineProperty(this, 'tasks', void 0);
  1700. }
  1701. getRealParams(name, links, doTask, link2param) {
  1702. try {
  1703. let realParams = [];
  1704. if (links.length > 0) {
  1705. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1706. }
  1707. if (!doTask && this.tasks[name].length > 0) {
  1708. realParams = [ ...realParams, ...this.tasks[name] ];
  1709. }
  1710. return unique(realParams);
  1711. } catch (error) {
  1712. throwError(error, 'Social.getRealParams');
  1713. return [];
  1714. }
  1715. }
  1716. }
  1717. const social_Social = Social;
  1718. function _classPrivateMethodInitSpec(obj, privateSet) {
  1719. _checkPrivateRedeclaration(obj, privateSet);
  1720. privateSet.add(obj);
  1721. }
  1722. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1723. _checkPrivateRedeclaration(obj, privateMap);
  1724. privateMap.set(obj, value);
  1725. }
  1726. function _checkPrivateRedeclaration(obj, privateCollection) {
  1727. if (privateCollection.has(obj)) {
  1728. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1729. }
  1730. }
  1731. function Discord_defineProperty(obj, key, value) {
  1732. if (key in obj) {
  1733. Object.defineProperty(obj, key, {
  1734. value: value,
  1735. enumerable: true,
  1736. configurable: true,
  1737. writable: true
  1738. });
  1739. } else {
  1740. obj[key] = value;
  1741. }
  1742. return obj;
  1743. }
  1744. function _classPrivateFieldSet(receiver, privateMap, value) {
  1745. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1746. _classApplyDescriptorSet(receiver, descriptor, value);
  1747. return value;
  1748. }
  1749. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1750. if (descriptor.set) {
  1751. descriptor.set.call(receiver, value);
  1752. } else {
  1753. if (!descriptor.writable) {
  1754. throw new TypeError('attempted to set read only private field');
  1755. }
  1756. descriptor.value = value;
  1757. }
  1758. }
  1759. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1760. if (!privateSet.has(receiver)) {
  1761. throw new TypeError('attempted to get private field on non-instance');
  1762. }
  1763. return fn;
  1764. }
  1765. function _classPrivateFieldGet(receiver, privateMap) {
  1766. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1767. return _classApplyDescriptorGet(receiver, descriptor);
  1768. }
  1769. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1770. if (!privateMap.has(receiver)) {
  1771. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1772. }
  1773. return privateMap.get(receiver);
  1774. }
  1775. function _classApplyDescriptorGet(receiver, descriptor) {
  1776. if (descriptor.get) {
  1777. return descriptor.get.call(receiver);
  1778. }
  1779. return descriptor.value;
  1780. }
  1781. const defaultTasks = {
  1782. servers: []
  1783. };
  1784. var _auth = new WeakMap();
  1785. var _cache = new WeakMap();
  1786. var _initialized = new WeakMap();
  1787. var _verifyAuth = new WeakSet();
  1788. var _updateAuth = new WeakSet();
  1789. var _joinServer = new WeakSet();
  1790. var _leaveServer = new WeakSet();
  1791. var _getGuild = new WeakSet();
  1792. var _setCache = new WeakSet();
  1793. class Discord extends social_Social {
  1794. constructor() {
  1795. var _GM_getValue;
  1796. super(...arguments);
  1797. _classPrivateMethodInitSpec(this, _setCache);
  1798. _classPrivateMethodInitSpec(this, _getGuild);
  1799. _classPrivateMethodInitSpec(this, _leaveServer);
  1800. _classPrivateMethodInitSpec(this, _joinServer);
  1801. _classPrivateMethodInitSpec(this, _updateAuth);
  1802. _classPrivateMethodInitSpec(this, _verifyAuth);
  1803. Discord_defineProperty(this, 'tasks', {
  1804. ...defaultTasks
  1805. });
  1806. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || {
  1807. ...defaultTasks
  1808. });
  1809. _classPrivateFieldInitSpec(this, _auth, {
  1810. writable: true,
  1811. value: GM_getValue('discordAuth') || {}
  1812. });
  1813. _classPrivateFieldInitSpec(this, _cache, {
  1814. writable: true,
  1815. value: GM_getValue('discordCache') || {}
  1816. });
  1817. _classPrivateFieldInitSpec(this, _initialized, {
  1818. writable: true,
  1819. value: false
  1820. });
  1821. }
  1822. async init() {
  1823. try {
  1824. if (_classPrivateFieldGet(this, _initialized)) {
  1825. return true;
  1826. }
  1827. if (!_classPrivateFieldGet(this, _auth).auth) {
  1828. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1829. _classPrivateFieldSet(this, _initialized, true);
  1830. return true;
  1831. }
  1832. return false;
  1833. }
  1834. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1835. if (isVerified) {
  1836. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1837. _classPrivateFieldSet(this, _initialized, true);
  1838. return true;
  1839. }
  1840. GM_setValue('discordAuth', {
  1841. auth: null
  1842. });
  1843. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1844. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1845. _classPrivateFieldSet(this, _initialized, true);
  1846. return true;
  1847. }
  1848. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1849. return false;
  1850. } catch (error) {
  1851. throwError(error, 'Discord.init');
  1852. return false;
  1853. }
  1854. }
  1855. async toggle(_ref) {
  1856. let {
  1857. doTask = true,
  1858. serverLinks = []
  1859. } = _ref;
  1860. try {
  1861. if (!_classPrivateFieldGet(this, _initialized)) {
  1862. scripts_echoLog({
  1863. text: i18n('needInit')
  1864. });
  1865. return false;
  1866. }
  1867. const prom = [];
  1868. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1869. scripts_echoLog({
  1870. type: 'globalOptionsSkip',
  1871. text: 'discord.servers'
  1872. });
  1873. } else {
  1874. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1875. var _link$match;
  1876. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1877. });
  1878. if (realServers.length > 0) {
  1879. for (const server of realServers) {
  1880. if (doTask) {
  1881. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1882. } else {
  1883. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1884. }
  1885. await delay(1e3);
  1886. }
  1887. }
  1888. }
  1889. return await Promise.all(prom).then(() => true);
  1890. } catch (error) {
  1891. throwError(error, 'Discord.toggleServers');
  1892. return false;
  1893. }
  1894. }
  1895. }
  1896. async function _verifyAuth2() {
  1897. try {
  1898. const logStatus = scripts_echoLog({
  1899. text: i18n('verifyingAuth', 'Discord')
  1900. });
  1901. const {
  1902. result,
  1903. statusText,
  1904. status,
  1905. data
  1906. } = await tools_httpRequest({
  1907. url: 'https://discord.com/api/v6/users/@me',
  1908. method: 'HEAD',
  1909. headers: {
  1910. authorization: _classPrivateFieldGet(this, _auth).auth
  1911. }
  1912. });
  1913. if (result === 'Success') {
  1914. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1915. logStatus.success();
  1916. return true;
  1917. }
  1918. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1919. return false;
  1920. }
  1921. logStatus.error(`${result}:${statusText}(${status})`);
  1922. return false;
  1923. } catch (error) {
  1924. throwError(error, 'Discord.verifyAuth');
  1925. return false;
  1926. }
  1927. }
  1928. async function _updateAuth2() {
  1929. try {
  1930. const logStatus = scripts_echoLog({
  1931. text: i18n('updatingAuth', 'Discord')
  1932. });
  1933. return await new Promise(resolve => {
  1934. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1935. active: true,
  1936. insert: true,
  1937. setParent: true
  1938. });
  1939. newTab.onclose = async () => {
  1940. var _GM_getValue2;
  1941. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1942. if (auth) {
  1943. _classPrivateFieldSet(this, _auth, {
  1944. auth: auth
  1945. });
  1946. logStatus.success();
  1947. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1948. } else {
  1949. logStatus.error('Error: Update discord auth failed!');
  1950. resolve(false);
  1951. }
  1952. };
  1953. });
  1954. } catch (error) {
  1955. throwError(error, 'Discord.updateAuth');
  1956. return false;
  1957. }
  1958. }
  1959. async function _joinServer2(inviteId) {
  1960. try {
  1961. const logStatus = scripts_echoLog({
  1962. type: 'joiningDiscordServer',
  1963. text: inviteId
  1964. });
  1965. const {
  1966. result,
  1967. statusText,
  1968. status,
  1969. data
  1970. } = await tools_httpRequest({
  1971. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1972. method: 'POST',
  1973. dataType: 'json',
  1974. headers: {
  1975. authorization: _classPrivateFieldGet(this, _auth).auth
  1976. }
  1977. });
  1978. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1979. var _data$response, _data$response$guild;
  1980. logStatus.success();
  1981. 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);
  1982. if (guild) {
  1983. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1984. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1985. }
  1986. return true;
  1987. }
  1988. logStatus.error(`${result}:${statusText}(${status})`);
  1989. return false;
  1990. } catch (error) {
  1991. throwError(error, 'Discord.joinServer');
  1992. return false;
  1993. }
  1994. }
  1995. async function _leaveServer2(inviteId) {
  1996. try {
  1997. if (this.whiteList.servers.includes(inviteId)) {
  1998. scripts_echoLog({
  1999. type: 'whiteList',
  2000. text: 'Discord.leaveServer',
  2001. id: inviteId
  2002. });
  2003. return true;
  2004. }
  2005. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2006. if (!guild) {
  2007. return false;
  2008. }
  2009. const logStatus = scripts_echoLog({
  2010. type: 'leavingDiscordServer',
  2011. text: guild
  2012. });
  2013. const {
  2014. result,
  2015. statusText,
  2016. status,
  2017. data
  2018. } = await tools_httpRequest({
  2019. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2020. method: 'DELETE',
  2021. headers: {
  2022. authorization: _classPrivateFieldGet(this, _auth).auth
  2023. }
  2024. });
  2025. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2026. logStatus.success();
  2027. return true;
  2028. }
  2029. logStatus.error(`${result}:${statusText}(${status})`);
  2030. return false;
  2031. } catch (error) {
  2032. throwError(error, 'Discord.leaveServer');
  2033. return false;
  2034. }
  2035. }
  2036. async function _getGuild2(inviteId) {
  2037. try {
  2038. const logStatus = scripts_echoLog({
  2039. type: 'gettingDiscordGuild',
  2040. text: inviteId
  2041. });
  2042. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2043. if (guild) {
  2044. logStatus.success();
  2045. return guild;
  2046. }
  2047. const {
  2048. result,
  2049. statusText,
  2050. status,
  2051. data
  2052. } = await tools_httpRequest({
  2053. url: `https://discord.com/invite/${inviteId}`,
  2054. method: 'GET'
  2055. });
  2056. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2057. var _data$responseText$ma;
  2058. 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];
  2059. if (guild) {
  2060. logStatus.success();
  2061. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2062. return guild;
  2063. }
  2064. logStatus.error(`${result}:${statusText}(${status})`);
  2065. return false;
  2066. }
  2067. logStatus.error(`${result}:${statusText}(${status})`);
  2068. return false;
  2069. } catch (error) {
  2070. throwError(error, 'Discord.getGuild');
  2071. return false;
  2072. }
  2073. }
  2074. function _setCache2(inviteId, guild) {
  2075. try {
  2076. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2077. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2078. } catch (error) {
  2079. throwError(error, 'Discord.setCache');
  2080. }
  2081. }
  2082. const social_Discord = Discord;
  2083. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2084. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2085. privateSet.add(obj);
  2086. }
  2087. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2088. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2089. privateMap.set(obj, value);
  2090. }
  2091. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2092. if (privateCollection.has(obj)) {
  2093. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2094. }
  2095. }
  2096. function Instagram_defineProperty(obj, key, value) {
  2097. if (key in obj) {
  2098. Object.defineProperty(obj, key, {
  2099. value: value,
  2100. enumerable: true,
  2101. configurable: true,
  2102. writable: true
  2103. });
  2104. } else {
  2105. obj[key] = value;
  2106. }
  2107. return obj;
  2108. }
  2109. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2110. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2111. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2112. return value;
  2113. }
  2114. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2115. if (descriptor.set) {
  2116. descriptor.set.call(receiver, value);
  2117. } else {
  2118. if (!descriptor.writable) {
  2119. throw new TypeError('attempted to set read only private field');
  2120. }
  2121. descriptor.value = value;
  2122. }
  2123. }
  2124. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2125. if (!privateSet.has(receiver)) {
  2126. throw new TypeError('attempted to get private field on non-instance');
  2127. }
  2128. return fn;
  2129. }
  2130. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2131. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2132. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2133. }
  2134. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2135. if (!privateMap.has(receiver)) {
  2136. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2137. }
  2138. return privateMap.get(receiver);
  2139. }
  2140. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2141. if (descriptor.get) {
  2142. return descriptor.get.call(receiver);
  2143. }
  2144. return descriptor.value;
  2145. }
  2146. const Instagram_defaultTasks = {
  2147. users: []
  2148. };
  2149. var Instagram_cache = new WeakMap();
  2150. var Instagram_auth = new WeakMap();
  2151. var Instagram_initialized = new WeakMap();
  2152. var _getUserInfo = new WeakSet();
  2153. var _followUser = new WeakSet();
  2154. var _unfollowUser = new WeakSet();
  2155. var Instagram_setCache = new WeakSet();
  2156. class Instagram extends social_Social {
  2157. constructor() {
  2158. var _GM_getValue;
  2159. super(...arguments);
  2160. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2161. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2162. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2163. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2164. Instagram_defineProperty(this, 'tasks', {
  2165. ...Instagram_defaultTasks
  2166. });
  2167. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || {
  2168. ...Instagram_defaultTasks
  2169. });
  2170. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2171. writable: true,
  2172. value: GM_getValue('instagramCache') || {}
  2173. });
  2174. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2175. writable: true,
  2176. value: {}
  2177. });
  2178. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2179. writable: true,
  2180. value: false
  2181. });
  2182. }
  2183. async init() {
  2184. try {
  2185. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2186. return true;
  2187. }
  2188. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2189. if (isVerified) {
  2190. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2191. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2192. return true;
  2193. }
  2194. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2195. return false;
  2196. } catch (error) {
  2197. throwError(error, 'Instagram.init');
  2198. return false;
  2199. }
  2200. }
  2201. async toggle(_ref) {
  2202. let {
  2203. doTask = true,
  2204. userLinks = []
  2205. } = _ref;
  2206. try {
  2207. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2208. scripts_echoLog({
  2209. text: i18n('needInit')
  2210. });
  2211. return false;
  2212. }
  2213. const prom = [];
  2214. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2215. scripts_echoLog({
  2216. type: 'globalOptionsSkip',
  2217. text: 'instagram.users'
  2218. });
  2219. } else {
  2220. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2221. var _link$match;
  2222. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2223. });
  2224. if (realUsers.length > 0) {
  2225. for (const username of realUsers) {
  2226. if (doTask) {
  2227. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2228. } else {
  2229. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2230. }
  2231. await delay(1e3);
  2232. }
  2233. }
  2234. }
  2235. return await Promise.all(prom).then(() => true);
  2236. } catch (error) {
  2237. throwError(error, 'Instagram.toggleUsers');
  2238. return false;
  2239. }
  2240. }
  2241. }
  2242. async function _getUserInfo2() {
  2243. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2244. try {
  2245. const logStatus = scripts_echoLog({
  2246. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2247. text: name
  2248. });
  2249. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2250. if (userId && name !== 'instagram') {
  2251. logStatus.success();
  2252. return userId;
  2253. }
  2254. const {
  2255. result,
  2256. statusText,
  2257. status,
  2258. data
  2259. } = await tools_httpRequest({
  2260. url: `https://www.instagram.com/${name}/`,
  2261. method: 'GET'
  2262. });
  2263. if (result === 'Success') {
  2264. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2265. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2266. return false;
  2267. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2268. logStatus.error(`Error:${i18n('insBanned')}`);
  2269. return false;
  2270. }
  2271. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2272. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2273. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2274. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2275. if (name === 'instagram') {
  2276. if (csrftoken && hash) {
  2277. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2278. csrftoken: csrftoken,
  2279. hash: hash
  2280. });
  2281. return true;
  2282. }
  2283. return false;
  2284. }
  2285. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2286. if (id) {
  2287. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2288. logStatus.success();
  2289. return id;
  2290. }
  2291. logStatus.error('Error: Get ins data error!');
  2292. return false;
  2293. }
  2294. logStatus.error(`${result}:${statusText}(${status})`);
  2295. return false;
  2296. }
  2297. return false;
  2298. } catch (error) {
  2299. throwError(error, 'Instagram.getUserInfo');
  2300. return false;
  2301. }
  2302. }
  2303. async function _followUser2(name) {
  2304. try {
  2305. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2306. if (!id) {
  2307. return false;
  2308. }
  2309. const logStatus = scripts_echoLog({
  2310. type: 'followingIns',
  2311. text: name
  2312. });
  2313. const {
  2314. result,
  2315. statusText,
  2316. status,
  2317. data
  2318. } = await tools_httpRequest({
  2319. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2320. method: 'POST',
  2321. dataType: 'json',
  2322. headers: {
  2323. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2324. origin: 'https://www.instagram.com',
  2325. referer: `https://www.instagram.com/${name}/`,
  2326. 'content-type': 'application/x-www-form-urlencoded',
  2327. 'sec-fetch-site': 'same-origin',
  2328. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2329. }
  2330. });
  2331. if (result === 'Success') {
  2332. var _data$response, _data$response2;
  2333. 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') {
  2334. logStatus.success();
  2335. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2336. return true;
  2337. }
  2338. 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})`}`);
  2339. return false;
  2340. }
  2341. logStatus.error(`${result}:${statusText}(${status})`);
  2342. return false;
  2343. } catch (error) {
  2344. throwError(error, 'Instagram.followUser');
  2345. return false;
  2346. }
  2347. }
  2348. async function _unfollowUser2(name) {
  2349. try {
  2350. if (this.whiteList.users.includes(name)) {
  2351. scripts_echoLog({
  2352. type: 'whiteList',
  2353. text: 'Instagram.unfollowUser',
  2354. id: name
  2355. });
  2356. return true;
  2357. }
  2358. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2359. if (!id) {
  2360. return false;
  2361. }
  2362. const logStatus = scripts_echoLog({
  2363. type: 'unfollowingIns',
  2364. text: name
  2365. });
  2366. const {
  2367. result,
  2368. statusText,
  2369. status,
  2370. data
  2371. } = await tools_httpRequest({
  2372. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2373. method: 'POST',
  2374. dataType: 'json',
  2375. headers: {
  2376. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2377. origin: 'https://www.instagram.com',
  2378. referer: `https://www.instagram.com/${name}/`,
  2379. 'content-type': 'application/x-www-form-urlencoded',
  2380. 'sec-fetch-site': 'same-origin',
  2381. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2382. }
  2383. });
  2384. if (result === 'Success') {
  2385. var _data$response3;
  2386. 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') {
  2387. logStatus.success();
  2388. return true;
  2389. }
  2390. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2391. return false;
  2392. }
  2393. logStatus.error(`${result}:${statusText}(${status})`);
  2394. return false;
  2395. } catch (error) {
  2396. throwError(error, 'Instagram.unfollowUser');
  2397. return false;
  2398. }
  2399. }
  2400. function Instagram_setCache2(name, id) {
  2401. try {
  2402. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2403. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2404. } catch (error) {
  2405. throwError(error, 'Instagram.setCache');
  2406. }
  2407. }
  2408. const social_Instagram = Instagram;
  2409. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2410. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2411. privateSet.add(obj);
  2412. }
  2413. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2414. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2415. privateMap.set(obj, value);
  2416. }
  2417. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2418. if (privateCollection.has(obj)) {
  2419. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2420. }
  2421. }
  2422. function Reddit_defineProperty(obj, key, value) {
  2423. if (key in obj) {
  2424. Object.defineProperty(obj, key, {
  2425. value: value,
  2426. enumerable: true,
  2427. configurable: true,
  2428. writable: true
  2429. });
  2430. } else {
  2431. obj[key] = value;
  2432. }
  2433. return obj;
  2434. }
  2435. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2436. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2437. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2438. return value;
  2439. }
  2440. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2441. if (descriptor.set) {
  2442. descriptor.set.call(receiver, value);
  2443. } else {
  2444. if (!descriptor.writable) {
  2445. throw new TypeError('attempted to set read only private field');
  2446. }
  2447. descriptor.value = value;
  2448. }
  2449. }
  2450. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2451. if (!privateSet.has(receiver)) {
  2452. throw new TypeError('attempted to get private field on non-instance');
  2453. }
  2454. return fn;
  2455. }
  2456. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2457. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2458. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2459. }
  2460. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2461. if (!privateMap.has(receiver)) {
  2462. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2463. }
  2464. return privateMap.get(receiver);
  2465. }
  2466. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2467. if (descriptor.get) {
  2468. return descriptor.get.call(receiver);
  2469. }
  2470. return descriptor.value;
  2471. }
  2472. const Reddit_defaultTasks = {
  2473. reddits: []
  2474. };
  2475. var Reddit_auth = new WeakMap();
  2476. var Reddit_initialized = new WeakMap();
  2477. var _useBeta = new WeakSet();
  2478. var Reddit_updateAuth = new WeakSet();
  2479. class Reddit extends social_Social {
  2480. constructor() {
  2481. var _GM_getValue;
  2482. super(...arguments);
  2483. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2484. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2485. Reddit_defineProperty(this, 'tasks', {
  2486. ...Reddit_defaultTasks
  2487. });
  2488. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || {
  2489. ...Reddit_defaultTasks
  2490. });
  2491. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2492. writable: true,
  2493. value: void 0
  2494. });
  2495. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2496. writable: true,
  2497. value: false
  2498. });
  2499. }
  2500. async init() {
  2501. try {
  2502. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2503. return true;
  2504. }
  2505. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2506. if (isVerified) {
  2507. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2508. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2509. return true;
  2510. }
  2511. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2512. return false;
  2513. } catch (error) {
  2514. throwError(error, 'Reddit.init');
  2515. return false;
  2516. }
  2517. }
  2518. async toggleTask(_ref) {
  2519. let {
  2520. name,
  2521. doTask = true
  2522. } = _ref;
  2523. try {
  2524. if (!doTask && this.whiteList.reddits.includes(name)) {
  2525. scripts_echoLog({
  2526. type: 'whiteList',
  2527. text: 'Reddit.undoTask',
  2528. id: name
  2529. });
  2530. return true;
  2531. }
  2532. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2533. if (/^u_/.test(name)) {
  2534. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2535. }
  2536. const logStatus = scripts_echoLog({
  2537. type: type,
  2538. text: name
  2539. });
  2540. const {
  2541. result,
  2542. statusText,
  2543. status,
  2544. data
  2545. } = await tools_httpRequest({
  2546. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2547. method: 'POST',
  2548. headers: {
  2549. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2550. 'content-type': 'application/x-www-form-urlencoded'
  2551. },
  2552. data: $.param({
  2553. action: doTask ? 'sub' : 'unsub',
  2554. sr_name: name,
  2555. api_type: 'json'
  2556. })
  2557. });
  2558. if (result === 'Success') {
  2559. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2560. logStatus.success();
  2561. if (doTask) {
  2562. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2563. }
  2564. return true;
  2565. }
  2566. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2567. return false;
  2568. }
  2569. logStatus.error(`${result}:${statusText}(${status})`);
  2570. return false;
  2571. } catch (error) {
  2572. throwError(error, 'Reddit.toggleTask');
  2573. return false;
  2574. }
  2575. }
  2576. async toggle(_ref2) {
  2577. let {
  2578. doTask = true,
  2579. redditLinks = []
  2580. } = _ref2;
  2581. try {
  2582. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2583. scripts_echoLog({
  2584. text: i18n('needInit')
  2585. });
  2586. return false;
  2587. }
  2588. const prom = [];
  2589. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2590. scripts_echoLog({
  2591. type: 'globalOptionsSkip',
  2592. text: 'reddit.reddits'
  2593. });
  2594. } else {
  2595. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2596. var _link$match, _link$match2;
  2597. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2598. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2599. if (userName) {
  2600. return name || userName;
  2601. }
  2602. return name;
  2603. });
  2604. if (realReddits.length > 0) {
  2605. for (const name of realReddits) {
  2606. prom.push(this.toggleTask({
  2607. name: name,
  2608. doTask: doTask
  2609. }));
  2610. await delay(1e3);
  2611. }
  2612. }
  2613. }
  2614. return await Promise.all(prom).then(() => true);
  2615. } catch (error) {
  2616. throwError(error, 'Reddit.toggle');
  2617. return false;
  2618. }
  2619. }
  2620. }
  2621. async function _useBeta2() {
  2622. try {
  2623. const logStatus = scripts_echoLog({
  2624. text: i18n('changingRedditVersion')
  2625. });
  2626. GM_setValue('redditAuth', null);
  2627. return await new Promise(resolve => {
  2628. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2629. active: true,
  2630. insert: true,
  2631. setParent: true
  2632. });
  2633. newTab.onclose = async () => {
  2634. logStatus.success();
  2635. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2636. };
  2637. });
  2638. } catch (error) {
  2639. throwError(error, 'Reddit.useBeta');
  2640. return false;
  2641. }
  2642. }
  2643. async function Reddit_updateAuth2() {
  2644. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2645. try {
  2646. const logStatus = scripts_echoLog({
  2647. text: i18n('updatingAuth', 'Reddit')
  2648. });
  2649. const {
  2650. result,
  2651. statusText,
  2652. status,
  2653. data
  2654. } = await tools_httpRequest({
  2655. url: 'https://www.reddit.com/',
  2656. method: 'GET',
  2657. nochche: true,
  2658. headers: {
  2659. 'Cache-Control': 'no-cache'
  2660. }
  2661. });
  2662. if (result === 'Success') {
  2663. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2664. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2665. return false;
  2666. }
  2667. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2668. var _data$responseText$ma;
  2669. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2670. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2671. }
  2672. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2673. if (accessToken) {
  2674. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2675. token: accessToken
  2676. });
  2677. logStatus.success();
  2678. return true;
  2679. }
  2680. logStatus.error('Error: Parameter "accessToken" not found!');
  2681. return false;
  2682. }
  2683. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2684. return false;
  2685. }
  2686. logStatus.error(`${result}:${statusText}(${status})`);
  2687. return false;
  2688. } catch (error) {
  2689. throwError(error, 'Reddit.updateAuth');
  2690. return false;
  2691. }
  2692. }
  2693. const social_Reddit = Reddit;
  2694. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2695. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2696. privateSet.add(obj);
  2697. }
  2698. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2699. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2700. privateMap.set(obj, value);
  2701. }
  2702. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2703. if (privateCollection.has(obj)) {
  2704. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2705. }
  2706. }
  2707. function Twitch_defineProperty(obj, key, value) {
  2708. if (key in obj) {
  2709. Object.defineProperty(obj, key, {
  2710. value: value,
  2711. enumerable: true,
  2712. configurable: true,
  2713. writable: true
  2714. });
  2715. } else {
  2716. obj[key] = value;
  2717. }
  2718. return obj;
  2719. }
  2720. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2721. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2722. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2723. return value;
  2724. }
  2725. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2726. if (descriptor.set) {
  2727. descriptor.set.call(receiver, value);
  2728. } else {
  2729. if (!descriptor.writable) {
  2730. throw new TypeError('attempted to set read only private field');
  2731. }
  2732. descriptor.value = value;
  2733. }
  2734. }
  2735. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2736. if (!privateSet.has(receiver)) {
  2737. throw new TypeError('attempted to get private field on non-instance');
  2738. }
  2739. return fn;
  2740. }
  2741. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2742. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2743. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2744. }
  2745. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2746. if (!privateMap.has(receiver)) {
  2747. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2748. }
  2749. return privateMap.get(receiver);
  2750. }
  2751. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2752. if (descriptor.get) {
  2753. return descriptor.get.call(receiver);
  2754. }
  2755. return descriptor.value;
  2756. }
  2757. const Twitch_defaultTasks = {
  2758. channels: []
  2759. };
  2760. var Twitch_auth = new WeakMap();
  2761. var Twitch_cache = new WeakMap();
  2762. var Twitch_initialized = new WeakMap();
  2763. var Twitch_verifyAuth = new WeakSet();
  2764. var Twitch_updateAuth = new WeakSet();
  2765. var _toggleChannel = new WeakSet();
  2766. var _getChannelId = new WeakSet();
  2767. var Twitch_setCache = new WeakSet();
  2768. class Twitch extends social_Social {
  2769. constructor() {
  2770. var _GM_getValue;
  2771. super(...arguments);
  2772. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2773. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2774. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2775. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2776. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2777. Twitch_defineProperty(this, 'tasks', {
  2778. ...Twitch_defaultTasks
  2779. });
  2780. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || {
  2781. ...Twitch_defaultTasks
  2782. });
  2783. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2784. writable: true,
  2785. value: GM_getValue('twitchAuth') || {}
  2786. });
  2787. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2788. writable: true,
  2789. value: GM_getValue('twitchCache') || {}
  2790. });
  2791. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2792. writable: true,
  2793. value: false
  2794. });
  2795. }
  2796. async init() {
  2797. try {
  2798. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2799. return true;
  2800. }
  2801. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2802. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2803. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2804. return true;
  2805. }
  2806. return false;
  2807. }
  2808. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2809. if (isVerified) {
  2810. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2811. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2812. return true;
  2813. }
  2814. GM_setValue('twitchAuth', null);
  2815. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2816. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2817. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2818. return true;
  2819. }
  2820. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2821. return false;
  2822. } catch (error) {
  2823. throwError(error, 'Twitch.init');
  2824. return false;
  2825. }
  2826. }
  2827. async toggle(_ref) {
  2828. let {
  2829. doTask = true,
  2830. channelLinks = []
  2831. } = _ref;
  2832. try {
  2833. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2834. scripts_echoLog({
  2835. text: i18n('needInit')
  2836. });
  2837. return false;
  2838. }
  2839. const prom = [];
  2840. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2841. scripts_echoLog({
  2842. type: 'globalOptionsSkip',
  2843. text: 'twitch.channels'
  2844. });
  2845. } else {
  2846. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2847. var _link$match;
  2848. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2849. });
  2850. if (realChannels.length > 0) {
  2851. for (const channel of realChannels) {
  2852. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2853. name: channel,
  2854. doTask: doTask
  2855. }));
  2856. await delay(1e3);
  2857. }
  2858. }
  2859. }
  2860. return Promise.all(prom).then(() => true);
  2861. } catch (error) {
  2862. throwError(error, 'Twitch.toggle');
  2863. return false;
  2864. }
  2865. }
  2866. }
  2867. async function Twitch_verifyAuth2() {
  2868. try {
  2869. const logStatus = scripts_echoLog({
  2870. text: i18n('verifyingAuth', 'Twitch')
  2871. });
  2872. const {
  2873. result,
  2874. statusText,
  2875. status,
  2876. data
  2877. } = await tools_httpRequest({
  2878. url: 'https://gql.twitch.tv/gql',
  2879. method: 'POST',
  2880. dataType: 'json',
  2881. headers: {
  2882. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2883. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2884. },
  2885. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2886. });
  2887. if (result === 'Success') {
  2888. var _data$response, _data$response$, _data$response$$data;
  2889. 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) {
  2890. logStatus.success();
  2891. return true;
  2892. }
  2893. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2894. return false;
  2895. }
  2896. logStatus.error(`${result}:${statusText}(${status})`);
  2897. return false;
  2898. } catch (error) {
  2899. throwError(error, 'Twitch.verifyAuth');
  2900. return false;
  2901. }
  2902. }
  2903. async function Twitch_updateAuth2() {
  2904. try {
  2905. const logStatus = scripts_echoLog({
  2906. text: i18n('updatingAuth', 'Twitch')
  2907. });
  2908. return await new Promise(resolve => {
  2909. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2910. active: true,
  2911. insert: true,
  2912. setParent: true
  2913. });
  2914. newTab.onclose = async () => {
  2915. const auth = GM_getValue('twitchAuth');
  2916. if (auth) {
  2917. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2918. logStatus.success();
  2919. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2920. } else {
  2921. logStatus.error('Error: Update twitch auth failed!');
  2922. resolve(false);
  2923. }
  2924. };
  2925. });
  2926. } catch (error) {
  2927. throwError(error, 'Twitch.updateAuth');
  2928. return false;
  2929. }
  2930. }
  2931. async function _toggleChannel2(_ref2) {
  2932. let {
  2933. name,
  2934. doTask = true
  2935. } = _ref2;
  2936. try {
  2937. if (!doTask && this.whiteList.channels.includes(name)) {
  2938. scripts_echoLog({
  2939. type: 'whiteList',
  2940. text: 'Twitch.unfollowChannel',
  2941. id: name
  2942. });
  2943. return true;
  2944. }
  2945. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2946. if (!channelId) {
  2947. return false;
  2948. }
  2949. const logStatus = scripts_echoLog({
  2950. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2951. text: name
  2952. });
  2953. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2954. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2955. const {
  2956. result,
  2957. statusText,
  2958. status,
  2959. data
  2960. } = await tools_httpRequest({
  2961. url: 'https://gql.twitch.tv/gql',
  2962. method: 'POST',
  2963. dataType: 'json',
  2964. headers: {
  2965. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2966. },
  2967. data: doTask ? followData : unfollowData
  2968. });
  2969. if (result === 'Success') {
  2970. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2971. logStatus.success();
  2972. if (doTask) {
  2973. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2974. }
  2975. return true;
  2976. }
  2977. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2978. return false;
  2979. }
  2980. logStatus.error(`${result}:${statusText}(${status})`);
  2981. return false;
  2982. } catch (error) {
  2983. throwError(error, 'Twitch.toggleChannel');
  2984. return false;
  2985. }
  2986. }
  2987. async function _getChannelId2(name) {
  2988. try {
  2989. const logStatus = scripts_echoLog({
  2990. type: 'gettingTwitchChannelId',
  2991. text: name
  2992. });
  2993. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  2994. if (channelId) {
  2995. logStatus.success();
  2996. return channelId;
  2997. }
  2998. const {
  2999. result,
  3000. statusText,
  3001. status,
  3002. data
  3003. } = await tools_httpRequest({
  3004. url: 'https://gql.twitch.tv/gql',
  3005. method: 'POST',
  3006. headers: {
  3007. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3008. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3009. },
  3010. responseType: 'json',
  3011. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3012. });
  3013. if (result === 'Success') {
  3014. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3015. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3016. 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);
  3017. if (channelId) {
  3018. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3019. logStatus.success();
  3020. return channelId;
  3021. }
  3022. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3023. return false;
  3024. }
  3025. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3026. return false;
  3027. }
  3028. logStatus.error(`${result}:${statusText}(${status})`);
  3029. return false;
  3030. } catch (error) {
  3031. throwError(error, 'Twitch.getChannelId');
  3032. return false;
  3033. }
  3034. }
  3035. function Twitch_setCache2(name, id) {
  3036. try {
  3037. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3038. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3039. } catch (error) {
  3040. throwError(error, 'Twitch.setCache');
  3041. }
  3042. }
  3043. const social_Twitch = Twitch;
  3044. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3045. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3046. privateSet.add(obj);
  3047. }
  3048. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3049. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3050. privateMap.set(obj, value);
  3051. }
  3052. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3053. if (privateCollection.has(obj)) {
  3054. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3055. }
  3056. }
  3057. function Twitter_defineProperty(obj, key, value) {
  3058. if (key in obj) {
  3059. Object.defineProperty(obj, key, {
  3060. value: value,
  3061. enumerable: true,
  3062. configurable: true,
  3063. writable: true
  3064. });
  3065. } else {
  3066. obj[key] = value;
  3067. }
  3068. return obj;
  3069. }
  3070. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3071. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3072. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3073. return value;
  3074. }
  3075. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3076. if (descriptor.set) {
  3077. descriptor.set.call(receiver, value);
  3078. } else {
  3079. if (!descriptor.writable) {
  3080. throw new TypeError('attempted to set read only private field');
  3081. }
  3082. descriptor.value = value;
  3083. }
  3084. }
  3085. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3086. if (!privateSet.has(receiver)) {
  3087. throw new TypeError('attempted to get private field on non-instance');
  3088. }
  3089. return fn;
  3090. }
  3091. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3092. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3093. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3094. }
  3095. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3096. if (!privateMap.has(receiver)) {
  3097. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3098. }
  3099. return privateMap.get(receiver);
  3100. }
  3101. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3102. if (descriptor.get) {
  3103. return descriptor.get.call(receiver);
  3104. }
  3105. return descriptor.value;
  3106. }
  3107. const Twitter_defaultTasks = {
  3108. users: [],
  3109. retweets: [],
  3110. likes: []
  3111. };
  3112. var _verifyId = new WeakMap();
  3113. var Twitter_auth = new WeakMap();
  3114. var Twitter_cache = new WeakMap();
  3115. var Twitter_initialized = new WeakMap();
  3116. var Twitter_verifyAuth = new WeakSet();
  3117. var Twitter_updateAuth = new WeakSet();
  3118. var _toggleUser = new WeakSet();
  3119. var _toggleRetweet = new WeakSet();
  3120. var Twitter_setCache = new WeakSet();
  3121. class Twitter extends social_Social {
  3122. constructor() {
  3123. var _GM_getValue;
  3124. super(...arguments);
  3125. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3126. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3127. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3128. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3129. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3130. Twitter_defineProperty(this, 'tasks', {
  3131. ...Twitter_defaultTasks
  3132. });
  3133. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || {
  3134. ...Twitter_defaultTasks
  3135. });
  3136. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3137. writable: true,
  3138. value: globalOptions.other.twitterVerifyId
  3139. });
  3140. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3141. writable: true,
  3142. value: GM_getValue('twitterAuth') || {}
  3143. });
  3144. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3145. writable: true,
  3146. value: GM_getValue('twitterCache') || {}
  3147. });
  3148. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3149. writable: true,
  3150. value: false
  3151. });
  3152. }
  3153. async init() {
  3154. try {
  3155. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3156. return true;
  3157. }
  3158. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3159. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3160. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3161. return true;
  3162. }
  3163. return false;
  3164. }
  3165. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3166. if (isVerified) {
  3167. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3168. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3169. return true;
  3170. }
  3171. GM_setValue('twitterAuth', null);
  3172. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3173. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3174. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3175. return true;
  3176. }
  3177. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3178. return false;
  3179. } catch (error) {
  3180. throwError(error, 'Twitter.init');
  3181. return false;
  3182. }
  3183. }
  3184. async userName2id(name) {
  3185. try {
  3186. const logStatus = scripts_echoLog({
  3187. type: 'gettingTwitterUserId',
  3188. text: name
  3189. });
  3190. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3191. if (userId) {
  3192. logStatus.success();
  3193. return userId;
  3194. }
  3195. const {
  3196. result,
  3197. statusText,
  3198. status,
  3199. data
  3200. } = await tools_httpRequest({
  3201. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3202. method: 'GET',
  3203. headers: {
  3204. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3205. 'content-type': 'application/json'
  3206. },
  3207. responseType: 'json',
  3208. anonymous: true
  3209. });
  3210. if (result === 'Success') {
  3211. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3212. var _response, _response$data, _response$data$user;
  3213. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3214. if (!response) {
  3215. try {
  3216. response = JSON.parse(data.responseText);
  3217. } catch (error) {
  3218. response = null;
  3219. }
  3220. }
  3221. 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);
  3222. if (userId) {
  3223. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3224. logStatus.success();
  3225. return userId;
  3226. }
  3227. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3228. return false;
  3229. }
  3230. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3231. return false;
  3232. }
  3233. logStatus.error(`${result}:${statusText}(${status})`);
  3234. return false;
  3235. } catch (error) {
  3236. throwError(error, 'Twitter.getUserId');
  3237. return false;
  3238. }
  3239. }
  3240. async toggle(_ref) {
  3241. let {
  3242. doTask = true,
  3243. userLinks = [],
  3244. retweetLinks = []
  3245. } = _ref;
  3246. try {
  3247. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3248. scripts_echoLog({
  3249. text: i18n('needInit')
  3250. });
  3251. return false;
  3252. }
  3253. const prom = [];
  3254. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3255. scripts_echoLog({
  3256. type: 'globalOptionsSkip',
  3257. text: 'twitter.users'
  3258. });
  3259. } else {
  3260. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3261. var _link$match;
  3262. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3263. });
  3264. if (realUsers.length > 0) {
  3265. for (const user of realUsers) {
  3266. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3267. name: user,
  3268. doTask: doTask
  3269. }));
  3270. await delay(1e3);
  3271. }
  3272. }
  3273. }
  3274. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3275. scripts_echoLog({
  3276. type: 'globalOptionsSkip',
  3277. text: 'twitter.retweets'
  3278. });
  3279. } else {
  3280. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3281. var _link$match2;
  3282. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3283. });
  3284. if (realRetweets.length > 0) {
  3285. for (const retweet of realRetweets) {
  3286. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3287. retweetId: retweet,
  3288. doTask: doTask
  3289. }));
  3290. await delay(1e3);
  3291. }
  3292. }
  3293. }
  3294. return Promise.all(prom).then(() => true);
  3295. } catch (error) {
  3296. throwError(error, 'Twitter.toggle');
  3297. return false;
  3298. }
  3299. }
  3300. }
  3301. async function Twitter_verifyAuth2() {
  3302. try {
  3303. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3304. name: 'verify',
  3305. doTask: true,
  3306. verify: true
  3307. });
  3308. } catch (error) {
  3309. throwError(error, 'Twitter.verifyAuth');
  3310. return false;
  3311. }
  3312. }
  3313. async function Twitter_updateAuth2() {
  3314. try {
  3315. const logStatus = scripts_echoLog({
  3316. text: i18n('updatingAuth', 'Twitter')
  3317. });
  3318. return await new Promise(resolve => {
  3319. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3320. active: true,
  3321. insert: true,
  3322. setParent: true
  3323. });
  3324. newTab.onclose = async () => {
  3325. const auth = GM_getValue('twitterAuth');
  3326. if (auth) {
  3327. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3328. logStatus.success();
  3329. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3330. } else {
  3331. logStatus.error('Error: Update twitter auth failed!');
  3332. resolve(false);
  3333. }
  3334. };
  3335. });
  3336. } catch (error) {
  3337. throwError(error, 'Twitter.updateToken');
  3338. return false;
  3339. }
  3340. }
  3341. async function _toggleUser2(_ref2) {
  3342. let {
  3343. name,
  3344. doTask = true,
  3345. verify = false
  3346. } = _ref2;
  3347. try {
  3348. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3349. scripts_echoLog({
  3350. type: 'whiteList',
  3351. text: 'Twitter.unfollowUser',
  3352. id: name
  3353. });
  3354. return true;
  3355. }
  3356. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3357. if (!userId) {
  3358. return false;
  3359. }
  3360. const logStatus = verify ? scripts_echoLog({
  3361. text: i18n('verifyingAuth', 'Twitter')
  3362. }) : scripts_echoLog({
  3363. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3364. text: name
  3365. });
  3366. const {
  3367. result,
  3368. statusText,
  3369. status,
  3370. data
  3371. } = await tools_httpRequest({
  3372. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3373. method: 'POST',
  3374. headers: {
  3375. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3376. 'Content-Type': 'application/x-www-form-urlencoded',
  3377. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3378. },
  3379. responseType: 'json',
  3380. data: $.param({
  3381. include_profile_interstitial_type: 1,
  3382. include_blocking: 1,
  3383. include_blocked_by: 1,
  3384. include_followed_by: 1,
  3385. include_want_retweets: 1,
  3386. include_mute_edge: 1,
  3387. include_can_dm: 1,
  3388. include_can_media_tag: 1,
  3389. skip_status: 1,
  3390. id: userId
  3391. })
  3392. });
  3393. if (result === 'Success') {
  3394. var _data$response, _data$response$errors, _data$response$errors2;
  3395. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3396. logStatus.success();
  3397. if (doTask && !verify) {
  3398. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3399. }
  3400. return true;
  3401. }
  3402. 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) {
  3403. logStatus.success();
  3404. return true;
  3405. }
  3406. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3407. return false;
  3408. }
  3409. logStatus.error(`${result}:${statusText}(${status})`);
  3410. return false;
  3411. } catch (error) {
  3412. throwError(error, 'Twitter.toggleUser');
  3413. return false;
  3414. }
  3415. }
  3416. async function _toggleRetweet2(_ref3) {
  3417. let {
  3418. retweetId,
  3419. doTask = true
  3420. } = _ref3;
  3421. try {
  3422. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3423. scripts_echoLog({
  3424. type: 'whiteList',
  3425. text: 'Twitter.unretweet',
  3426. id: retweetId
  3427. });
  3428. return true;
  3429. }
  3430. const logStatus = scripts_echoLog({
  3431. type: `${doTask ? '' : 'un'}retweetting`,
  3432. text: retweetId
  3433. });
  3434. const {
  3435. result,
  3436. statusText,
  3437. status,
  3438. data
  3439. } = await tools_httpRequest({
  3440. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3441. method: 'POST',
  3442. headers: {
  3443. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3444. 'Content-Type': 'application/x-www-form-urlencoded',
  3445. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3446. },
  3447. data: $.param({
  3448. tweet_mode: 'extended',
  3449. id: retweetId
  3450. }),
  3451. responseType: 'json'
  3452. });
  3453. if (result === 'Success') {
  3454. var _data$response2, _data$response2$error, _data$response2$error2;
  3455. 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) {
  3456. logStatus.success();
  3457. if (doTask) {
  3458. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3459. }
  3460. return true;
  3461. }
  3462. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3463. return false;
  3464. }
  3465. logStatus.error(`${result}:${statusText}(${status})`);
  3466. return false;
  3467. } catch (error) {
  3468. throwError(error, 'Twitter.toggleRetweet');
  3469. return false;
  3470. }
  3471. }
  3472. function Twitter_setCache2(name, id) {
  3473. try {
  3474. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3475. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3476. } catch (error) {
  3477. throwError(error, 'Twitter.setCache');
  3478. }
  3479. }
  3480. const social_Twitter = Twitter;
  3481. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3482. Vk_checkPrivateRedeclaration(obj, privateSet);
  3483. privateSet.add(obj);
  3484. }
  3485. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3486. Vk_checkPrivateRedeclaration(obj, privateMap);
  3487. privateMap.set(obj, value);
  3488. }
  3489. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3490. if (privateCollection.has(obj)) {
  3491. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3492. }
  3493. }
  3494. function Vk_defineProperty(obj, key, value) {
  3495. if (key in obj) {
  3496. Object.defineProperty(obj, key, {
  3497. value: value,
  3498. enumerable: true,
  3499. configurable: true,
  3500. writable: true
  3501. });
  3502. } else {
  3503. obj[key] = value;
  3504. }
  3505. return obj;
  3506. }
  3507. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3508. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3509. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3510. return value;
  3511. }
  3512. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3513. if (descriptor.set) {
  3514. descriptor.set.call(receiver, value);
  3515. } else {
  3516. if (!descriptor.writable) {
  3517. throw new TypeError('attempted to set read only private field');
  3518. }
  3519. descriptor.value = value;
  3520. }
  3521. }
  3522. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3523. if (!privateSet.has(receiver)) {
  3524. throw new TypeError('attempted to get private field on non-instance');
  3525. }
  3526. return fn;
  3527. }
  3528. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3529. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3530. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3531. }
  3532. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3533. if (!privateMap.has(receiver)) {
  3534. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3535. }
  3536. return privateMap.get(receiver);
  3537. }
  3538. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3539. if (descriptor.get) {
  3540. return descriptor.get.call(receiver);
  3541. }
  3542. return descriptor.value;
  3543. }
  3544. const Vk_defaultTasks = {
  3545. names: []
  3546. };
  3547. var _username = new WeakMap();
  3548. var Vk_cache = new WeakMap();
  3549. var Vk_initialized = new WeakMap();
  3550. var Vk_verifyAuth = new WeakSet();
  3551. var _toggleGroup = new WeakSet();
  3552. var _togglePublic = new WeakSet();
  3553. var _sendWall = new WeakSet();
  3554. var _deleteWall = new WeakSet();
  3555. var _getId = new WeakSet();
  3556. var _toggleVk = new WeakSet();
  3557. var Vk_setCache = new WeakSet();
  3558. class Vk extends social_Social {
  3559. constructor() {
  3560. var _GM_getValue;
  3561. super(...arguments);
  3562. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3563. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3564. Vk_classPrivateMethodInitSpec(this, _getId);
  3565. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3566. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3567. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3568. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3569. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3570. Vk_defineProperty(this, 'tasks', {
  3571. ...Vk_defaultTasks
  3572. });
  3573. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || {
  3574. ...Vk_defaultTasks
  3575. });
  3576. Vk_classPrivateFieldInitSpec(this, _username, {
  3577. writable: true,
  3578. value: ''
  3579. });
  3580. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3581. writable: true,
  3582. value: GM_getValue('vkCache') || {}
  3583. });
  3584. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3585. writable: true,
  3586. value: false
  3587. });
  3588. }
  3589. async init() {
  3590. try {
  3591. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3592. return true;
  3593. }
  3594. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3595. if (isVerified) {
  3596. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3597. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3598. return true;
  3599. }
  3600. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3601. return false;
  3602. } catch (error) {
  3603. throwError(error, 'Vk.init');
  3604. return false;
  3605. }
  3606. }
  3607. async toggle(_ref) {
  3608. let {
  3609. doTask = true,
  3610. nameLinks = []
  3611. } = _ref;
  3612. try {
  3613. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3614. scripts_echoLog({
  3615. text: i18n('needInit')
  3616. });
  3617. return false;
  3618. }
  3619. const prom = [];
  3620. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3621. scripts_echoLog({
  3622. type: 'globalOptionsSkip',
  3623. text: 'vk.names'
  3624. });
  3625. } else {
  3626. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3627. var _link$match;
  3628. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3629. });
  3630. if (realNames.length > 0) {
  3631. for (const name of realNames) {
  3632. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3633. name: name,
  3634. doTask: doTask
  3635. }));
  3636. await delay(1e3);
  3637. }
  3638. }
  3639. }
  3640. return Promise.all(prom).then(() => true);
  3641. } catch (error) {
  3642. throwError(error, 'Vk.toggle');
  3643. return false;
  3644. }
  3645. }
  3646. }
  3647. async function Vk_verifyAuth2() {
  3648. try {
  3649. const logStatus = scripts_echoLog({
  3650. text: i18n('verifyAuth', 'Vk')
  3651. });
  3652. const {
  3653. result,
  3654. statusText,
  3655. status,
  3656. data
  3657. } = await tools_httpRequest({
  3658. url: 'https://vk.com/im',
  3659. method: 'GET'
  3660. });
  3661. if (result === 'Success') {
  3662. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3663. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3664. return false;
  3665. }
  3666. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3667. var _data$responseText$ma;
  3668. 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]) || '');
  3669. logStatus.success();
  3670. return true;
  3671. }
  3672. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3673. return false;
  3674. }
  3675. logStatus.error(`${result}:${statusText}(${status})`);
  3676. return false;
  3677. } catch (error) {
  3678. throwError(error, 'Vk.verifyAuth');
  3679. return false;
  3680. }
  3681. }
  3682. async function _toggleGroup2(name, dataParam) {
  3683. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3684. try {
  3685. const logStatus = scripts_echoLog({
  3686. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3687. text: name
  3688. });
  3689. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3690. logStatus.success();
  3691. return true;
  3692. }
  3693. const reqData = {
  3694. act: doTask ? 'enter' : 'leave',
  3695. al: 1,
  3696. gid: dataParam.groupId,
  3697. hash: dataParam.groupHash
  3698. };
  3699. if (doTask) {
  3700. reqData.context = '_';
  3701. }
  3702. const {
  3703. result,
  3704. statusText,
  3705. status,
  3706. data
  3707. } = await tools_httpRequest({
  3708. url: 'https://vk.com/al_groups.php',
  3709. method: 'POST',
  3710. headers: {
  3711. origin: 'https://vk.com',
  3712. referer: `https://vk.com/${name}`,
  3713. 'content-type': 'application/x-www-form-urlencoded'
  3714. },
  3715. data: $.param(reqData)
  3716. });
  3717. if (result === 'Success') {
  3718. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3719. logStatus.success();
  3720. if (doTask) {
  3721. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3722. }
  3723. return true;
  3724. }
  3725. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3726. return false;
  3727. }
  3728. logStatus.error(`${result}:${statusText}(${status})`);
  3729. return false;
  3730. } catch (error) {
  3731. throwError(error, 'Vk.toggleGroup');
  3732. return false;
  3733. }
  3734. }
  3735. async function _togglePublic2(name, dataParam) {
  3736. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3737. try {
  3738. const logStatus = scripts_echoLog({
  3739. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3740. text: name
  3741. });
  3742. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3743. logStatus.success();
  3744. return true;
  3745. }
  3746. const {
  3747. result,
  3748. statusText,
  3749. status,
  3750. data
  3751. } = await tools_httpRequest({
  3752. url: 'https://vk.com/al_public.php',
  3753. method: 'POST',
  3754. headers: {
  3755. origin: 'https://vk.com',
  3756. referer: `https://vk.com/${name}`,
  3757. 'content-type': 'application/x-www-form-urlencoded'
  3758. },
  3759. data: $.param({
  3760. act: doTask ? 'a_enter' : 'a_leave',
  3761. al: 1,
  3762. pid: dataParam.publicPid,
  3763. hash: dataParam.publicHash
  3764. })
  3765. });
  3766. if (result === 'Success') {
  3767. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3768. logStatus.success();
  3769. if (doTask) {
  3770. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3771. }
  3772. return true;
  3773. }
  3774. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3775. return false;
  3776. }
  3777. logStatus.error(`${result}:${statusText}(${status})`);
  3778. return false;
  3779. } catch (error) {
  3780. throwError(error, 'Vk.togglePublic');
  3781. return false;
  3782. }
  3783. }
  3784. async function _sendWall2(name) {
  3785. try {
  3786. const logStatus = scripts_echoLog({
  3787. type: 'sendingVkWall',
  3788. text: name
  3789. });
  3790. const {
  3791. result,
  3792. statusText,
  3793. status,
  3794. data
  3795. } = await tools_httpRequest({
  3796. url: 'https://vk.com/like.php',
  3797. method: 'POST',
  3798. headers: {
  3799. origin: 'https://vk.com',
  3800. referer: `https://vk.com/${name}`,
  3801. 'content-type': 'application/x-www-form-urlencoded'
  3802. },
  3803. data: $.param({
  3804. act: 'publish_box',
  3805. al: 1,
  3806. object: name
  3807. })
  3808. });
  3809. if (result === 'Success') {
  3810. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3811. var _data$responseText$ma2;
  3812. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3813. if (hash) {
  3814. const {
  3815. result: resultR,
  3816. statusText: statusTextR,
  3817. status: statusR,
  3818. data: dataR
  3819. } = await tools_httpRequest({
  3820. url: 'https://vk.com/like.php',
  3821. method: 'POST',
  3822. headers: {
  3823. origin: 'https://vk.com',
  3824. referer: `https://vk.com/${name}`,
  3825. 'content-type': 'application/x-www-form-urlencoded'
  3826. },
  3827. data: $.param({
  3828. Message: '',
  3829. act: 'a_do_publish',
  3830. al: 1,
  3831. close_comments: 0,
  3832. friends_only: 0,
  3833. from: 'box',
  3834. hash: hash,
  3835. list: '',
  3836. mark_as_ads: 0,
  3837. mute_notifications: 0,
  3838. object: name,
  3839. ret_data: 1,
  3840. to: 0
  3841. })
  3842. });
  3843. if (resultR === 'Success') {
  3844. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3845. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3846. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3847. 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) {
  3848. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3849. logStatus.success();
  3850. 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);
  3851. 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);
  3852. if (postId && ownerId) {
  3853. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3854. }
  3855. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3856. return true;
  3857. }
  3858. }
  3859. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3860. return false;
  3861. }
  3862. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3863. return false;
  3864. }
  3865. logStatus.error('Error: Get "hash" failed');
  3866. return false;
  3867. }
  3868. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3869. return false;
  3870. }
  3871. logStatus.error(`${result}:${statusText}(${status})`);
  3872. return false;
  3873. } catch (error) {
  3874. throwError(error, 'Vk.sendWall');
  3875. return false;
  3876. }
  3877. }
  3878. async function _deleteWall2(name, dataParams) {
  3879. try {
  3880. const logStatus = scripts_echoLog({
  3881. type: 'deletingVkWall',
  3882. text: name
  3883. });
  3884. const {
  3885. result,
  3886. statusText,
  3887. status,
  3888. data
  3889. } = await tools_httpRequest({
  3890. url: 'https://vk.com/al_wall.php?act=delete',
  3891. method: 'POST',
  3892. headers: {
  3893. origin: 'https://vk.com',
  3894. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3895. 'content-type': 'application/x-www-form-urlencoded'
  3896. },
  3897. data: $.param({
  3898. act: 'delete',
  3899. al: 1,
  3900. confirm: 0,
  3901. from: 'wkview',
  3902. hash: dataParams.wallHash,
  3903. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3904. })
  3905. });
  3906. if (result === 'Success') {
  3907. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3908. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3909. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3910. 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]) {
  3911. logStatus.success();
  3912. return true;
  3913. }
  3914. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3915. return false;
  3916. }
  3917. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3918. return false;
  3919. }
  3920. logStatus.error(`${result}:${statusText}(${status})`);
  3921. return false;
  3922. } catch (error) {
  3923. throwError(error, 'Vk.deleteWall');
  3924. return false;
  3925. }
  3926. }
  3927. async function _getId2(name, doTask) {
  3928. try {
  3929. let url = `https://vk.com/${name}`;
  3930. if (/^wall-/.test(name)) {
  3931. if (doTask) {
  3932. return {
  3933. type: 'sendWall'
  3934. };
  3935. }
  3936. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3937. return {
  3938. type: 'unSupport'
  3939. };
  3940. }
  3941. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3942. }
  3943. const logStatus = scripts_echoLog({
  3944. type: 'gettingVkId',
  3945. text: name
  3946. });
  3947. const {
  3948. result,
  3949. statusText,
  3950. status,
  3951. data
  3952. } = await tools_httpRequest({
  3953. url: url,
  3954. method: 'GET'
  3955. });
  3956. if (result === 'Success') {
  3957. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3958. var _data$responseText$ma3, _data$responseText$ma4;
  3959. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3960. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3961. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3962. const publicJoined = !data.responseText.includes('Public.subscribe');
  3963. if (groupAct && groupId && groupHash) {
  3964. logStatus.success();
  3965. return {
  3966. groupAct: groupAct,
  3967. groupId: groupId,
  3968. groupHash: groupHash,
  3969. type: 'group'
  3970. };
  3971. } else if (publicHash && publicPid) {
  3972. logStatus.success();
  3973. return {
  3974. publicHash: publicHash,
  3975. publicPid: publicPid,
  3976. publicJoined: publicJoined,
  3977. type: 'public'
  3978. };
  3979. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3980. var _data$responseText$ma5;
  3981. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3982. if (wallHash) {
  3983. logStatus.success();
  3984. return {
  3985. type: 'deleteWall',
  3986. wallHash: wallHash
  3987. };
  3988. }
  3989. } else if (name.includes('wall') && doTask) {
  3990. logStatus.success();
  3991. return {
  3992. type: 'sendWall'
  3993. };
  3994. }
  3995. logStatus.error('Error: Parameters not found!');
  3996. return false;
  3997. }
  3998. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3999. return false;
  4000. }
  4001. logStatus.error(`${result}:${statusText}(${status})`);
  4002. return false;
  4003. } catch (error) {
  4004. throwError(error, 'Vk.getId');
  4005. return false;
  4006. }
  4007. }
  4008. async function _toggleVk2(_ref2) {
  4009. let {
  4010. name,
  4011. doTask = true
  4012. } = _ref2;
  4013. try {
  4014. if (!doTask && this.whiteList.names.includes(name)) {
  4015. scripts_echoLog({
  4016. type: 'whiteList',
  4017. text: 'Vk.undoTask',
  4018. id: name
  4019. });
  4020. return true;
  4021. }
  4022. const formatName = name.replace(/\/$/, '');
  4023. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4024. if (!data) {
  4025. return false;
  4026. }
  4027. switch (data.type) {
  4028. case 'group':
  4029. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4030.  
  4031. case 'public':
  4032. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4033.  
  4034. case 'sendWall':
  4035. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4036.  
  4037. case 'deleteWall':
  4038. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4039.  
  4040. default:
  4041. return false;
  4042. }
  4043. } catch (error) {
  4044. throwError(error, 'Vk.toggleVk');
  4045. return false;
  4046. }
  4047. }
  4048. function Vk_setCache2(name, postId) {
  4049. try {
  4050. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4051. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4052. } catch (error) {
  4053. throwError(error, 'Vk.setCache');
  4054. }
  4055. }
  4056. const social_Vk = Vk;
  4057. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4058. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4059. privateSet.add(obj);
  4060. }
  4061. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4062. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4063. privateMap.set(obj, value);
  4064. }
  4065. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4066. if (privateCollection.has(obj)) {
  4067. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4068. }
  4069. }
  4070. function Youtube_defineProperty(obj, key, value) {
  4071. if (key in obj) {
  4072. Object.defineProperty(obj, key, {
  4073. value: value,
  4074. enumerable: true,
  4075. configurable: true,
  4076. writable: true
  4077. });
  4078. } else {
  4079. obj[key] = value;
  4080. }
  4081. return obj;
  4082. }
  4083. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4084. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4085. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4086. return value;
  4087. }
  4088. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4089. if (descriptor.set) {
  4090. descriptor.set.call(receiver, value);
  4091. } else {
  4092. if (!descriptor.writable) {
  4093. throw new TypeError('attempted to set read only private field');
  4094. }
  4095. descriptor.value = value;
  4096. }
  4097. }
  4098. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4099. if (!privateSet.has(receiver)) {
  4100. throw new TypeError('attempted to get private field on non-instance');
  4101. }
  4102. return fn;
  4103. }
  4104. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4105. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4106. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4107. }
  4108. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4109. if (!privateMap.has(receiver)) {
  4110. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4111. }
  4112. return privateMap.get(receiver);
  4113. }
  4114. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4115. if (descriptor.get) {
  4116. return descriptor.get.call(receiver);
  4117. }
  4118. return descriptor.value;
  4119. }
  4120. const Youtube_defaultTasks = {
  4121. channels: [],
  4122. likes: []
  4123. };
  4124. const getInfo = async function(link, type) {
  4125. try {
  4126. const logStatus = scripts_echoLog({
  4127. text: i18n('gettingYtbToken')
  4128. });
  4129. const {
  4130. result,
  4131. statusText,
  4132. status,
  4133. data
  4134. } = await tools_httpRequest({
  4135. url: link,
  4136. method: 'GET'
  4137. });
  4138. if (result === 'Success') {
  4139. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4140. var _data$responseText$ma, _ref;
  4141. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4142. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4143. return {
  4144. needLogin: true
  4145. };
  4146. }
  4147. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4148. 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]) || '{}';
  4149. const {
  4150. client,
  4151. request
  4152. } = JSON.parse(context);
  4153. if (apiKey && client && request) {
  4154. client.hl = 'en';
  4155. if (type === 'channel') {
  4156. var _data$responseText$ma2;
  4157. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4158. if (channelId) {
  4159. logStatus.success();
  4160. return {
  4161. params: {
  4162. apiKey: apiKey,
  4163. client: client,
  4164. request: request,
  4165. channelId: channelId
  4166. }
  4167. };
  4168. }
  4169. logStatus.error('Error: Get "channelId" failed!');
  4170. return {};
  4171. } else if (type === 'likeVideo') {
  4172. var _data$responseText$ma3, _data$responseText$ma4;
  4173. 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];
  4174. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4175. if (videoId) {
  4176. logStatus.success();
  4177. return {
  4178. params: {
  4179. apiKey: apiKey,
  4180. client: client,
  4181. request: request,
  4182. videoId: videoId,
  4183. likeParams: likeParams
  4184. }
  4185. };
  4186. }
  4187. logStatus.error('Error: Get "videoId" failed!');
  4188. return {};
  4189. }
  4190. logStatus.error('Error: Unknown type');
  4191. return {};
  4192. }
  4193. logStatus.error('Error: Parameter "apiKey" not found!');
  4194. return {};
  4195. }
  4196. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4197. return {};
  4198. }
  4199. logStatus.error(`${result}:${statusText}(${status})`);
  4200. return {};
  4201. } catch (error) {
  4202. throwError(error, 'Youtube.getInfo');
  4203. return {};
  4204. }
  4205. };
  4206. var Youtube_auth = new WeakMap();
  4207. var Youtube_initialized = new WeakMap();
  4208. var _verifyChannel = new WeakMap();
  4209. var Youtube_verifyAuth = new WeakSet();
  4210. var Youtube_updateAuth = new WeakSet();
  4211. var _getInfo = new WeakSet();
  4212. var Youtube_toggleChannel = new WeakSet();
  4213. var _toggleLikeVideo = new WeakSet();
  4214. class Youtube extends social_Social {
  4215. constructor() {
  4216. var _GM_getValue;
  4217. super(...arguments);
  4218. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4219. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4220. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4221. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4222. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4223. Youtube_defineProperty(this, 'tasks', {
  4224. ...Youtube_defaultTasks
  4225. });
  4226. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || {
  4227. ...Youtube_defaultTasks
  4228. });
  4229. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4230. writable: true,
  4231. value: GM_getValue('youtubeAuth') || {}
  4232. });
  4233. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4234. writable: true,
  4235. value: false
  4236. });
  4237. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4238. writable: true,
  4239. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4240. });
  4241. }
  4242. async init() {
  4243. try {
  4244. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4245. return true;
  4246. }
  4247. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4248. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4249. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4250. return true;
  4251. }
  4252. return false;
  4253. }
  4254. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4255. if (isVerified) {
  4256. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4257. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4258. return true;
  4259. }
  4260. GM_setValue('youtubeAuth', null);
  4261. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4262. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4263. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4264. return true;
  4265. }
  4266. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4267. return false;
  4268. } catch (error) {
  4269. throwError(error, 'Youtube.init');
  4270. return false;
  4271. }
  4272. }
  4273. async toggle(_ref2) {
  4274. let {
  4275. doTask = true,
  4276. channelLinks = [],
  4277. videoLinks = []
  4278. } = _ref2;
  4279. try {
  4280. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4281. scripts_echoLog({
  4282. text: i18n('needInit')
  4283. });
  4284. return false;
  4285. }
  4286. const prom = [];
  4287. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4288. scripts_echoLog({
  4289. type: 'globalOptionsSkip',
  4290. text: 'youtube.channels'
  4291. });
  4292. } else {
  4293. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4294. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4295. var _link$match;
  4296. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4297. }
  4298. return link;
  4299. });
  4300. if (realChannels.length > 0) {
  4301. for (const channel of realChannels) {
  4302. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4303. link: channel,
  4304. doTask: doTask
  4305. }));
  4306. await delay(1e3);
  4307. }
  4308. }
  4309. }
  4310. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4311. scripts_echoLog({
  4312. type: 'globalOptionsSkip',
  4313. text: 'youtube.likes'
  4314. });
  4315. } else {
  4316. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4317. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4318. var _link$match2;
  4319. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4320. }
  4321. return link;
  4322. });
  4323. if (realLikes.length > 0) {
  4324. for (const video of realLikes) {
  4325. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4326. link: video,
  4327. doTask: doTask
  4328. }));
  4329. await delay(1e3);
  4330. }
  4331. }
  4332. }
  4333. return Promise.all(prom).then(() => true);
  4334. } catch (error) {
  4335. throwError(error, 'Youtube.toggle');
  4336. return false;
  4337. }
  4338. }
  4339. }
  4340. async function Youtube_verifyAuth2() {
  4341. try {
  4342. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4343. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4344. doTask: true,
  4345. verify: true
  4346. });
  4347. } catch (error) {
  4348. throwError(error, 'Youtube.verifyAuth');
  4349. return false;
  4350. }
  4351. }
  4352. async function Youtube_updateAuth2() {
  4353. try {
  4354. const logStatus = scripts_echoLog({
  4355. text: i18n('updatingAuth', 'Youtube')
  4356. });
  4357. return await new Promise(resolve => {
  4358. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4359. active: true,
  4360. insert: true,
  4361. setParent: true
  4362. });
  4363. newTab.onclose = async () => {
  4364. const auth = GM_getValue('youtubeAuth');
  4365. if (auth) {
  4366. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4367. logStatus.success();
  4368. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4369. resolve(result);
  4370. });
  4371. } else {
  4372. logStatus.error('Error: Update youtube auth failed!');
  4373. resolve(false);
  4374. }
  4375. };
  4376. });
  4377. } catch (error) {
  4378. throwError(error, 'Discord.updateAuth');
  4379. return false;
  4380. }
  4381. }
  4382. function _getInfo2(link, type) {
  4383. return getInfo(link, type);
  4384. }
  4385. async function Youtube_toggleChannel2(_ref3) {
  4386. let {
  4387. link,
  4388. doTask = true,
  4389. verify = false
  4390. } = _ref3;
  4391. try {
  4392. const {
  4393. params,
  4394. needLogin
  4395. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4396. const {
  4397. apiKey,
  4398. client,
  4399. request,
  4400. channelId
  4401. } = params || {};
  4402. if (needLogin) {
  4403. scripts_echoLog({
  4404. html: i18n('loginYtb')
  4405. });
  4406. return false;
  4407. }
  4408. if (!(apiKey && client && request && channelId)) {
  4409. scripts_echoLog({
  4410. text: '"getYtbToken" failed'
  4411. });
  4412. return false;
  4413. }
  4414. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4415. scripts_echoLog({
  4416. type: 'whiteList',
  4417. text: 'Youtube.unfollowChannel',
  4418. id: channelId
  4419. });
  4420. return true;
  4421. }
  4422. const logStatus = verify ? scripts_echoLog({
  4423. text: i18n('verifyingAuth', 'Youtube')
  4424. }) : scripts_echoLog({
  4425. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4426. text: channelId
  4427. });
  4428. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4429. const {
  4430. result,
  4431. statusText,
  4432. status,
  4433. data
  4434. } = await tools_httpRequest({
  4435. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4436. method: 'POST',
  4437. headers: {
  4438. origin: 'https://www.youtube.com',
  4439. referer: `https://www.youtube.com/channel/${channelId}`,
  4440. 'content-type': 'application/json',
  4441. 'x-goog-authuser': '0',
  4442. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4443. 'x-origin': 'https://www.youtube.com',
  4444. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4445. },
  4446. data: JSON.stringify({
  4447. context: {
  4448. client: client,
  4449. request: {
  4450. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4451. internalExperimentFlags: [],
  4452. consistencyTokenJars: []
  4453. },
  4454. user: {}
  4455. },
  4456. channelIds: [ channelId ],
  4457. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4458. })
  4459. });
  4460. if (result === 'Success') {
  4461. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4462. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4463. logStatus.success();
  4464. if (doTask && !verify) {
  4465. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4466. }
  4467. return true;
  4468. }
  4469. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4470. return false;
  4471. }
  4472. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4473. return false;
  4474. }
  4475. logStatus.error(`${result}:${statusText}(${status})`);
  4476. return false;
  4477. } catch (error) {
  4478. throwError(error, 'Youtube.toggleChannel');
  4479. return false;
  4480. }
  4481. }
  4482. async function _toggleLikeVideo2(_ref4) {
  4483. let {
  4484. link,
  4485. doTask = true
  4486. } = _ref4;
  4487. try {
  4488. const {
  4489. params,
  4490. needLogin
  4491. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4492. const {
  4493. apiKey,
  4494. client,
  4495. request,
  4496. videoId,
  4497. likeParams
  4498. } = params || {};
  4499. if (needLogin) {
  4500. scripts_echoLog({
  4501. html: `${i18n('loginYtb')}`
  4502. });
  4503. return false;
  4504. }
  4505. if (!(apiKey && client && request && videoId && likeParams)) {
  4506. scripts_echoLog({
  4507. text: '"getYtbToken" failed'
  4508. });
  4509. return false;
  4510. }
  4511. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4512. scripts_echoLog({
  4513. type: 'whiteList',
  4514. text: 'Youtube.unlikeVideo',
  4515. id: videoId
  4516. });
  4517. return true;
  4518. }
  4519. const logStatus = scripts_echoLog({
  4520. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4521. text: videoId
  4522. });
  4523. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4524. const likeVideoData = {
  4525. context: {
  4526. client: client,
  4527. request: {
  4528. sessionId: request.sessionId,
  4529. internalExperimentFlags: [],
  4530. consistencyTokenJars: []
  4531. },
  4532. user: {}
  4533. },
  4534. target: {
  4535. videoId: videoId
  4536. }
  4537. };
  4538. if (doTask) {
  4539. if (likeParams) {
  4540. likeVideoData.params = likeParams;
  4541. } else {
  4542. logStatus.error('Empty likeParams');
  4543. return false;
  4544. }
  4545. }
  4546. const {
  4547. result,
  4548. statusText,
  4549. status,
  4550. data
  4551. } = await tools_httpRequest({
  4552. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4553. method: 'POST',
  4554. headers: {
  4555. origin: 'https://www.youtube.com',
  4556. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4557. 'content-type': 'application/json',
  4558. 'x-goog-authuser': '0',
  4559. 'x-goog-visitor-id': client.visitorData,
  4560. 'x-origin': 'https://www.youtube.com',
  4561. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4562. },
  4563. data: JSON.stringify(likeVideoData)
  4564. });
  4565. if (result === 'Success') {
  4566. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4567. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4568. logStatus.success();
  4569. if (doTask) {
  4570. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4571. }
  4572. return true;
  4573. }
  4574. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4575. return false;
  4576. }
  4577. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4578. return false;
  4579. }
  4580. logStatus.error(`${result}:${statusText}(${status})`);
  4581. return false;
  4582. } catch (error) {
  4583. throwError(error, 'Youtube.toggleLikeVideo');
  4584. return false;
  4585. }
  4586. }
  4587. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4588. Steam_checkPrivateRedeclaration(obj, privateSet);
  4589. privateSet.add(obj);
  4590. }
  4591. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4592. Steam_checkPrivateRedeclaration(obj, privateMap);
  4593. privateMap.set(obj, value);
  4594. }
  4595. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4596. if (privateCollection.has(obj)) {
  4597. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4598. }
  4599. }
  4600. function Steam_defineProperty(obj, key, value) {
  4601. if (key in obj) {
  4602. Object.defineProperty(obj, key, {
  4603. value: value,
  4604. enumerable: true,
  4605. configurable: true,
  4606. writable: true
  4607. });
  4608. } else {
  4609. obj[key] = value;
  4610. }
  4611. return obj;
  4612. }
  4613. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4614. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4615. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4616. return value;
  4617. }
  4618. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4619. if (descriptor.set) {
  4620. descriptor.set.call(receiver, value);
  4621. } else {
  4622. if (!descriptor.writable) {
  4623. throw new TypeError('attempted to set read only private field');
  4624. }
  4625. descriptor.value = value;
  4626. }
  4627. }
  4628. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4629. if (!privateSet.has(receiver)) {
  4630. throw new TypeError('attempted to get private field on non-instance');
  4631. }
  4632. return fn;
  4633. }
  4634. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4635. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4636. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4637. }
  4638. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4639. if (!privateMap.has(receiver)) {
  4640. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4641. }
  4642. return privateMap.get(receiver);
  4643. }
  4644. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4645. if (descriptor.get) {
  4646. return descriptor.get.call(receiver);
  4647. }
  4648. return descriptor.value;
  4649. }
  4650. const Steam_defaultTasks = {
  4651. groups: [],
  4652. wishlists: [],
  4653. follows: [],
  4654. forums: [],
  4655. workshops: [],
  4656. workshopVotes: [],
  4657. curators: [],
  4658. curatorLikes: [],
  4659. announcements: []
  4660. };
  4661. var Steam_cache = new WeakMap();
  4662. var Steam_auth = new WeakMap();
  4663. var Steam_initialized = new WeakMap();
  4664. var _area = new WeakMap();
  4665. var _updateStoreAuth = new WeakSet();
  4666. var _updateCommunityAuth = new WeakSet();
  4667. var _getAreaInfo = new WeakSet();
  4668. var _changeArea = new WeakSet();
  4669. var _joinGroup = new WeakSet();
  4670. var _leaveGroup = new WeakSet();
  4671. var _getGroupId = new WeakSet();
  4672. var _addToWishlist = new WeakSet();
  4673. var _removeFromWishlist = new WeakSet();
  4674. var _toggleFollowGame = new WeakSet();
  4675. var _isFollowedGame = new WeakSet();
  4676. var _toggleForum = new WeakSet();
  4677. var _getForumId = new WeakSet();
  4678. var _toggleFavoriteWorkshop = new WeakSet();
  4679. var _getWorkshopAppId = new WeakSet();
  4680. var _voteUpWorkshop = new WeakSet();
  4681. var _toggleCurator = new WeakSet();
  4682. var _toggleCuratorLike = new WeakSet();
  4683. var _getAnnouncementParams = new WeakSet();
  4684. var _likeAnnouncement = new WeakSet();
  4685. var Steam_setCache = new WeakSet();
  4686. class Steam extends social_Social {
  4687. constructor() {
  4688. var _GM_getValue;
  4689. super(...arguments);
  4690. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4691. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4692. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4693. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4694. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4695. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4696. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4697. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4698. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4699. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4700. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4701. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4702. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4703. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4704. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4705. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4706. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4707. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4708. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4709. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4710. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4711. Steam_defineProperty(this, 'tasks', {
  4712. ...Steam_defaultTasks
  4713. });
  4714. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || {
  4715. ...Steam_defaultTasks
  4716. });
  4717. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4718. writable: true,
  4719. value: GM_getValue('steamCache') || {
  4720. group: {},
  4721. forum: {},
  4722. workshop: {},
  4723. curator: {}
  4724. }
  4725. });
  4726. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4727. writable: true,
  4728. value: {}
  4729. });
  4730. Steam_classPrivateFieldInitSpec(this, Steam_initialized, {
  4731. writable: true,
  4732. value: false
  4733. });
  4734. Steam_classPrivateFieldInitSpec(this, _area, {
  4735. writable: true,
  4736. value: 'CN'
  4737. });
  4738. }
  4739. async init() {
  4740. try {
  4741. if (Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4742. return true;
  4743. }
  4744. const isVerified = await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this) && await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this);
  4745. if (isVerified) {
  4746. Steam_classPrivateFieldSet(this, Steam_initialized, true);
  4747. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4748. return true;
  4749. }
  4750. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4751. return false;
  4752. } catch (error) {
  4753. throwError(error, 'Steam.init');
  4754. return false;
  4755. }
  4756. }
  4757. async getCuratorId(path, name) {
  4758. try {
  4759. const logStatus = scripts_echoLog({
  4760. type: 'gettingCuratorId',
  4761. text: `${path}/${name}`
  4762. });
  4763. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4764. if (curatorId) {
  4765. logStatus.success();
  4766. return curatorId;
  4767. }
  4768. const {
  4769. result,
  4770. statusText,
  4771. status,
  4772. data
  4773. } = await tools_httpRequest({
  4774. url: `https://store.steampowered.com/${path}/${name}`,
  4775. method: 'GET',
  4776. headers: {
  4777. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4778. }
  4779. });
  4780. if (result === 'Success') {
  4781. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4782. var _data$responseText$ma;
  4783. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4784. if (curatorId) {
  4785. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4786. logStatus.success();
  4787. return curatorId;
  4788. }
  4789. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4790. return false;
  4791. }
  4792. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4793. return false;
  4794. }
  4795. logStatus.error(`${result}:${statusText}(${status})`);
  4796. return false;
  4797. } catch (error) {
  4798. throwError(error, 'Steam.getCuratorID');
  4799. return false;
  4800. }
  4801. }
  4802. async toggle(_ref) {
  4803. let {
  4804. doTask = true,
  4805. groupLinks = [],
  4806. wishlistLinks = [],
  4807. followLinks = [],
  4808. forumLinks = [],
  4809. workshopLinks = [],
  4810. workshopVoteLinks = [],
  4811. curatorLinks = [],
  4812. curatorLikeLinks = [],
  4813. announcementLinks = []
  4814. } = _ref;
  4815. try {
  4816. if (!Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4817. scripts_echoLog({
  4818. text: i18n('needInit')
  4819. });
  4820. return false;
  4821. }
  4822. const prom = [];
  4823. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4824. scripts_echoLog({
  4825. type: 'globalOptionsSkip',
  4826. text: 'steam.groups'
  4827. });
  4828. } else {
  4829. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4830. var _link$match;
  4831. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4832. });
  4833. if (realGroups.length > 0) {
  4834. for (const group of realGroups) {
  4835. if (doTask) {
  4836. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4837. } else {
  4838. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4839. }
  4840. await delay(1e3);
  4841. }
  4842. }
  4843. }
  4844. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4845. scripts_echoLog({
  4846. type: 'globalOptionsSkip',
  4847. text: 'steam.wishlists'
  4848. });
  4849. } else {
  4850. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4851. var _link$match2;
  4852. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4853. });
  4854. if (realWishlists.length > 0) {
  4855. for (const game of realWishlists) {
  4856. if (doTask) {
  4857. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4858. } else {
  4859. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4860. }
  4861. await delay(1e3);
  4862. }
  4863. }
  4864. }
  4865. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4866. scripts_echoLog({
  4867. type: 'globalOptionsSkip',
  4868. text: 'steam.follows'
  4869. });
  4870. } else {
  4871. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4872. var _link$match3;
  4873. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4874. });
  4875. if (realFollows.length > 0) {
  4876. for (const game of realFollows) {
  4877. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4878. await delay(1e3);
  4879. }
  4880. }
  4881. }
  4882. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4883. scripts_echoLog({
  4884. type: 'globalOptionsSkip',
  4885. text: 'steam.forums'
  4886. });
  4887. } else {
  4888. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4889. var _link$match4;
  4890. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4891. });
  4892. if (realForums.length > 0) {
  4893. for (const forum of realForums) {
  4894. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4895. await delay(1e3);
  4896. }
  4897. }
  4898. }
  4899. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4900. scripts_echoLog({
  4901. type: 'globalOptionsSkip',
  4902. text: 'steam.workshops'
  4903. });
  4904. } else {
  4905. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4906. var _link$match5;
  4907. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4908. });
  4909. if (realWorkshops.length > 0) {
  4910. for (const workshop of realWorkshops) {
  4911. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4912. await delay(1e3);
  4913. }
  4914. }
  4915. }
  4916. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4917. scripts_echoLog({
  4918. type: 'globalOptionsSkip',
  4919. text: 'steam.workshopVotes'
  4920. });
  4921. } else {
  4922. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4923. var _link$match6;
  4924. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4925. });
  4926. if (doTask && realworkshopVotes.length > 0) {
  4927. for (const workshop of realworkshopVotes) {
  4928. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4929. await delay(1e3);
  4930. }
  4931. }
  4932. }
  4933. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4934. scripts_echoLog({
  4935. type: 'globalOptionsSkip',
  4936. text: 'steam.curators'
  4937. });
  4938. } else {
  4939. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4940. var _link$match7;
  4941. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4942. });
  4943. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4944. var _link$match8;
  4945. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4946. });
  4947. if (realCurators.length > 0) {
  4948. for (const curator of realCurators) {
  4949. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4950. await delay(1e3);
  4951. }
  4952. }
  4953. if (realCuratorLikes.length > 0) {
  4954. for (const curatorLike of realCuratorLikes) {
  4955. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4956. await delay(1e3);
  4957. }
  4958. }
  4959. }
  4960. if (doTask && !globalOptions.doTask.steam.announcements) {
  4961. scripts_echoLog({
  4962. type: 'globalOptionsSkip',
  4963. text: 'steam.announcements'
  4964. });
  4965. } else {
  4966. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  4967. var _link$match10;
  4968. if (link.includes('store.steampowered.com')) {
  4969. var _link$match9;
  4970. 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('/');
  4971. }
  4972. 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('/');
  4973. });
  4974. if (doTask && realAnnouncements.length > 0) {
  4975. for (const id of realAnnouncements) {
  4976. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  4977. await delay(1e3);
  4978. }
  4979. }
  4980. }
  4981. return Promise.all(prom).then(async () => {
  4982. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  4983. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  4984. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  4985. }
  4986. return true;
  4987. });
  4988. } catch (error) {
  4989. throwError(error, 'Steam.toggle');
  4990. return false;
  4991. }
  4992. }
  4993. }
  4994. async function _updateStoreAuth2() {
  4995. try {
  4996. const logStatus = scripts_echoLog({
  4997. text: i18n('updatingAuth', i18n('steamStore'))
  4998. });
  4999. const {
  5000. result,
  5001. statusText,
  5002. status,
  5003. data
  5004. } = await tools_httpRequest({
  5005. url: 'https://store.steampowered.com/stats/',
  5006. method: 'GET'
  5007. });
  5008. if (result === 'Success') {
  5009. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5010. var _data$responseText$ma2;
  5011. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5012. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5013. return false;
  5014. }
  5015. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5016. if (storeSessionID) {
  5017. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5018. logStatus.success();
  5019. return true;
  5020. }
  5021. logStatus.error('Error: Get "sessionID" failed');
  5022. return false;
  5023. }
  5024. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5025. return false;
  5026. }
  5027. logStatus.error(`${result}:${statusText}(${status})`);
  5028. return false;
  5029. } catch (error) {
  5030. throwError(error, 'Steam.updateStoreAuth');
  5031. return false;
  5032. }
  5033. }
  5034. async function _updateCommunityAuth2() {
  5035. try {
  5036. const logStatus = scripts_echoLog({
  5037. text: i18n('updatingAuth', i18n('steamCommunity'))
  5038. });
  5039. const {
  5040. result,
  5041. statusText,
  5042. status,
  5043. data
  5044. } = await tools_httpRequest({
  5045. url: 'https://steamcommunity.com/my',
  5046. method: 'GET'
  5047. });
  5048. if (result === 'Success') {
  5049. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5050. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5051. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5052. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5053. return false;
  5054. }
  5055. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5056. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5057. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5058. if (steam64Id) {
  5059. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5060. }
  5061. if (userName) {
  5062. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5063. }
  5064. if (communitySessionID) {
  5065. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5066. logStatus.success();
  5067. return true;
  5068. }
  5069. logStatus.error('Error: Get "sessionID" failed');
  5070. return false;
  5071. }
  5072. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5073. return false;
  5074. }
  5075. logStatus.error(`${result}:${statusText}(${status})`);
  5076. return false;
  5077. } catch (error) {
  5078. throwError(error, 'Steam.updateCommunityAuth');
  5079. return false;
  5080. }
  5081. }
  5082. async function _getAreaInfo2() {
  5083. try {
  5084. const logStatus = scripts_echoLog({
  5085. text: i18n('gettingAreaInfo')
  5086. });
  5087. const {
  5088. result,
  5089. statusText,
  5090. status,
  5091. data
  5092. } = await tools_httpRequest({
  5093. url: 'https://store.steampowered.com/cart/',
  5094. method: 'GET'
  5095. });
  5096. if (result === 'Success') {
  5097. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5098. var _data$responseText$ma6;
  5099. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5100. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5101. if (currentArea && areas.length > 0) {
  5102. Steam_classPrivateFieldSet(this, _area, currentArea);
  5103. logStatus.success();
  5104. return {
  5105. currentArea: currentArea,
  5106. areas: areas
  5107. };
  5108. }
  5109. logStatus.error('Error: get country info filed');
  5110. return {};
  5111. }
  5112. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5113. return {};
  5114. }
  5115. logStatus.error(`${result}:${statusText}(${status})`);
  5116. return {};
  5117. } catch (error) {
  5118. throwError(error, 'Steam.getAreaInfo');
  5119. return {};
  5120. }
  5121. }
  5122. async function _changeArea2(area) {
  5123. try {
  5124. let aimedArea = area;
  5125. if (!aimedArea) {
  5126. const {
  5127. currentArea,
  5128. areas
  5129. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5130. if (!currentArea || !areas) {
  5131. return false;
  5132. }
  5133. if (currentArea !== 'CN') {
  5134. scripts_echoLog({
  5135. text: 'notNeededChangeArea'
  5136. });
  5137. return 'skip';
  5138. }
  5139. const anotherArea = areas.filter(area => area && area !== 'CN');
  5140. if (!anotherArea || anotherArea.length === 0) {
  5141. scripts_echoLog({
  5142. text: 'noAnotherArea'
  5143. });
  5144. return false;
  5145. }
  5146. [ aimedArea ] = anotherArea;
  5147. }
  5148. const logStatus = scripts_echoLog({
  5149. text: i18n('changingArea', aimedArea)
  5150. });
  5151. const {
  5152. result,
  5153. statusText,
  5154. status,
  5155. data
  5156. } = await tools_httpRequest({
  5157. url: 'https://store.steampowered.com/account/setcountry',
  5158. method: 'POST',
  5159. headers: {
  5160. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5161. },
  5162. data: $.param({
  5163. cc: aimedArea,
  5164. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5165. })
  5166. });
  5167. if (result === 'Success') {
  5168. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5169. const {
  5170. currentArea
  5171. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5172. if (currentArea === aimedArea) {
  5173. logStatus.success();
  5174. return currentArea;
  5175. }
  5176. logStatus.error('Error: change country filed');
  5177. return 'CN';
  5178. }
  5179. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5180. return 'CN';
  5181. }
  5182. logStatus.error(`${result}:${statusText}(${status})`);
  5183. return 'CN';
  5184. } catch (error) {
  5185. throwError(error, 'Steam.changeArea');
  5186. return false;
  5187. }
  5188. }
  5189. async function _joinGroup2(groupName) {
  5190. try {
  5191. const logStatus = scripts_echoLog({
  5192. type: 'joiningSteamGroup',
  5193. text: groupName
  5194. });
  5195. const {
  5196. result,
  5197. statusText,
  5198. status,
  5199. data
  5200. } = await tools_httpRequest({
  5201. url: `https://steamcommunity.com/groups/${groupName}`,
  5202. method: 'POST',
  5203. headers: {
  5204. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5205. },
  5206. data: $.param({
  5207. action: 'join',
  5208. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5209. })
  5210. });
  5211. if (result === 'Success') {
  5212. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5213. logStatus.success();
  5214. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5215. return true;
  5216. }
  5217. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5218. return false;
  5219. }
  5220. logStatus.error(`${result}:${statusText}(${status})`);
  5221. return false;
  5222. } catch (error) {
  5223. throwError(error, 'Steam.joinGroup');
  5224. return false;
  5225. }
  5226. }
  5227. async function _leaveGroup2(groupName) {
  5228. try {
  5229. if (this.whiteList.groups.includes(groupName)) {
  5230. scripts_echoLog({
  5231. type: 'whiteList',
  5232. text: 'Steam.leaveGroup',
  5233. id: groupName
  5234. });
  5235. return true;
  5236. }
  5237. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5238. if (!groupId) {
  5239. return false;
  5240. }
  5241. const logStatus = scripts_echoLog({
  5242. type: 'leavingSteamGroup',
  5243. text: groupName
  5244. });
  5245. const {
  5246. result,
  5247. statusText,
  5248. status,
  5249. data
  5250. } = await tools_httpRequest({
  5251. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5252. method: 'POST',
  5253. headers: {
  5254. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5255. },
  5256. data: $.param({
  5257. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5258. action: 'leaveGroup',
  5259. groupId: groupId
  5260. })
  5261. });
  5262. if (result === 'Success') {
  5263. 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) {
  5264. logStatus.success();
  5265. return true;
  5266. }
  5267. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5268. return false;
  5269. }
  5270. logStatus.error(`${result}:${statusText}(${status})`);
  5271. return false;
  5272. } catch (error) {
  5273. throwError(error, 'Steam.leaveGroup');
  5274. return false;
  5275. }
  5276. }
  5277. async function _getGroupId2(groupName) {
  5278. try {
  5279. const logStatus = scripts_echoLog({
  5280. type: 'gettingSteamGroupId',
  5281. text: groupName
  5282. });
  5283. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5284. if (groupId) {
  5285. logStatus.success();
  5286. return groupId;
  5287. }
  5288. const {
  5289. result,
  5290. statusText,
  5291. status,
  5292. data
  5293. } = await tools_httpRequest({
  5294. url: `https://steamcommunity.com/groups/${groupName}`,
  5295. method: 'GET',
  5296. headers: {
  5297. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5298. }
  5299. });
  5300. if (result === 'Success') {
  5301. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5302. var _data$responseText$ma7;
  5303. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5304. if (groupId) {
  5305. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5306. logStatus.success();
  5307. return groupId;
  5308. }
  5309. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5310. return false;
  5311. }
  5312. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5313. return false;
  5314. }
  5315. logStatus.error(`${result}:${statusText}(${status})`);
  5316. return false;
  5317. } catch (error) {
  5318. throwError(error, 'Steam.getGroupID');
  5319. return false;
  5320. }
  5321. }
  5322. async function _addToWishlist2(gameId) {
  5323. try {
  5324. var _data$response;
  5325. const logStatus = scripts_echoLog({
  5326. type: 'addingToWishlist',
  5327. text: gameId
  5328. });
  5329. const {
  5330. result,
  5331. data
  5332. } = await tools_httpRequest({
  5333. url: 'https://store.steampowered.com/api/addtowishlist',
  5334. method: 'POST',
  5335. headers: {
  5336. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5337. },
  5338. data: $.param({
  5339. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5340. appid: gameId
  5341. }),
  5342. dataType: 'json'
  5343. });
  5344. 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) {
  5345. logStatus.success();
  5346. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5347. return true;
  5348. }
  5349. const {
  5350. result: resultR,
  5351. statusText: statusTextR,
  5352. status: statusR,
  5353. data: dataR
  5354. } = await tools_httpRequest({
  5355. url: `https://store.steampowered.com/app/${gameId}`,
  5356. method: 'GET'
  5357. });
  5358. if (resultR === 'Success') {
  5359. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5360. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5361. logStatus.warning(i18n('changeAreaNotice'));
  5362. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5363. return false;
  5364. }
  5365. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5366. }
  5367. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5368. logStatus.success();
  5369. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5370. return true;
  5371. } 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"')) {
  5372. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5373. return false;
  5374. }
  5375. logStatus.success();
  5376. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5377. return true;
  5378. }
  5379. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5380. return false;
  5381. }
  5382. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5383. return false;
  5384. } catch (error) {
  5385. throwError(error, 'Steam.addToWishlist');
  5386. return false;
  5387. }
  5388. }
  5389. async function _removeFromWishlist2(gameId) {
  5390. try {
  5391. var _data$response2;
  5392. if (this.whiteList.wishlists.includes(gameId)) {
  5393. scripts_echoLog({
  5394. type: 'whiteList',
  5395. text: 'Steam.removeFromWishlist',
  5396. id: gameId
  5397. });
  5398. return true;
  5399. }
  5400. const logStatus = scripts_echoLog({
  5401. type: 'removingFromWishlist',
  5402. text: gameId
  5403. });
  5404. const {
  5405. result,
  5406. data
  5407. } = await tools_httpRequest({
  5408. url: 'https://store.steampowered.com/api/removefromwishlist',
  5409. method: 'POST',
  5410. headers: {
  5411. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5412. },
  5413. data: $.param({
  5414. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5415. appid: gameId
  5416. }),
  5417. dataType: 'json'
  5418. });
  5419. 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) {
  5420. logStatus.success();
  5421. return true;
  5422. }
  5423. const {
  5424. result: resultR,
  5425. statusText: statusTextR,
  5426. status: statusR,
  5427. data: dataR
  5428. } = await tools_httpRequest({
  5429. url: `https://store.steampowered.com/app/${gameId}`,
  5430. method: 'GET'
  5431. });
  5432. if (resultR === 'Success') {
  5433. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5434. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5435. logStatus.warning(i18n('changeAreaNotice'));
  5436. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5437. if (!result || result === 'CN' || result === 'skip') {
  5438. return false;
  5439. }
  5440. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5441. }
  5442. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5443. logStatus.success();
  5444. return true;
  5445. }
  5446. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5447. return false;
  5448. }
  5449. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5450. return false;
  5451. }
  5452. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5453. return false;
  5454. } catch (error) {
  5455. throwError(error, 'Steam.removeFromWishlist');
  5456. return false;
  5457. }
  5458. }
  5459. async function _toggleFollowGame2(gameId, doTask) {
  5460. try {
  5461. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5462. scripts_echoLog({
  5463. type: 'whiteList',
  5464. text: 'Steam.unfollowGame',
  5465. id: gameId
  5466. });
  5467. return true;
  5468. }
  5469. const logStatus = scripts_echoLog({
  5470. type: `${doTask ? '' : 'un'}followingGame`,
  5471. text: gameId
  5472. });
  5473. const requestData = {
  5474. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5475. appid: gameId
  5476. };
  5477. if (!doTask) {
  5478. requestData.unfollow = '1';
  5479. }
  5480. const {
  5481. result,
  5482. data
  5483. } = await tools_httpRequest({
  5484. url: 'https://store.steampowered.com/explore/followgame/',
  5485. method: 'POST',
  5486. headers: {
  5487. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5488. },
  5489. data: $.param(requestData)
  5490. });
  5491. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5492. logStatus.success();
  5493. return true;
  5494. }
  5495. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5496. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5497. logStatus.warning(i18n('changeAreaNotice'));
  5498. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5499. return false;
  5500. }
  5501. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5502. }
  5503. if (doTask === followed) {
  5504. logStatus.success();
  5505. if (doTask) {
  5506. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5507. }
  5508. return true;
  5509. }
  5510. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5511. return false;
  5512. } catch (error) {
  5513. throwError(error, 'Steam.toggleFollowGame');
  5514. return false;
  5515. }
  5516. }
  5517. async function _isFollowedGame2(gameId) {
  5518. try {
  5519. const {
  5520. result,
  5521. data
  5522. } = await tools_httpRequest({
  5523. url: `https://store.steampowered.com/app/${gameId}`,
  5524. method: 'GET'
  5525. });
  5526. if (result === 'Success') {
  5527. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5528. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5529. return 'areaLocked';
  5530. }
  5531. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5532. return true;
  5533. }
  5534. return false;
  5535. }
  5536. return false;
  5537. }
  5538. return false;
  5539. } catch (error) {
  5540. throwError(error, 'Steam.isFollowedGame');
  5541. return false;
  5542. }
  5543. }
  5544. async function _toggleForum2(gameId) {
  5545. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5546. try {
  5547. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5548. scripts_echoLog({
  5549. type: 'whiteList',
  5550. text: 'Steam.unsubscribForum',
  5551. id: gameId
  5552. });
  5553. return true;
  5554. }
  5555. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5556. if (!forumId) {
  5557. return false;
  5558. }
  5559. const logStatus = scripts_echoLog({
  5560. type: `${doTask ? '' : 'un'}subscribingForum`,
  5561. text: gameId
  5562. });
  5563. const [ id, feature ] = forumId.split('_');
  5564. const {
  5565. result,
  5566. statusText,
  5567. status,
  5568. data
  5569. } = await tools_httpRequest({
  5570. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5571. method: 'POST',
  5572. responseType: 'json',
  5573. headers: {
  5574. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5575. },
  5576. data: $.param({
  5577. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5578. })
  5579. });
  5580. if (result === 'Success') {
  5581. var _data$response3, _data$response4;
  5582. 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)) {
  5583. if (doTask) {
  5584. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5585. }
  5586. logStatus.success();
  5587. return true;
  5588. }
  5589. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5590. return true;
  5591. }
  5592. logStatus.error(`${result}:${statusText}(${status})`);
  5593. return true;
  5594. } catch (error) {
  5595. throwError(error, 'Steam.toggleForum');
  5596. return true;
  5597. }
  5598. }
  5599. async function _getForumId2(gameId) {
  5600. try {
  5601. const logStatus = scripts_echoLog({
  5602. type: 'gettingForumId',
  5603. text: gameId
  5604. });
  5605. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5606. if (forumId) {
  5607. logStatus.success();
  5608. return forumId;
  5609. }
  5610. const {
  5611. result,
  5612. statusText,
  5613. status,
  5614. data
  5615. } = await tools_httpRequest({
  5616. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5617. method: 'GET'
  5618. });
  5619. if (result === 'Success') {
  5620. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5621. var _data$responseText, _data$responseText$ma8;
  5622. 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];
  5623. if (forumId) {
  5624. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5625. logStatus.success();
  5626. return forumId;
  5627. }
  5628. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5629. return false;
  5630. }
  5631. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5632. return false;
  5633. }
  5634. logStatus.error(`${result}:${statusText}(${status})`);
  5635. return false;
  5636. } catch (error) {
  5637. throwError(error, 'Steam.getForumId');
  5638. return false;
  5639. }
  5640. }
  5641. async function _toggleFavoriteWorkshop2(id) {
  5642. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5643. try {
  5644. if (!doTask && this.whiteList.workshops.includes(id)) {
  5645. scripts_echoLog({
  5646. type: 'whiteList',
  5647. text: 'Steam.unfavoriteWorkshop',
  5648. id: id
  5649. });
  5650. return true;
  5651. }
  5652. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5653. if (!appid) {
  5654. return false;
  5655. }
  5656. const logStatus = scripts_echoLog({
  5657. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5658. text: id
  5659. });
  5660. const {
  5661. result,
  5662. statusText,
  5663. status,
  5664. data
  5665. } = await tools_httpRequest({
  5666. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5667. method: 'POST',
  5668. headers: {
  5669. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5670. },
  5671. data: $.param({
  5672. id: id,
  5673. appid: appid,
  5674. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5675. })
  5676. });
  5677. if (result === 'Success') {
  5678. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5679. if (doTask) {
  5680. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5681. }
  5682. logStatus.success();
  5683. return true;
  5684. }
  5685. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5686. return false;
  5687. }
  5688. logStatus.error(`${result}:${statusText}(${status})`);
  5689. return false;
  5690. } catch (error) {
  5691. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5692. return false;
  5693. }
  5694. }
  5695. async function _getWorkshopAppId2(id) {
  5696. try {
  5697. const logStatus = scripts_echoLog({
  5698. type: 'gettingWorkshopAppId',
  5699. text: id
  5700. });
  5701. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5702. if (appId) {
  5703. logStatus.success();
  5704. return appId;
  5705. }
  5706. const {
  5707. result,
  5708. statusText,
  5709. status,
  5710. data
  5711. } = await tools_httpRequest({
  5712. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5713. method: 'GET'
  5714. });
  5715. if (result === 'Success') {
  5716. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5717. var _data$responseText$ma9;
  5718. 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];
  5719. if (appId) {
  5720. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5721. logStatus.success();
  5722. return appId;
  5723. }
  5724. logStatus.error('Error: getWorkshopAppId failed');
  5725. return false;
  5726. }
  5727. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5728. return false;
  5729. }
  5730. logStatus.error(`${result}:${statusText}(${status})`);
  5731. return false;
  5732. } catch (error) {
  5733. throwError(error, 'Steam.getWorkshopAppId');
  5734. return false;
  5735. }
  5736. }
  5737. async function _voteUpWorkshop2(id) {
  5738. try {
  5739. const logStatus = scripts_echoLog({
  5740. type: 'votingUpWorkshop',
  5741. text: id
  5742. });
  5743. const {
  5744. result,
  5745. statusText,
  5746. status,
  5747. data
  5748. } = await tools_httpRequest({
  5749. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5750. method: 'POST',
  5751. responseType: 'json',
  5752. headers: {
  5753. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5754. },
  5755. data: $.param({
  5756. id: id,
  5757. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5758. })
  5759. });
  5760. if (result === 'Success') {
  5761. var _data$response5;
  5762. 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) {
  5763. logStatus.success();
  5764. return true;
  5765. }
  5766. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5767. return true;
  5768. }
  5769. logStatus.error(`${result}:${statusText}(${status})`);
  5770. return true;
  5771. } catch (error) {
  5772. throwError(error, 'Steam.voteupWorkshop');
  5773. return true;
  5774. }
  5775. }
  5776. async function _toggleCurator2(curatorId) {
  5777. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5778. try {
  5779. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5780. scripts_echoLog({
  5781. type: 'whiteList',
  5782. text: 'Steam.unfollowCurator',
  5783. id: curatorId
  5784. });
  5785. return true;
  5786. }
  5787. const logStatus = scripts_echoLog({
  5788. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5789. text: curatorId
  5790. });
  5791. const {
  5792. result,
  5793. statusText,
  5794. status,
  5795. data
  5796. } = await tools_httpRequest({
  5797. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5798. method: 'POST',
  5799. headers: {
  5800. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5801. },
  5802. data: $.param({
  5803. clanid: curatorId,
  5804. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5805. follow: doTask
  5806. }),
  5807. dataType: 'json'
  5808. });
  5809. if (result === 'Success') {
  5810. var _data$response6, _data$response6$succe, _data$response7;
  5811. 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) {
  5812. logStatus.success();
  5813. return true;
  5814. }
  5815. 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})`);
  5816. return false;
  5817. }
  5818. logStatus.error(`${result}:${statusText}(${status})`);
  5819. return false;
  5820. } catch (error) {
  5821. throwError(error, 'Steam.toggleCurator');
  5822. return false;
  5823. }
  5824. }
  5825. async function _toggleCuratorLike2(link) {
  5826. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5827. try {
  5828. const [ path, name ] = link.split('/');
  5829. if (!(path && name)) {
  5830. scripts_echoLog({
  5831. text: i18n('errorLink', link)
  5832. });
  5833. return false;
  5834. }
  5835. const curatorId = await this.getCuratorId(path, name);
  5836. if (curatorId) {
  5837. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5838. }
  5839. return false;
  5840. } catch (error) {
  5841. throwError(error, 'Steam.toggleCuratorLike');
  5842. return false;
  5843. }
  5844. }
  5845. async function _getAnnouncementParams2(appId, viewId) {
  5846. try {
  5847. const logStatus = scripts_echoLog({
  5848. type: 'gettingAnnouncementParams',
  5849. text: appId,
  5850. id: viewId
  5851. });
  5852. const {
  5853. result,
  5854. statusText,
  5855. status,
  5856. data
  5857. } = await tools_httpRequest({
  5858. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5859. method: 'GET',
  5860. headers: {
  5861. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5862. }
  5863. });
  5864. if (result === 'Success') {
  5865. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5866. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5867. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5868. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5869. 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];
  5870. if (authWgToken && clanId) {
  5871. logStatus.success();
  5872. return {
  5873. authWgToken: authWgToken,
  5874. clanId: clanId,
  5875. gid: gid
  5876. };
  5877. }
  5878. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5879. return {};
  5880. }
  5881. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5882. return {};
  5883. }
  5884. logStatus.error(`${result}:${statusText}(${status})`);
  5885. return {};
  5886. } catch (error) {
  5887. throwError(error, 'Steam.likeAnnouncement');
  5888. return {};
  5889. }
  5890. }
  5891. async function _likeAnnouncement2(id) {
  5892. try {
  5893. const [ appId, viewId ] = id.split('/');
  5894. if (!(appId && viewId)) {
  5895. scripts_echoLog({
  5896. type: 'lost params',
  5897. text: id
  5898. });
  5899. return false;
  5900. }
  5901. const {
  5902. authWgToken,
  5903. clanId,
  5904. gid
  5905. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5906. if (!(authWgToken && clanId)) {
  5907. return false;
  5908. }
  5909. const logStatus = scripts_echoLog({
  5910. type: 'likingAnnouncement',
  5911. text: appId,
  5912. id: viewId
  5913. });
  5914. const {
  5915. result,
  5916. statusText,
  5917. status,
  5918. data
  5919. } = await tools_httpRequest({
  5920. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5921. method: 'POST',
  5922. headers: {
  5923. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5924. Host: 'store.steampowered.com',
  5925. Origin: 'https://store.steampowered.com',
  5926. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5927. },
  5928. data: $.param({
  5929. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5930. wgauthtoken: authWgToken,
  5931. voteup: 1,
  5932. clanid: clanId,
  5933. ajax: 1
  5934. }),
  5935. dataType: 'json'
  5936. });
  5937. if (result === 'Success') {
  5938. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5939. logStatus.success();
  5940. return true;
  5941. }
  5942. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5943. return false;
  5944. }
  5945. logStatus.error(`${result}:${statusText}(${status})`);
  5946. return false;
  5947. } catch (error) {
  5948. throwError(error, 'Steam.likeAnnouncement');
  5949. return false;
  5950. }
  5951. }
  5952. function Steam_setCache2(type, name, id) {
  5953. try {
  5954. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  5955. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  5956. } catch (error) {
  5957. throwError(error, 'Steam.setCache');
  5958. }
  5959. }
  5960. const social_Steam = Steam;
  5961. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  5962. Website_checkPrivateRedeclaration(obj, privateSet);
  5963. privateSet.add(obj);
  5964. }
  5965. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  5966. if (privateCollection.has(obj)) {
  5967. throw new TypeError('Cannot initialize the same private elements twice on an object');
  5968. }
  5969. }
  5970. function Website_defineProperty(obj, key, value) {
  5971. if (key in obj) {
  5972. Object.defineProperty(obj, key, {
  5973. value: value,
  5974. enumerable: true,
  5975. configurable: true,
  5976. writable: true
  5977. });
  5978. } else {
  5979. obj[key] = value;
  5980. }
  5981. return obj;
  5982. }
  5983. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  5984. if (!privateSet.has(receiver)) {
  5985. throw new TypeError('attempted to get private field on non-instance');
  5986. }
  5987. return fn;
  5988. }
  5989. var _bind = new WeakSet();
  5990. class Website {
  5991. constructor() {
  5992. Website_classPrivateMethodInitSpec(this, _bind);
  5993. Website_defineProperty(this, 'undoneTasks', void 0);
  5994. Website_defineProperty(this, 'socialTasks', void 0);
  5995. Website_defineProperty(this, 'giveawayId', void 0);
  5996. Website_defineProperty(this, 'socialInitialized', {
  5997. discord: false,
  5998. instagram: false,
  5999. reddit: false,
  6000. twitch: false,
  6001. twitter: false,
  6002. vk: false,
  6003. youtube: false,
  6004. steam: false
  6005. });
  6006. Website_defineProperty(this, 'initialized', false);
  6007. Website_defineProperty(this, 'social', {});
  6008. }
  6009. async initSocial(action) {
  6010. try {
  6011. const pro = [];
  6012. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6013. if (tasks.discord) {
  6014. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6015. if (hasDiscord && !this.socialInitialized.discord) {
  6016. this.social.discord = new social_Discord();
  6017. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6018. }
  6019. }
  6020. if (tasks.instagram) {
  6021. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6022. if (hasInstagram && !this.socialInitialized.instagram) {
  6023. this.social.instagram = new social_Instagram();
  6024. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6025. }
  6026. }
  6027. if (tasks.reddit) {
  6028. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6029. if (hasReddit && !this.socialInitialized.reddit) {
  6030. this.social.reddit = new social_Reddit();
  6031. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6032. }
  6033. }
  6034. if (tasks.twitch) {
  6035. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6036. if (hasTwitch && !this.socialInitialized.twitch) {
  6037. this.social.twitch = new social_Twitch();
  6038. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6039. }
  6040. }
  6041. if (tasks.twitter) {
  6042. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6043. if (hasTwitter && !this.socialInitialized.twitter) {
  6044. this.social.twitter = new social_Twitter();
  6045. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6046. }
  6047. }
  6048. if (tasks.vk) {
  6049. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6050. if (hasVk && !this.socialInitialized.vk) {
  6051. this.social.vk = new social_Vk();
  6052. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6053. }
  6054. }
  6055. if (tasks.youtube) {
  6056. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6057. if (hasYoutube && !this.socialInitialized.youtube) {
  6058. this.social.youtube = new Youtube();
  6059. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6060. }
  6061. }
  6062. if (tasks.steam) {
  6063. const hasSteam = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6064. if (hasSteam && !this.socialInitialized.steam) {
  6065. this.social.steam = new social_Steam();
  6066. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steam', this.social.steam.init()));
  6067. }
  6068. }
  6069. if (tasks.links && tasks.links.length > 0) {
  6070. this.social.visitLink = visitLink;
  6071. }
  6072. return await Promise.all(pro).then(result => {
  6073. let checked = true;
  6074. for (const data of result) {
  6075. if (data.result) {
  6076. this.socialInitialized[data.name] = data.result;
  6077. } else {
  6078. checked = false;
  6079. }
  6080. }
  6081. return checked;
  6082. });
  6083. } catch (error) {
  6084. throwError(error, 'Website.initSocial');
  6085. return false;
  6086. }
  6087. }
  6088. uniqueTasks(allTasks) {
  6089. const result = {};
  6090. for (const [ social, types ] of Object.entries(allTasks)) {
  6091. result[social] = {};
  6092. for (const [ type, tasks ] of Object.entries(types)) {
  6093. result[social][type] = unique(tasks);
  6094. }
  6095. }
  6096. return result;
  6097. }
  6098. async toggleTask(action) {
  6099. try {
  6100. if (!this.initialized && !this.init()) {
  6101. return false;
  6102. }
  6103. if (!await this.classifyTask(action)) {
  6104. return false;
  6105. }
  6106. if (!await this.initSocial(action)) {
  6107. return false;
  6108. }
  6109. const pro = [];
  6110. const doTask = action === 'do';
  6111. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6112. if (this.social.discord) {
  6113. pro.push(this.social.discord.toggle({
  6114. doTask: doTask,
  6115. ...tasks.discord
  6116. }));
  6117. }
  6118. if (this.social.instagram) {
  6119. pro.push(this.social.instagram.toggle({
  6120. doTask: doTask,
  6121. ...tasks.instagram
  6122. }));
  6123. }
  6124. if (this.social.reddit) {
  6125. pro.push(this.social.reddit.toggle({
  6126. doTask: doTask,
  6127. ...tasks.reddit
  6128. }));
  6129. }
  6130. if (this.social.twitch) {
  6131. pro.push(this.social.twitch.toggle({
  6132. doTask: doTask,
  6133. ...tasks.twitch
  6134. }));
  6135. }
  6136. if (this.social.twitter) {
  6137. pro.push(this.social.twitter.toggle({
  6138. doTask: doTask,
  6139. ...tasks.twitter
  6140. }));
  6141. }
  6142. if (this.social.vk) {
  6143. pro.push(this.social.vk.toggle({
  6144. doTask: doTask,
  6145. ...tasks.vk
  6146. }));
  6147. }
  6148. if (this.social.youtube) {
  6149. pro.push(this.social.youtube.toggle({
  6150. doTask: doTask,
  6151. ...tasks.youtube
  6152. }));
  6153. }
  6154. if (this.social.steam) {
  6155. pro.push(this.social.steam.toggle({
  6156. doTask: doTask,
  6157. ...tasks.steam
  6158. }));
  6159. }
  6160. if (this.social.visitLink && tasks.links && doTask) {
  6161. for (const link of tasks.links) {
  6162. pro.push(this.social.visitLink(link));
  6163. }
  6164. }
  6165. if (doTask && tasks.extra && this.extraDoTask) {
  6166. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6167. if (hasExtra) {
  6168. pro.push(this.extraDoTask(tasks.extra));
  6169. }
  6170. }
  6171. await Promise.all(pro);
  6172. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6173. return true;
  6174. } catch (error) {
  6175. throwError(error, 'Website.toggleTask');
  6176. return false;
  6177. }
  6178. }
  6179. async doTask() {
  6180. try {
  6181. return await this.toggleTask('do');
  6182. } catch (error) {
  6183. throwError(error, 'Website.doTask');
  6184. return false;
  6185. }
  6186. }
  6187. async undoTask() {
  6188. try {
  6189. return await this.toggleTask('undo');
  6190. } catch (error) {
  6191. throwError(error, 'Website.undoTask');
  6192. return false;
  6193. }
  6194. }
  6195. }
  6196. async function _bind2(name, init) {
  6197. try {
  6198. return {
  6199. name: name,
  6200. result: await init
  6201. };
  6202. } catch (error) {
  6203. throwError(error, 'Website.bind');
  6204. return {
  6205. name: name,
  6206. result: false
  6207. };
  6208. }
  6209. }
  6210. const website_Website = Website;
  6211. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6212. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6213. privateSet.add(obj);
  6214. }
  6215. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6216. if (privateCollection.has(obj)) {
  6217. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6218. }
  6219. }
  6220. function FreeAnyWhere_defineProperty(obj, key, value) {
  6221. if (key in obj) {
  6222. Object.defineProperty(obj, key, {
  6223. value: value,
  6224. enumerable: true,
  6225. configurable: true,
  6226. writable: true
  6227. });
  6228. } else {
  6229. obj[key] = value;
  6230. }
  6231. return obj;
  6232. }
  6233. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6234. if (!privateSet.has(receiver)) {
  6235. throw new TypeError('attempted to get private field on non-instance');
  6236. }
  6237. return fn;
  6238. }
  6239. const FreeAnyWhere_defaultTasks = {
  6240. steam: {
  6241. groupLinks: [],
  6242. wishlistLinks: [],
  6243. curatorLinks: [],
  6244. followLinks: []
  6245. },
  6246. vk: {
  6247. nameLinks: []
  6248. }
  6249. };
  6250. var _getGiveawayId = new WeakSet();
  6251. var _verify = new WeakSet();
  6252. class FreeAnyWhere extends website_Website {
  6253. constructor() {
  6254. super(...arguments);
  6255. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6256. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6257. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6258. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6259. FreeAnyWhere_defineProperty(this, 'socialTasks', {
  6260. ...FreeAnyWhere_defaultTasks
  6261. });
  6262. FreeAnyWhere_defineProperty(this, 'undoneTasks', {
  6263. ...FreeAnyWhere_defaultTasks
  6264. });
  6265. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6266. }
  6267. static test() {
  6268. return window.location.host === 'freeanywhere.net';
  6269. }
  6270. init() {
  6271. try {
  6272. const logStatus = scripts_echoLog({
  6273. text: i18n('initing')
  6274. });
  6275. if ($('a[href="#/login"]').length > 0) {
  6276. window.open('/#/login', '_self');
  6277. logStatus.warning(i18n('needLogin'));
  6278. return false;
  6279. }
  6280. if (window.location.href.includes('/login')) {
  6281. logStatus.warning(i18n('needLogin'));
  6282. return false;
  6283. }
  6284. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6285. var _window$location$href;
  6286. 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];
  6287. if (!id) {
  6288. logStatus.error(i18n('getFailed', 'Id'));
  6289. return false;
  6290. }
  6291. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6292. }
  6293. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6294. return false;
  6295. }
  6296. this.initialized = true;
  6297. logStatus.success();
  6298. return true;
  6299. } catch (error) {
  6300. throwError(error, 'Freeanywhere.init');
  6301. return false;
  6302. }
  6303. }
  6304. async classifyTask(action) {
  6305. try {
  6306. const logStatus = scripts_echoLog({
  6307. text: i18n('getTasksInfo')
  6308. });
  6309. if (action === 'undo') {
  6310. var _GM_getValue;
  6311. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  6312. ...FreeAnyWhere_defaultTasks
  6313. };
  6314. }
  6315. const {
  6316. result,
  6317. statusText,
  6318. status,
  6319. data
  6320. } = await tools_httpRequest({
  6321. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6322. method: 'GET',
  6323. headers: {
  6324. authorization: `Token ${window.localStorage.getItem('token')}`,
  6325. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6326. },
  6327. responseType: 'json'
  6328. });
  6329. if (result === 'Success') {
  6330. var _data$response;
  6331. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6332. if (tasks) {
  6333. if (action === 'verify') {
  6334. this.tasks = [];
  6335. }
  6336. for (const task of tasks) {
  6337. const type = task.challenge;
  6338. const social = task.challenge_provider;
  6339. const taskInfo = {
  6340. id: task.id,
  6341. title: task.title
  6342. };
  6343. if (action === 'verify' && !task.is_success) {
  6344. this.tasks.push(taskInfo);
  6345. continue;
  6346. }
  6347. switch (social) {
  6348. case 'steam':
  6349. taskInfo.social = 'steam';
  6350. switch (type) {
  6351. case 'WL':
  6352. if (action === 'undo') {
  6353. this.socialTasks.steam.wishlistLinks.push(task.link);
  6354. }
  6355. if (action === 'do' && !task.is_success) {
  6356. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6357. }
  6358. break;
  6359.  
  6360. case 'JTG':
  6361. if (action === 'undo') {
  6362. this.socialTasks.steam.groupLinks.push(task.link);
  6363. }
  6364. if (action === 'do' && !task.is_success) {
  6365. this.undoneTasks.steam.groupLinks.push(task.link);
  6366. }
  6367. break;
  6368.  
  6369. case 'STC':
  6370. if (action === 'undo') {
  6371. this.socialTasks.steam.curatorLinks.push(task.link);
  6372. }
  6373. if (action === 'do' && !task.is_success) {
  6374. this.undoneTasks.steam.curatorLinks.push(task.link);
  6375. }
  6376. break;
  6377.  
  6378. case 'GF':
  6379. if (action === 'undo') {
  6380. this.socialTasks.steam.followLinks.push(task.link);
  6381. }
  6382. if (action === 'do' && !task.is_success) {
  6383. this.undoneTasks.steam.followLinks.push(task.link);
  6384. }
  6385. break;
  6386. }
  6387. break;
  6388.  
  6389. case 'vk-oauth2':
  6390. if (action === 'undo') {
  6391. this.socialTasks.vk.nameLinks.push(task.link);
  6392. }
  6393. if (action === 'do' && !task.is_success) {
  6394. this.undoneTasks.vk.nameLinks.push(task.link);
  6395. }
  6396. break;
  6397.  
  6398. case 'website':
  6399. break;
  6400.  
  6401. default:
  6402. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6403. break;
  6404. }
  6405. }
  6406. logStatus.success();
  6407. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6408. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6409. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6410. tasks: this.socialTasks,
  6411. time: new Date().getTime()
  6412. });
  6413. return true;
  6414. }
  6415. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6416. console.error(data);
  6417. return false;
  6418. }
  6419. logStatus.error(`${result}:${statusText}(${status})`);
  6420. return false;
  6421. } catch (error) {
  6422. throwError(error, 'Freeanywhere.classifyTask');
  6423. return false;
  6424. }
  6425. }
  6426. async verifyTask() {
  6427. try {
  6428. if (!this.initialized && !this.init()) {
  6429. return false;
  6430. }
  6431. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6432. return false;
  6433. }
  6434. const pro = [];
  6435. for (const task of this.tasks) {
  6436. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6437. await delay(1e3);
  6438. }
  6439. await Promise.all(pro);
  6440. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6441. return !!await this.getKey(true);
  6442. } catch (error) {
  6443. throwError(error, 'Freeanywhere.verifyTask');
  6444. return false;
  6445. }
  6446. }
  6447. async getKey(initialized) {
  6448. try {
  6449. if (!initialized && !this.initialized && !this.init()) {
  6450. return false;
  6451. }
  6452. const logStatus = scripts_echoLog({
  6453. text: i18n('gettingKey')
  6454. });
  6455. const {
  6456. result,
  6457. statusText,
  6458. status,
  6459. data
  6460. } = await tools_httpRequest({
  6461. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6462. method: 'GET',
  6463. dataType: 'json',
  6464. headers: {
  6465. authorization: `Token ${window.localStorage.getItem('token')}`
  6466. }
  6467. });
  6468. if (result === 'Success') {
  6469. var _data$response2;
  6470. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6471. logStatus.success();
  6472. scripts_echoLog({}).success(data.response.reward);
  6473. return data.response.reward;
  6474. }
  6475. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6476. return false;
  6477. }
  6478. logStatus.error(`${result}:${statusText}(${status})`);
  6479. return false;
  6480. } catch (error) {
  6481. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6482. return false;
  6483. }
  6484. }
  6485. }
  6486. function _getGiveawayId2() {
  6487. try {
  6488. var _window$location$href2;
  6489. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6490. if (giveawayId) {
  6491. this.giveawayId = giveawayId;
  6492. return true;
  6493. }
  6494. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6495. return false;
  6496. } catch (error) {
  6497. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6498. }
  6499. }
  6500. async function _verify2(task) {
  6501. try {
  6502. const logStatus = scripts_echoLog({
  6503. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6504. });
  6505. const {
  6506. result,
  6507. statusText,
  6508. status,
  6509. data
  6510. } = await tools_httpRequest({
  6511. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6512. method: 'GET',
  6513. dataType: 'json',
  6514. headers: {
  6515. authorization: `Token ${window.localStorage.getItem('token')}`,
  6516. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6517. }
  6518. });
  6519. if (result === 'Success') {
  6520. var _data$response3;
  6521. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6522. logStatus.success();
  6523. return true;
  6524. }
  6525. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6526. return false;
  6527. }
  6528. logStatus.error(`${result}:${statusText}(${status})`);
  6529. return false;
  6530. } catch (error) {
  6531. throwError(error, 'Freeanywhere.verify');
  6532. return false;
  6533. }
  6534. }
  6535. const website_FreeAnyWhere = FreeAnyWhere;
  6536. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6537. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6538. privateSet.add(obj);
  6539. }
  6540. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6541. if (privateCollection.has(obj)) {
  6542. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6543. }
  6544. }
  6545. function GiveawaySu_defineProperty(obj, key, value) {
  6546. if (key in obj) {
  6547. Object.defineProperty(obj, key, {
  6548. value: value,
  6549. enumerable: true,
  6550. configurable: true,
  6551. writable: true
  6552. });
  6553. } else {
  6554. obj[key] = value;
  6555. }
  6556. return obj;
  6557. }
  6558. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6559. if (!privateSet.has(receiver)) {
  6560. throw new TypeError('attempted to get private field on non-instance');
  6561. }
  6562. return fn;
  6563. }
  6564. const GiveawaySu_defaultTasks = {
  6565. steam: {
  6566. groupLinks: [],
  6567. wishlistLinks: [],
  6568. curatorLinks: [],
  6569. curatorLikeLinks: [],
  6570. followLinks: [],
  6571. forumLinks: [],
  6572. announcementLinks: [],
  6573. workshopVoteLinks: []
  6574. },
  6575. discord: {
  6576. serverLinks: []
  6577. },
  6578. instagram: {
  6579. userLinks: []
  6580. },
  6581. vk: {
  6582. nameLinks: []
  6583. },
  6584. twitch: {
  6585. channelLinks: []
  6586. },
  6587. reddit: {
  6588. redditLinks: []
  6589. },
  6590. youtube: {
  6591. channelLinks: [],
  6592. likeLinks: []
  6593. }
  6594. };
  6595. var _checkLogin = new WeakSet();
  6596. var _checkLeftKey = new WeakSet();
  6597. var GiveawaySu_getGiveawayId = new WeakSet();
  6598. class GiveawaySu extends website_Website {
  6599. constructor() {
  6600. super(...arguments);
  6601. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6602. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6603. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6604. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6605. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6606. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6607. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6608. }
  6609. static test() {
  6610. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6611. }
  6612. async after() {
  6613. try {
  6614. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6615. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6616. }
  6617. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6618. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6619. }
  6620. } catch (error) {
  6621. throwError(error, 'Giveawaysu.after');
  6622. }
  6623. }
  6624. init() {
  6625. try {
  6626. const logStatus = scripts_echoLog({
  6627. text: i18n('initing')
  6628. });
  6629. if ($('a.steam-login').length > 0) {
  6630. window.open('/steam/redirect', '_self');
  6631. logStatus.warning(i18n('needLogin'));
  6632. return false;
  6633. }
  6634. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6635. return false;
  6636. }
  6637. this.initialized = true;
  6638. logStatus.success();
  6639. return true;
  6640. } catch (error) {
  6641. throwError(error, 'Giveawaysu.init');
  6642. return false;
  6643. }
  6644. }
  6645. async classifyTask(action) {
  6646. try {
  6647. const logStatus = scripts_echoLog({
  6648. text: i18n('getTasksInfo')
  6649. });
  6650. if (action === 'undo') {
  6651. var _GM_getValue;
  6652. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6653. return true;
  6654. }
  6655. const pro = [];
  6656. const tasks = $('#actions tr');
  6657. if ($('div.bind-discord').is(':visible')) {
  6658. $('div.bind-discord a')[0].click();
  6659. }
  6660. if ($('div.bind-twitch').is(':visible')) {
  6661. $('div.bind-twitch a')[0].click();
  6662. }
  6663. for (const task of tasks) {
  6664. pro.push(new Promise(resolve => {
  6665. const td = $(task).find('td:not(".hidden")');
  6666. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6667. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6668. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6669. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6670. const taskName = taskDes.text().trim();
  6671. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6672. return resolve(true);
  6673. }
  6674. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6675. if (!taskLink) {
  6676. return resolve(false);
  6677. }
  6678. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6679. this.undoneTasks.steam.groupLinks.push(taskLink);
  6680. } else if (/like.*announcement/gi.test(taskName)) {
  6681. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6682. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6683. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6684. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6685. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6686. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6687. this.undoneTasks.steam.forumLinks.push(taskLink);
  6688. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6689. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6690. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6691. this.undoneTasks.discord.serverLinks.push(taskLink);
  6692. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6693. this.undoneTasks.instagram.userLinks.push(taskLink);
  6694. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6695. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6696. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6697. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6698. } else if (/watch.*art/gim.test(taskName)) {
  6699. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6700. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6701. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6702. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6703. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6704. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6705. this.undoneTasks.vk.nameLinks.push(taskLink);
  6706. } else {
  6707. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6708. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6709. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6710. }
  6711. if (/follow.*button/gim.test(taskName)) {
  6712. this.undoneTasks.steam.followLinks.push(taskLink);
  6713. }
  6714. }
  6715. }
  6716. resolve(true);
  6717. }).catch(error => {
  6718. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6719. return false;
  6720. });
  6721. }));
  6722. }
  6723. await Promise.all(pro);
  6724. logStatus.success();
  6725. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6726. this.socialTasks = this.undoneTasks;
  6727. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6728. tasks: this.socialTasks,
  6729. time: new Date().getTime()
  6730. });
  6731. return true;
  6732. } catch (error) {
  6733. throwError(error, 'Giveawaysu.classifyTask');
  6734. return false;
  6735. }
  6736. }
  6737. }
  6738. function _checkLogin2() {
  6739. try {
  6740. if (!globalOptions.other.checkLogin) {
  6741. return true;
  6742. }
  6743. if ($('a.steam-login').length > 0) {
  6744. window.open('/steam/redirect', '_self');
  6745. }
  6746. return true;
  6747. } catch (error) {
  6748. throwError(error, 'Giveawaysu.checkLogin');
  6749. return false;
  6750. }
  6751. }
  6752. async function _checkLeftKey2() {
  6753. try {
  6754. if (!globalOptions.other.checkLeftKey) {
  6755. return true;
  6756. }
  6757. if ($('.giveaway-ended').length > 0) {
  6758. await external_Swal_default().fire({
  6759. icon: 'warning',
  6760. title: i18n('notice'),
  6761. text: i18n('noKeysLeft'),
  6762. confirmButtonText: i18n('confirm'),
  6763. cancelButtonText: i18n('cancel'),
  6764. showCancelButton: true
  6765. }).then(_ref => {
  6766. let {
  6767. value
  6768. } = _ref;
  6769. if (value) {
  6770. window.close();
  6771. }
  6772. });
  6773. }
  6774. return true;
  6775. } catch (error) {
  6776. throwError(error, 'Giveawaysu.checkLeftKey');
  6777. return false;
  6778. }
  6779. }
  6780. function GiveawaySu_getGiveawayId2() {
  6781. var _window$location$href;
  6782. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6783. if (giveawayId) {
  6784. this.giveawayId = giveawayId;
  6785. return true;
  6786. }
  6787. scripts_echoLog({
  6788. text: i18n('getFailed', 'GiveawayId')
  6789. });
  6790. return false;
  6791. }
  6792. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6793. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6794. privateSet.add(obj);
  6795. }
  6796. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6797. if (privateCollection.has(obj)) {
  6798. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6799. }
  6800. }
  6801. function Indiedb_defineProperty(obj, key, value) {
  6802. if (key in obj) {
  6803. Object.defineProperty(obj, key, {
  6804. value: value,
  6805. enumerable: true,
  6806. configurable: true,
  6807. writable: true
  6808. });
  6809. } else {
  6810. obj[key] = value;
  6811. }
  6812. return obj;
  6813. }
  6814. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6815. if (!privateSet.has(receiver)) {
  6816. throw new TypeError('attempted to get private field on non-instance');
  6817. }
  6818. return fn;
  6819. }
  6820. var _join = new WeakSet();
  6821. var _do = new WeakSet();
  6822. var Indiedb_checkLogin = new WeakSet();
  6823. var Indiedb_checkLeftKey = new WeakSet();
  6824. class Indiedb {
  6825. constructor() {
  6826. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6827. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6828. Indiedb_classPrivateMethodInitSpec(this, _do);
  6829. Indiedb_classPrivateMethodInitSpec(this, _join);
  6830. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6831. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6832. }
  6833. static test() {
  6834. return window.location.host === 'www.indiedb.com';
  6835. }
  6836. async after() {
  6837. try {
  6838. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  6839. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6840. }
  6841. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  6842. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6843. }
  6844. } catch (error) {
  6845. throwError(error, 'Indiedb.after');
  6846. }
  6847. }
  6848. async doTask() {
  6849. try {
  6850. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  6851. return false;
  6852. }
  6853. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  6854. } catch (error) {
  6855. throwError(error, 'Indiedb.doTask');
  6856. return false;
  6857. }
  6858. }
  6859. }
  6860. async function _join2() {
  6861. try {
  6862. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6863. scripts_echoLog({}).error(i18n('needLogin'));
  6864. return false;
  6865. }
  6866. const currentoption = $('a.buttonenter.buttongiveaway');
  6867. if (/join giveaway/gim.test(currentoption.text())) {
  6868. const logStatus = scripts_echoLog({
  6869. text: `${i18n('joiningGiveaway')}...`
  6870. });
  6871. const {
  6872. result,
  6873. statusText,
  6874. status,
  6875. data
  6876. } = await tools_httpRequest({
  6877. url: currentoption.attr('href'),
  6878. method: 'POST',
  6879. data: 'ajax=t',
  6880. dataType: 'json',
  6881. headers: {
  6882. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6883. accept: 'application/json, text/javascript, */*; q=0.01',
  6884. origin: window.location.origin
  6885. }
  6886. });
  6887. if (result === 'Success') {
  6888. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6889. var _data$response, _data$response4, _data$response5;
  6890. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6891. var _data$response2, _data$response3;
  6892. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6893. $('#giveawaysjoined').slideDown();
  6894. $('#giveawaysrecommend').slideDown();
  6895. 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}` : ''}`);
  6896. return true;
  6897. }
  6898. 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}` : ''}`);
  6899. return false;
  6900. }
  6901. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6902. return false;
  6903. }
  6904. logStatus.error(`${result}:${statusText}(${status})`);
  6905. return false;
  6906. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6907. return true;
  6908. }
  6909. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6910. return false;
  6911. } catch (error) {
  6912. throwError(error, 'Indiedb.init');
  6913. return false;
  6914. }
  6915. }
  6916. async function _do2() {
  6917. try {
  6918. const id = $('script').map((index, script) => {
  6919. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6920. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6921. 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] ];
  6922. }
  6923. return null;
  6924. });
  6925. if (id.length === 2) {
  6926. const pro = [];
  6927. const tasks = $('#giveawaysjoined a[class*=promo]');
  6928. for (const task of tasks) {
  6929. const promo = $(task);
  6930. if (!promo.hasClass('buttonentered')) {
  6931. const status = scripts_echoLog({
  6932. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6933. });
  6934. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6935. let text = '';
  6936. if (promo.hasClass('facebookpromo')) {
  6937. text = 'facebookpromo';
  6938. } else if (promo.hasClass('twitterpromo')) {
  6939. text = 'twitterpromo';
  6940. } else {
  6941. text = 'visitpromo';
  6942. }
  6943. pro.push(new Promise(resolve => {
  6944. $.ajax({
  6945. type: 'POST',
  6946. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6947. timeout: 6e4,
  6948. dataType: 'json',
  6949. data: {
  6950. ajax: 't'
  6951. },
  6952. error(response, error, exception) {
  6953. console.log({
  6954. response: response,
  6955. error: error,
  6956. exception: exception
  6957. });
  6958. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6959. resolve(true);
  6960. },
  6961. success(response) {
  6962. console.log(response);
  6963. if (response.success) {
  6964. status.success(`Success:${response.text}`);
  6965. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6966. resolve(true);
  6967. } else {
  6968. status.error(`Error:${response.text}`);
  6969. resolve(true);
  6970. }
  6971. }
  6972. });
  6973. }));
  6974. } else if (promo.hasClass('emailoptinpromo')) {
  6975. pro.push(new Promise(resolve => {
  6976. $.ajax({
  6977. type: 'POST',
  6978. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6979. timeout: 6e4,
  6980. dataType: 'json',
  6981. data: {
  6982. ajax: 't',
  6983. emailsystoggle: 4
  6984. },
  6985. error(response, error, exception) {
  6986. console.log({
  6987. response: response,
  6988. error: error,
  6989. exception: exception
  6990. });
  6991. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6992. resolve(true);
  6993. },
  6994. success(response) {
  6995. console.log(response);
  6996. if (response.success) {
  6997. status.success(`Success:${response.text}`);
  6998. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6999. resolve(true);
  7000. } else {
  7001. status.error(`Error:${response.text}`);
  7002. resolve(true);
  7003. }
  7004. }
  7005. });
  7006. }));
  7007. } else if (promo.hasClass('watchingpromo')) {
  7008. pro.push(new Promise(resolve => {
  7009. var _promo$attr;
  7010. const data = getUrlQuery(promo.attr('href'));
  7011. data.ajax = 't';
  7012. $.ajax({
  7013. type: 'POST',
  7014. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7015. timeout: 6e4,
  7016. dataType: 'json',
  7017. data: data,
  7018. error(response, error, exception) {
  7019. console.log({
  7020. response: response,
  7021. error: error,
  7022. exception: exception
  7023. });
  7024. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7025. resolve(true);
  7026. },
  7027. success(response) {
  7028. console.log(response);
  7029. if (response.success) {
  7030. status.success(`Success:${response.text}`);
  7031. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7032. resolve(true);
  7033. } else {
  7034. status.error(`Error:${response.text}`);
  7035. resolve(true);
  7036. }
  7037. }
  7038. });
  7039. }));
  7040. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7041. pro.push(new Promise(resolve => {
  7042. $.ajax({
  7043. type: 'POST',
  7044. url: urlPath(promo.attr('href')),
  7045. timeout: 6e4,
  7046. dataType: 'json',
  7047. data: {
  7048. ajax: 't'
  7049. },
  7050. error(response, error, exception) {
  7051. console.log({
  7052. response: response,
  7053. error: error,
  7054. exception: exception
  7055. });
  7056. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7057. resolve(true);
  7058. },
  7059. success(response) {
  7060. console.log(response);
  7061. if (response.success) {
  7062. status.success(`Success:${response.text}`);
  7063. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7064. resolve(true);
  7065. } else {
  7066. status.error(`Error:${response.text}`);
  7067. resolve(true);
  7068. }
  7069. }
  7070. });
  7071. }));
  7072. } else {
  7073. status.error(`Error:${i18n('unKnownTaskType')}`);
  7074. }
  7075. }
  7076. }
  7077. await Promise.all(pro);
  7078. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7079. return true;
  7080. }
  7081. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7082. return false;
  7083. } catch (error) {
  7084. throwError(error, 'Indiedb.classifyTask');
  7085. return false;
  7086. }
  7087. }
  7088. function Indiedb_checkLogin2() {
  7089. try {
  7090. if (!globalOptions.other.checkLogin) {
  7091. return true;
  7092. }
  7093. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7094. window.open('/members/login', '_self');
  7095. }
  7096. return true;
  7097. } catch (error) {
  7098. throwError(error, 'Indiedb.checkLogin');
  7099. return false;
  7100. }
  7101. }
  7102. async function Indiedb_checkLeftKey2() {
  7103. try {
  7104. if (!globalOptions.other.checkLeftKey) {
  7105. return true;
  7106. }
  7107. if ($('a.buttonenter:contains("next time")').length > 0) {
  7108. await external_Swal_default().fire({
  7109. icon: 'warning',
  7110. title: i18n('notice'),
  7111. text: i18n('giveawayEnded'),
  7112. confirmButtonText: i18n('confirm'),
  7113. cancelButtonText: i18n('cancel'),
  7114. showCancelButton: true
  7115. }).then(_ref => {
  7116. let {
  7117. value
  7118. } = _ref;
  7119. if (value) {
  7120. window.close();
  7121. }
  7122. });
  7123. }
  7124. return true;
  7125. } catch (error) {
  7126. throwError(error, 'Indiedb.checkLeftKey');
  7127. return false;
  7128. }
  7129. }
  7130. const website_Indiedb = Indiedb;
  7131. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7132. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7133. privateSet.add(obj);
  7134. }
  7135. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7136. if (privateCollection.has(obj)) {
  7137. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7138. }
  7139. }
  7140. function Keyhub_defineProperty(obj, key, value) {
  7141. if (key in obj) {
  7142. Object.defineProperty(obj, key, {
  7143. value: value,
  7144. enumerable: true,
  7145. configurable: true,
  7146. writable: true
  7147. });
  7148. } else {
  7149. obj[key] = value;
  7150. }
  7151. return obj;
  7152. }
  7153. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7154. if (!privateSet.has(receiver)) {
  7155. throw new TypeError('attempted to get private field on non-instance');
  7156. }
  7157. return fn;
  7158. }
  7159. const Keyhub_defaultTasks = {
  7160. steam: {
  7161. groupLinks: [],
  7162. wishlistLinks: [],
  7163. curatorLinks: []
  7164. },
  7165. discord: {
  7166. serverLinks: []
  7167. },
  7168. links: []
  7169. };
  7170. var Keyhub_getGiveawayId = new WeakSet();
  7171. var Keyhub_checkLeftKey = new WeakSet();
  7172. var Keyhub_checkLogin = new WeakSet();
  7173. class Keyhub extends website_Website {
  7174. constructor() {
  7175. super(...arguments);
  7176. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7177. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7178. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7179. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7180. Keyhub_defineProperty(this, 'socialTasks', {
  7181. ...Keyhub_defaultTasks
  7182. });
  7183. Keyhub_defineProperty(this, 'undoneTasks', {
  7184. ...Keyhub_defaultTasks
  7185. });
  7186. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7187. }
  7188. static test() {
  7189. return window.location.host === 'key-hub.eu';
  7190. }
  7191. async after() {
  7192. try {
  7193. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7194. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7195. }
  7196. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7197. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7198. }
  7199. } catch (error) {
  7200. throwError(error, 'Keyhub.after');
  7201. }
  7202. }
  7203. init() {
  7204. try {
  7205. const logStatus = scripts_echoLog({
  7206. text: i18n('initing')
  7207. });
  7208. if ($('a[href*="/connect/steam"]').length > 0) {
  7209. window.open('/connect/steam', '_self');
  7210. logStatus.warning(i18n('needLogin'));
  7211. return false;
  7212. }
  7213. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7214. return false;
  7215. }
  7216. $('#VPNoverlay').hide();
  7217. $('#mainArticleSection').show();
  7218. this.initialized = true;
  7219. logStatus.success();
  7220. return true;
  7221. } catch (error) {
  7222. throwError(error, 'Keyhub.init');
  7223. return false;
  7224. }
  7225. }
  7226. async classifyTask(action) {
  7227. try {
  7228. const logStatus = scripts_echoLog({
  7229. text: i18n('getTasksInfo')
  7230. });
  7231. if (action === 'undo') {
  7232. var _GM_getValue;
  7233. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  7234. ...Keyhub_defaultTasks
  7235. };
  7236. }
  7237. const tasks = $('.task a');
  7238. for (const task of tasks) {
  7239. let link = $(task).attr('href');
  7240. const taskDes = $(task).text().trim();
  7241. if (!link) {
  7242. continue;
  7243. }
  7244. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7245. link = await getRedirectLink(link) || link;
  7246. }
  7247. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7248. window.open(link, '_blank');
  7249. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7250. if (action === 'undo') {
  7251. this.socialTasks.steam.groupLinks.push(link);
  7252. }
  7253. if (action === 'do') {
  7254. this.undoneTasks.steam.groupLinks.push(link);
  7255. }
  7256. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7257. if (action === 'undo') {
  7258. this.socialTasks.steam.wishlistLinks.push(link);
  7259. }
  7260. if (action === 'do') {
  7261. this.undoneTasks.steam.wishlistLinks.push(link);
  7262. }
  7263. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7264. if (action === 'undo') {
  7265. this.socialTasks.steam.curatorLinks.push(link);
  7266. }
  7267. if (action === 'do') {
  7268. this.undoneTasks.steam.curatorLinks.push(link);
  7269. }
  7270. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7271. if (action === 'undo') {
  7272. this.socialTasks.discord.serverLinks.push(link);
  7273. }
  7274. if (action === 'do') {
  7275. this.undoneTasks.discord.serverLinks.push(link);
  7276. }
  7277. } else {
  7278. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7279. }
  7280. }
  7281. logStatus.success();
  7282. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7283. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7284. GM_setValue(`khTasks-${this.giveawayId}`, {
  7285. tasks: this.socialTasks,
  7286. time: new Date().getTime()
  7287. });
  7288. return true;
  7289. } catch (error) {
  7290. throwError(error, 'Keyhub.classifyTask');
  7291. return false;
  7292. }
  7293. }
  7294. verifyTask() {
  7295. try {
  7296. scripts_echoLog({
  7297. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7298. });
  7299. $.get(window.location.href, res => {
  7300. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7301. });
  7302. } catch (error) {
  7303. throwError(error, 'keyhub.verifyTask');
  7304. }
  7305. }
  7306. }
  7307. function Keyhub_getGiveawayId2() {
  7308. try {
  7309. var _window$location$href;
  7310. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7311. if (giveawayId) {
  7312. this.giveawayId = giveawayId;
  7313. return true;
  7314. }
  7315. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7316. return false;
  7317. } catch (error) {
  7318. throwError(error, 'Keyhub.getGiveawayId');
  7319. return false;
  7320. }
  7321. }
  7322. async function Keyhub_checkLeftKey2() {
  7323. try {
  7324. if (!globalOptions.other.checkLeftKey) {
  7325. return true;
  7326. }
  7327. const leftKey = $('#keysleft').text().trim();
  7328. if (leftKey === '0') {
  7329. await external_Swal_default().fire({
  7330. icon: 'warning',
  7331. title: i18n('notice'),
  7332. text: i18n('noKeysLeft'),
  7333. confirmButtonText: i18n('confirm'),
  7334. cancelButtonText: i18n('cancel'),
  7335. showCancelButton: true
  7336. }).then(_ref => {
  7337. let {
  7338. value
  7339. } = _ref;
  7340. if (value) {
  7341. window.close();
  7342. }
  7343. });
  7344. }
  7345. return true;
  7346. } catch (error) {
  7347. throwError(error, 'Keyhub.checkLeftKey');
  7348. return false;
  7349. }
  7350. }
  7351. function Keyhub_checkLogin2() {
  7352. try {
  7353. if (!globalOptions.other.checkLogin) {
  7354. return true;
  7355. }
  7356. if ($('a[href*="/connect/steam"]').length > 0) {
  7357. window.open('/connect/steam', '_self');
  7358. }
  7359. return true;
  7360. } catch (error) {
  7361. throwError(error, 'Keyhub.checkLogin');
  7362. return false;
  7363. }
  7364. }
  7365. const website_Keyhub = Keyhub;
  7366. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7367. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7368. privateSet.add(obj);
  7369. }
  7370. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7371. if (privateCollection.has(obj)) {
  7372. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7373. }
  7374. }
  7375. function Givekey_defineProperty(obj, key, value) {
  7376. if (key in obj) {
  7377. Object.defineProperty(obj, key, {
  7378. value: value,
  7379. enumerable: true,
  7380. configurable: true,
  7381. writable: true
  7382. });
  7383. } else {
  7384. obj[key] = value;
  7385. }
  7386. return obj;
  7387. }
  7388. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7389. if (!privateSet.has(receiver)) {
  7390. throw new TypeError('attempted to get private field on non-instance');
  7391. }
  7392. return fn;
  7393. }
  7394. const Givekey_defaultTasks = {
  7395. steam: {
  7396. groupLinks: [],
  7397. wishlistLinks: [],
  7398. curatorLinks: [],
  7399. curatorLikeLinks: []
  7400. },
  7401. twitter: {
  7402. userLinks: []
  7403. },
  7404. vk: {
  7405. nameLinks: []
  7406. },
  7407. discord: {
  7408. serverLinks: []
  7409. }
  7410. };
  7411. var Givekey_verify = new WeakSet();
  7412. var Givekey_getGiveawayId = new WeakSet();
  7413. var Givekey_checkLeftKey = new WeakSet();
  7414. class Givekey extends website_Website {
  7415. constructor() {
  7416. super(...arguments);
  7417. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7418. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7419. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7420. Givekey_defineProperty(this, 'name', 'Givekey');
  7421. Givekey_defineProperty(this, 'tasks', []);
  7422. Givekey_defineProperty(this, 'socialTasks', {
  7423. ...Givekey_defaultTasks
  7424. });
  7425. Givekey_defineProperty(this, 'undoneTasks', {
  7426. ...Givekey_defaultTasks
  7427. });
  7428. Givekey_defineProperty(this, 'userId', void 0);
  7429. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7430. }
  7431. static test() {
  7432. return window.location.host === 'givekey.ru';
  7433. }
  7434. async after() {
  7435. try {
  7436. await new Promise(resolve => {
  7437. const checker = setInterval(() => {
  7438. if ($('#navbarDropdown').length > 0) {
  7439. clearInterval(checker);
  7440. resolve(true);
  7441. }
  7442. });
  7443. });
  7444. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7445. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7446. }
  7447. } catch (error) {
  7448. throwError(error, 'Givekey.after');
  7449. return false;
  7450. }
  7451. }
  7452. init() {
  7453. try {
  7454. const logStatus = scripts_echoLog({
  7455. text: i18n('initing')
  7456. });
  7457. if ($('a[href*="/auth/steam"]').length > 0) {
  7458. window.open('/auth/steam', '_self');
  7459. logStatus.warning(i18n('needLogin'));
  7460. return false;
  7461. }
  7462. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7463. return false;
  7464. }
  7465. const userId = $('meta[name="user-id"]').attr('content');
  7466. if (!userId) {
  7467. logStatus.error(i18n('getFailed', i18n('userId')));
  7468. return false;
  7469. }
  7470. this.userId = userId;
  7471. this.initialized = true;
  7472. logStatus.success();
  7473. return true;
  7474. } catch (error) {
  7475. throwError(error, 'Givekey.init');
  7476. return false;
  7477. }
  7478. }
  7479. async classifyTask(action) {
  7480. try {
  7481. const logStatus = scripts_echoLog({
  7482. text: i18n('getTasksInfo')
  7483. });
  7484. if (action === 'undo') {
  7485. var _GM_getValue;
  7486. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || Givekey_defaultTasks;
  7487. }
  7488. const tasks = $('.card-body:has("button") .row');
  7489. for (const task of tasks) {
  7490. const taskEle = $(task);
  7491. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7492. if (isSuccess && action !== 'undo') {
  7493. continue;
  7494. }
  7495. const checkButton = taskEle.find('#task_check');
  7496. const taskId = checkButton.attr('data-id');
  7497. if (taskId) {
  7498. this.tasks.push(taskId);
  7499. }
  7500. if (action === 'verify') {
  7501. continue;
  7502. }
  7503. let href = taskEle.find('a').attr('href') || null;
  7504. const text = taskEle.find('a').text().trim();
  7505. const icon = taskEle.find('i');
  7506. if (!href || !text) {
  7507. continue;
  7508. }
  7509. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7510. href = await getRedirectLink(href);
  7511. }
  7512. if (!href) {
  7513. continue;
  7514. }
  7515. if (/^https?:\/\/vk\.com\//.test(href)) {
  7516. this.socialTasks.vk.nameLinks.push(href);
  7517. if (action === 'do' && !isSuccess) {
  7518. this.undoneTasks.vk.nameLinks.push(href);
  7519. }
  7520. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7521. this.socialTasks.steam.groupLinks.push(href);
  7522. if (action === 'do' && !isSuccess) {
  7523. this.undoneTasks.steam.groupLinks.push(href);
  7524. }
  7525. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7526. this.socialTasks.steam.wishlistLinks.push(href);
  7527. if (action === 'do' && !isSuccess) {
  7528. this.undoneTasks.steam.wishlistLinks.push(href);
  7529. }
  7530. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7531. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7532. this.socialTasks.steam.curatorLinks.push(href);
  7533. if (action === 'do' && !isSuccess) {
  7534. this.undoneTasks.steam.curatorLinks.push(href);
  7535. }
  7536. } else {
  7537. this.socialTasks.steam.curatorLikeLinks.push(href);
  7538. if (action === 'do' && !isSuccess) {
  7539. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7540. }
  7541. }
  7542. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7543. this.socialTasks.twitter.userLinks.push(href);
  7544. if (action === 'do' && !isSuccess) {
  7545. this.undoneTasks.twitter.userLinks.push(href);
  7546. }
  7547. } else if (icon.hasClass('fa-discord')) {
  7548. this.socialTasks.discord.serverLinks.push(href);
  7549. if (action === 'do' && !isSuccess) {
  7550. this.undoneTasks.discord.serverLinks.push(href);
  7551. }
  7552. } else {
  7553. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7554. }
  7555. }
  7556. logStatus.success();
  7557. this.tasks = unique(this.tasks);
  7558. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7559. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7560. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7561. tasks: this.socialTasks,
  7562. time: new Date().getTime()
  7563. });
  7564. return true;
  7565. } catch (error) {
  7566. throwError(error, 'Givekey.classifyTask');
  7567. return false;
  7568. }
  7569. }
  7570. async verifyTask() {
  7571. try {
  7572. if (!this.initialized && !this.init()) {
  7573. return false;
  7574. }
  7575. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7576. return false;
  7577. }
  7578. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7579. const taskLength = this.tasks.length;
  7580. for (let i = 0; i < taskLength; i++) {
  7581. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7582. if (i < taskLength - 1) {
  7583. await delay(15e3);
  7584. }
  7585. }
  7586. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7587. scripts_echoLog({}).warning(i18n('giveKeyNoticeAfter'));
  7588. return true;
  7589. } catch (error) {
  7590. throwError(error, 'Givekey.verifyTask');
  7591. return false;
  7592. }
  7593. }
  7594. }
  7595. async function Givekey_verify2(task) {
  7596. try {
  7597. const logStatus = scripts_echoLog({
  7598. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7599. });
  7600. return await new Promise(resolve => {
  7601. $.ajax({
  7602. url: 'https://givekey.ru/giveaway/task',
  7603. method: 'POST',
  7604. data: `id=${task}&user_id=${this.userId}`,
  7605. dataType: 'json',
  7606. headers: {
  7607. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7608. },
  7609. success: data => {
  7610. if (data.btn) {
  7611. $(`button[data-id=${this.userId}]`).html(data.btn);
  7612. }
  7613. if (data.status === 'ok') {
  7614. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7615. logStatus.success();
  7616. resolve(true);
  7617. } else if (data.status === 'end') {
  7618. logStatus.success();
  7619. scripts_echoLog({}).success(data.key);
  7620. resolve(true);
  7621. } else {
  7622. logStatus.error(`Error:${data.msg}`);
  7623. resolve(false);
  7624. }
  7625. },
  7626. error: xhr => {
  7627. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7628. resolve(false);
  7629. }
  7630. });
  7631. });
  7632. } catch (error) {
  7633. throwError(error, 'Givekey.verify');
  7634. return false;
  7635. }
  7636. }
  7637. function Givekey_getGiveawayId2() {
  7638. try {
  7639. var _window$location$href;
  7640. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7641. if (giveawayId) {
  7642. this.giveawayId = giveawayId;
  7643. return true;
  7644. }
  7645. scripts_echoLog({
  7646. text: i18n('getFailed', 'GiveawayId')
  7647. });
  7648. return false;
  7649. } catch (error) {
  7650. throwError(error, 'Givekey.getGiveawayId');
  7651. return false;
  7652. }
  7653. }
  7654. async function Givekey_checkLeftKey2() {
  7655. try {
  7656. if (!globalOptions.other.checkLeftKey) {
  7657. return true;
  7658. }
  7659. if (!$('#keys_count').text()) {
  7660. await external_Swal_default().fire({
  7661. icon: 'warning',
  7662. title: i18n('notice'),
  7663. text: i18n('noKeysLeft'),
  7664. confirmButtonText: i18n('confirm'),
  7665. cancelButtonText: i18n('cancel'),
  7666. showCancelButton: true
  7667. }).then(_ref => {
  7668. let {
  7669. value
  7670. } = _ref;
  7671. if (value) {
  7672. window.close();
  7673. }
  7674. });
  7675. }
  7676. return true;
  7677. } catch (error) {
  7678. throwError(error, 'Givekey.checkLeftKey');
  7679. return false;
  7680. }
  7681. }
  7682. const website_Givekey = Givekey;
  7683. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7684. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7685. privateSet.add(obj);
  7686. }
  7687. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7688. if (privateCollection.has(obj)) {
  7689. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7690. }
  7691. }
  7692. function GiveeClub_defineProperty(obj, key, value) {
  7693. if (key in obj) {
  7694. Object.defineProperty(obj, key, {
  7695. value: value,
  7696. enumerable: true,
  7697. configurable: true,
  7698. writable: true
  7699. });
  7700. } else {
  7701. obj[key] = value;
  7702. }
  7703. return obj;
  7704. }
  7705. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7706. if (!privateSet.has(receiver)) {
  7707. throw new TypeError('attempted to get private field on non-instance');
  7708. }
  7709. return fn;
  7710. }
  7711. var GiveeClub_checkLogin = new WeakSet();
  7712. var GiveeClub_getGiveawayId = new WeakSet();
  7713. var GiveeClub_checkLeftKey = new WeakSet();
  7714. class GiveeClub extends GiveawaySu {
  7715. constructor() {
  7716. super(...arguments);
  7717. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7718. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7719. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7720. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7721. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7722. }
  7723. static test() {
  7724. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7725. }
  7726. async after() {
  7727. try {
  7728. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7729. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7730. }
  7731. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7732. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7733. }
  7734. } catch (error) {
  7735. throwError(error, 'GiveeClub.after');
  7736. }
  7737. }
  7738. init() {
  7739. try {
  7740. const logStatus = scripts_echoLog({
  7741. text: i18n('initing')
  7742. });
  7743. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7744. logStatus.warning(i18n('needLogin'));
  7745. return false;
  7746. }
  7747. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7748. return false;
  7749. }
  7750. this.initialized = true;
  7751. logStatus.success();
  7752. return true;
  7753. } catch (error) {
  7754. throwError(error, 'GiveeClub.init');
  7755. return false;
  7756. }
  7757. }
  7758. async classifyTask(action) {
  7759. try {
  7760. const logStatus = scripts_echoLog({
  7761. text: i18n('getTasksInfo')
  7762. });
  7763. if (action === 'undo') {
  7764. var _GM_getValue;
  7765. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7766. return true;
  7767. }
  7768. const pro = [];
  7769. const tasks = $('.event-actions tr');
  7770. for (const task of tasks) {
  7771. pro.push(new Promise(resolve => {
  7772. const taskDes = $(task).find('.event-action-label a');
  7773. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7774. const taskName = taskDes.text().trim();
  7775. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7776. return resolve(true);
  7777. }
  7778. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7779. if (!taskLink) {
  7780. return resolve(false);
  7781. }
  7782. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7783. this.undoneTasks.steam.groupLinks.push(taskLink);
  7784. } else if (/like.*announcement/gi.test(taskName)) {
  7785. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7786. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7787. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7788. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7789. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7790. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7791. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7792. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7793. this.undoneTasks.steam.forumLinks.push(taskLink);
  7794. } else if (taskIcon.includes('discord')) {
  7795. this.undoneTasks.discord.serverLinks.push(taskLink);
  7796. } else if (taskIcon.includes('instagram')) {
  7797. this.undoneTasks.instagram.userLinks.push(taskLink);
  7798. } else if (taskIcon.includes('twitch')) {
  7799. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7800. } else if (taskIcon.includes('reddit')) {
  7801. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7802. } else if (/watch.*art/gim.test(taskName)) {
  7803. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7804. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7805. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7806. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7807. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7808. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7809. this.undoneTasks.vk.nameLinks.push(taskLink);
  7810. } else {
  7811. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7812. if (/follow.*button/gim.test(taskName)) {
  7813. this.undoneTasks.steam.followLinks.push(taskLink);
  7814. }
  7815. }
  7816. }
  7817. resolve(true);
  7818. }).catch(error => {
  7819. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7820. return false;
  7821. });
  7822. }));
  7823. }
  7824. await Promise.all(pro);
  7825. logStatus.success();
  7826. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7827. this.socialTasks = this.undoneTasks;
  7828. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7829. tasks: this.socialTasks,
  7830. time: new Date().getTime()
  7831. });
  7832. return true;
  7833. } catch (error) {
  7834. throwError(error, 'GiveeClub.classifyTask');
  7835. return false;
  7836. }
  7837. }
  7838. }
  7839. function GiveeClub_checkLogin2() {
  7840. try {
  7841. if (!globalOptions.other.checkLogin) {
  7842. return true;
  7843. }
  7844. if ($('a[href*="/account/auth"]').length > 0) {
  7845. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7846. }
  7847. return true;
  7848. } catch (error) {
  7849. throwError(error, 'GiveeClub.checkLogin');
  7850. return false;
  7851. }
  7852. }
  7853. function GiveeClub_getGiveawayId2() {
  7854. var _window$location$href;
  7855. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7856. if (giveawayId) {
  7857. this.giveawayId = giveawayId;
  7858. return true;
  7859. }
  7860. scripts_echoLog({
  7861. text: i18n('getFailed', 'GiveawayId')
  7862. });
  7863. return false;
  7864. }
  7865. async function GiveeClub_checkLeftKey2() {
  7866. try {
  7867. if (!globalOptions.other.checkLeftKey) {
  7868. return true;
  7869. }
  7870. if ($('.event-ended').length > 0) {
  7871. await external_Swal_default().fire({
  7872. icon: 'warning',
  7873. title: i18n('notice'),
  7874. text: i18n('giveawayEnded'),
  7875. confirmButtonText: i18n('confirm'),
  7876. cancelButtonText: i18n('cancel'),
  7877. showCancelButton: true
  7878. }).then(_ref => {
  7879. let {
  7880. value
  7881. } = _ref;
  7882. if (value) {
  7883. window.close();
  7884. }
  7885. });
  7886. }
  7887. return true;
  7888. } catch (error) {
  7889. throwError(error, 'Giveawaysu.checkLeftKey');
  7890. return false;
  7891. }
  7892. }
  7893. const website_GiveeClub = GiveeClub;
  7894. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  7895. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  7896. privateSet.add(obj);
  7897. }
  7898. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  7899. if (privateCollection.has(obj)) {
  7900. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7901. }
  7902. }
  7903. function OpiumPulses_defineProperty(obj, key, value) {
  7904. if (key in obj) {
  7905. Object.defineProperty(obj, key, {
  7906. value: value,
  7907. enumerable: true,
  7908. configurable: true,
  7909. writable: true
  7910. });
  7911. } else {
  7912. obj[key] = value;
  7913. }
  7914. return obj;
  7915. }
  7916. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  7917. if (!privateSet.has(receiver)) {
  7918. throw new TypeError('attempted to get private field on non-instance');
  7919. }
  7920. return fn;
  7921. }
  7922. const defaultOptions = {
  7923. maxPoint: '99999999'
  7924. };
  7925. var _toggleTask = new WeakSet();
  7926. var OpiumPulses_checkLogin = new WeakSet();
  7927. class OpiumPulses {
  7928. constructor() {
  7929. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  7930. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  7931. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  7932. OpiumPulses_defineProperty(this, 'options', {
  7933. ...defaultOptions,
  7934. ...GM_getValue('OpiumPulsesOptions')
  7935. });
  7936. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  7937. OpiumPulses_defineProperty(this, 'myPoints', 0);
  7938. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  7939. }
  7940. static test() {
  7941. return window.location.host === 'www.opiumpulses.com';
  7942. }
  7943. async after() {
  7944. try {
  7945. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  7946. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7947. }
  7948. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7949. } catch (error) {
  7950. throwError(error, 'OpiumPulses.after');
  7951. }
  7952. }
  7953. async doFreeTask() {
  7954. try {
  7955. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  7956. } catch (error) {
  7957. throwError(error, 'OpiumPulses.doFreeTask');
  7958. }
  7959. }
  7960. async doPointTask() {
  7961. try {
  7962. var _$$text$match;
  7963. 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);
  7964. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  7965. } catch (error) {
  7966. throwError(error, 'OpiumPulses.doPointTask');
  7967. }
  7968. }
  7969. init() {
  7970. return true;
  7971. }
  7972. classifyTask() {
  7973. return true;
  7974. }
  7975. }
  7976. async function _toggleTask2(type) {
  7977. try {
  7978. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7979. for (const item of items) {
  7980. var _$$find$text$match;
  7981. 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);
  7982. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7983. if (type === 'points' && needPoints > this.myPoints) {
  7984. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7985. } else if (type === 'points' && !needPoints) {
  7986. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  7987. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  7988. var _aElement$attr;
  7989. const logStatus = scripts_echoLog({
  7990. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  7991. });
  7992. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  7993. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  7994. var _aElement$attr2, _aElement$attr2$match;
  7995. 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];
  7996. if (giveawayId) {
  7997. checkUser(giveawayId);
  7998. }
  7999. }
  8000. if (!aElement.attr('href')) {
  8001. logStatus.error('Error: No "href".');
  8002. continue;
  8003. }
  8004. const {
  8005. result,
  8006. statusText,
  8007. status,
  8008. data
  8009. } = await tools_httpRequest({
  8010. url: aElement.attr('href'),
  8011. method: 'GET'
  8012. });
  8013. if (result === 'Success') {
  8014. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8015. var _data$responseText$ma;
  8016. logStatus.success();
  8017. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8018. if (type === 'points' && points) {
  8019. this.myPoints = parseInt(points, 10);
  8020. }
  8021. } else {
  8022. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8023. }
  8024. } else {
  8025. logStatus.error(`${result}:${statusText}(${status})`);
  8026. }
  8027. }
  8028. }
  8029. scripts_echoLog({
  8030. text: '-----END-----'
  8031. });
  8032. } catch (error) {
  8033. throwError(error, 'OpiumPulses.toggleTask');
  8034. }
  8035. }
  8036. function OpiumPulses_checkLogin2() {
  8037. try {
  8038. if (!globalOptions.other.checkLogin) {
  8039. return true;
  8040. }
  8041. if ($('a[href*="/site/login"]').length > 1) {
  8042. window.open('/site/login', '_self');
  8043. }
  8044. return true;
  8045. } catch (error) {
  8046. throwError(error, 'OpiumPulses.checkLogin');
  8047. return false;
  8048. }
  8049. }
  8050. const website_OpiumPulses = OpiumPulses;
  8051. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8052. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8053. privateSet.add(obj);
  8054. }
  8055. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8056. if (privateCollection.has(obj)) {
  8057. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8058. }
  8059. }
  8060. function Keylol_defineProperty(obj, key, value) {
  8061. if (key in obj) {
  8062. Object.defineProperty(obj, key, {
  8063. value: value,
  8064. enumerable: true,
  8065. configurable: true,
  8066. writable: true
  8067. });
  8068. } else {
  8069. obj[key] = value;
  8070. }
  8071. return obj;
  8072. }
  8073. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8074. if (!privateSet.has(receiver)) {
  8075. throw new TypeError('attempted to get private field on non-instance');
  8076. }
  8077. return fn;
  8078. }
  8079. const Keylol_defaultTasks = {
  8080. steam: {
  8081. groupLinks: [],
  8082. wishlistLinks: [],
  8083. curatorLinks: [],
  8084. curatorLikeLinks: [],
  8085. followLinks: [],
  8086. forumLinks: [],
  8087. announcementLinks: [],
  8088. workshopVoteLinks: []
  8089. },
  8090. discord: {
  8091. serverLinks: []
  8092. },
  8093. instagram: {
  8094. userLinks: []
  8095. },
  8096. vk: {
  8097. nameLinks: []
  8098. },
  8099. twitch: {
  8100. channelLinks: []
  8101. },
  8102. reddit: {
  8103. redditLinks: []
  8104. },
  8105. twitter: {
  8106. userLinks: [],
  8107. retweetLinks: []
  8108. },
  8109. youtube: {
  8110. channelLinks: [],
  8111. likeLinks: []
  8112. }
  8113. };
  8114. var _addBtn = new WeakSet();
  8115. class Keylol extends website_Website {
  8116. constructor() {
  8117. super(...arguments);
  8118. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8119. Keylol_defineProperty(this, 'name', 'Keylol');
  8120. Keylol_defineProperty(this, 'socialTasks', {
  8121. ...Keylol_defaultTasks
  8122. });
  8123. Keylol_defineProperty(this, 'undoneTasks', {
  8124. ...Keylol_defaultTasks
  8125. });
  8126. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8127. }
  8128. static test() {
  8129. var _$$eq$attr;
  8130. 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'));
  8131. }
  8132. init() {
  8133. return true;
  8134. }
  8135. after() {
  8136. try {
  8137. const selecter = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8138. const mainPost = $(selecter);
  8139. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8140. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8141. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8142. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8143. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8144. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8145. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8146. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8147. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8148. if (discordLinks.length > 0) {
  8149. for (const discordLink of discordLinks) {
  8150. const link = $(discordLink).attr('href');
  8151. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8152. continue;
  8153. }
  8154. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8155. }
  8156. }
  8157. if (redditLinks.length > 0) {
  8158. for (const redditLink of redditLinks) {
  8159. const link = $(redditLink).attr('href');
  8160. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8161. continue;
  8162. }
  8163. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8164. }
  8165. }
  8166. if (insLinks.length > 0) {
  8167. for (const insLink of insLinks) {
  8168. const link = $(insLink).attr('href');
  8169. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8170. continue;
  8171. }
  8172. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8173. }
  8174. }
  8175. if (twitterLinks.length > 0) {
  8176. for (const twitterLink of twitterLinks) {
  8177. const link = $(twitterLink).attr('href');
  8178. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8179. continue;
  8180. }
  8181. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8182. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8183. } else {
  8184. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8185. }
  8186. }
  8187. }
  8188. if (twitchLinks.length > 0) {
  8189. for (const twitchLink of twitchLinks) {
  8190. const link = $(twitchLink).attr('href');
  8191. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8192. continue;
  8193. }
  8194. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8195. }
  8196. }
  8197. if (vkLinks.length > 0) {
  8198. for (const vkLink of vkLinks) {
  8199. const link = $(vkLink).attr('href');
  8200. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8201. continue;
  8202. }
  8203. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8204. }
  8205. }
  8206. if (steamStoreLinks.length > 0) {
  8207. for (const steamStoreLink of steamStoreLinks) {
  8208. const link = $(steamStoreLink).attr('href');
  8209. if (!link) {
  8210. continue;
  8211. }
  8212. if (/app\/[\d]+/.test(link)) {
  8213. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8214. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8215. } else if (/curator\/[\d]+/.test(link)) {
  8216. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8217. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8218. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8219. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8220. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8221. }
  8222. }
  8223. }
  8224. if (steamCommunityLinks.length > 0) {
  8225. for (const steamCommunityLink of steamCommunityLinks) {
  8226. const link = $(steamCommunityLink).attr('href');
  8227. if (!link) {
  8228. continue;
  8229. }
  8230. if (/groups\/.+/.test(link)) {
  8231. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8232. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8233. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8234. }
  8235. }
  8236. }
  8237. if (ytbLinks.length > 0) {
  8238. for (const ytbLink of ytbLinks) {
  8239. const link = $(ytbLink).attr('href');
  8240. if (!link) {
  8241. continue;
  8242. }
  8243. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8244. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8245. }
  8246. }
  8247. } catch (error) {
  8248. throwError(error, 'keylol.after');
  8249. }
  8250. }
  8251. classifyTask(action) {
  8252. try {
  8253. this.socialTasks = {
  8254. ...Keylol_defaultTasks
  8255. };
  8256. this.undoneTasks = {
  8257. ...Keylol_defaultTasks
  8258. };
  8259. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8260. for (const btn of selectedBtns) {
  8261. const button = $(btn);
  8262. const social = button.attr('data-social');
  8263. const type = button.attr('data-type');
  8264. const link = button.attr('data-link');
  8265. if (!(social && type && link)) {
  8266. continue;
  8267. }
  8268. if (action === 'do') {
  8269. this.undoneTasks[social][type].push(link);
  8270. }
  8271. if (action === 'undo') {
  8272. this.socialTasks[social][type].push(link);
  8273. }
  8274. }
  8275. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8276. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8277. return true;
  8278. } catch (error) {
  8279. throwError(error, 'Keylol.classifyTask');
  8280. return false;
  8281. }
  8282. }
  8283. selectAll() {
  8284. try {
  8285. $('.auto-task-keylol').attr('selected', 'selected');
  8286. } catch (error) {
  8287. throwError(error, 'Keylol.selectAll');
  8288. }
  8289. }
  8290. selectNone() {
  8291. try {
  8292. $('.auto-task-keylol').removeAttr('selected');
  8293. } catch (error) {
  8294. throwError(error, 'Keylol.selectNone');
  8295. }
  8296. }
  8297. invertSelect() {
  8298. try {
  8299. $('.auto-task-keylol').each((index, element) => {
  8300. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8301. });
  8302. } catch (error) {
  8303. throwError(error, 'Keylol.invertSelect');
  8304. }
  8305. }
  8306. }
  8307. function _addBtn2(before, social, linkType, link) {
  8308. try {
  8309. $(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>`);
  8310. } catch (error) {
  8311. throwError(error, 'keylol.addBtn');
  8312. }
  8313. }
  8314. const website_Keylol = Keylol;
  8315. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8316. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8317. privateSet.add(obj);
  8318. }
  8319. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8320. if (privateCollection.has(obj)) {
  8321. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8322. }
  8323. }
  8324. function Opquests_defineProperty(obj, key, value) {
  8325. if (key in obj) {
  8326. Object.defineProperty(obj, key, {
  8327. value: value,
  8328. enumerable: true,
  8329. configurable: true,
  8330. writable: true
  8331. });
  8332. } else {
  8333. obj[key] = value;
  8334. }
  8335. return obj;
  8336. }
  8337. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8338. if (!privateSet.has(receiver)) {
  8339. throw new TypeError('attempted to get private field on non-instance');
  8340. }
  8341. return fn;
  8342. }
  8343. const Opquests_defaultTasks = {
  8344. steam: {
  8345. groupLinks: [],
  8346. wishlistLinks: [],
  8347. followLinks: [],
  8348. curatorLikeLinks: []
  8349. }
  8350. };
  8351. var Opquests_getGiveawayId = new WeakSet();
  8352. var Opquests_checkLogin = new WeakSet();
  8353. class Opquests extends website_Website {
  8354. constructor() {
  8355. super(...arguments);
  8356. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8357. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8358. Opquests_defineProperty(this, 'name', 'Opquests');
  8359. Opquests_defineProperty(this, 'undoneTasks', {
  8360. ...Opquests_defaultTasks
  8361. });
  8362. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8363. }
  8364. static test() {
  8365. return window.location.host === 'opquests.com';
  8366. }
  8367. async after() {
  8368. try {
  8369. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8370. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8371. }
  8372. } catch (error) {
  8373. throwError(error, 'Opquests.after');
  8374. }
  8375. }
  8376. init() {
  8377. try {
  8378. const logStatus = scripts_echoLog({
  8379. text: i18n('initing')
  8380. });
  8381. if ($('a[href*="/auth/redirect"]').length > 0) {
  8382. window.open('/auth/redirect', '_self');
  8383. logStatus.warning(i18n('needLogin'));
  8384. return false;
  8385. }
  8386. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8387. return false;
  8388. }
  8389. this.initialized = true;
  8390. logStatus.success();
  8391. return true;
  8392. } catch (error) {
  8393. throwError(error, 'Opquests.init');
  8394. return false;
  8395. }
  8396. }
  8397. async classifyTask(action) {
  8398. try {
  8399. if (action === 'undo') {
  8400. scripts_echoLog({
  8401. text: i18n('cannotUndo')
  8402. });
  8403. return false;
  8404. }
  8405. const logStatus = scripts_echoLog({
  8406. text: i18n('getTasksInfo')
  8407. });
  8408. const tasks = $('.w-full:contains("Validate") .items-center');
  8409. for (const task of tasks) {
  8410. const link = $(task).find('a:contains("Open")').attr('href');
  8411. const taskDes = $(task).find('div').eq(1).text().trim();
  8412. if (!link) {
  8413. continue;
  8414. }
  8415. if (/steamcommunity\.com\/groups\//.test(link)) {
  8416. this.undoneTasks.steam.groupLinks.push(link);
  8417. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8418. if (/wishlist/gim.test(taskDes)) {
  8419. this.undoneTasks.steam.wishlistLinks.push(link);
  8420. } else if (/follow/gim.test(taskDes)) {
  8421. this.undoneTasks.steam.followLinks.push(link);
  8422. }
  8423. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8424. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8425. } else {
  8426. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8427. }
  8428. }
  8429. logStatus.success();
  8430. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8431. return true;
  8432. } catch (error) {
  8433. throwError(error, 'Opquests.classifyTask');
  8434. return false;
  8435. }
  8436. }
  8437. }
  8438. function Opquests_getGiveawayId2() {
  8439. try {
  8440. var _window$location$href;
  8441. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8442. if (giveawayId) {
  8443. this.giveawayId = giveawayId;
  8444. return true;
  8445. }
  8446. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8447. return false;
  8448. } catch (error) {
  8449. throwError(error, 'Opquests.getGiveawayId');
  8450. return false;
  8451. }
  8452. }
  8453. function Opquests_checkLogin2() {
  8454. try {
  8455. if (!globalOptions.other.checkLogin) {
  8456. return true;
  8457. }
  8458. if ($('a[href*="/auth/redirect"]').length > 0) {
  8459. window.open('/auth/redirect', '_self');
  8460. }
  8461. return true;
  8462. } catch (error) {
  8463. throwError(error, 'Opquests.checkLogin');
  8464. return false;
  8465. }
  8466. }
  8467. const website_Opquests = Opquests;
  8468. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8469. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8470. privateSet.add(obj);
  8471. }
  8472. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8473. if (privateCollection.has(obj)) {
  8474. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8475. }
  8476. }
  8477. function Gleam_defineProperty(obj, key, value) {
  8478. if (key in obj) {
  8479. Object.defineProperty(obj, key, {
  8480. value: value,
  8481. enumerable: true,
  8482. configurable: true,
  8483. writable: true
  8484. });
  8485. } else {
  8486. obj[key] = value;
  8487. }
  8488. return obj;
  8489. }
  8490. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8491. if (!privateSet.has(receiver)) {
  8492. throw new TypeError('attempted to get private field on non-instance');
  8493. }
  8494. return fn;
  8495. }
  8496. const Gleam_defaultTasks = {
  8497. steam: {
  8498. groupLinks: [],
  8499. wishlistLinks: [],
  8500. followLinks: [],
  8501. curatorLinks: [],
  8502. curatorLikeLinks: []
  8503. },
  8504. twitter: {
  8505. userLinks: [],
  8506. retweetLinks: []
  8507. },
  8508. twitch: {
  8509. channelLinks: []
  8510. },
  8511. discord: {
  8512. serverLinks: []
  8513. },
  8514. youtube: {
  8515. channelLinks: []
  8516. },
  8517. extra: {
  8518. gleam: []
  8519. }
  8520. };
  8521. const Gleam_defaultOptions = {
  8522. vlootUsername: '',
  8523. gameroundUsername: ''
  8524. };
  8525. var _checkSync = new WeakSet();
  8526. var _doGleamTask = new WeakSet();
  8527. var Gleam_getGiveawayId = new WeakSet();
  8528. var _getGleamLink = new WeakSet();
  8529. var Gleam_checkLeftKey = new WeakSet();
  8530. class Gleam extends website_Website {
  8531. constructor() {
  8532. super(...arguments);
  8533. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8534. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8535. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8536. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8537. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8538. Gleam_defineProperty(this, 'name', 'Gleam');
  8539. Gleam_defineProperty(this, 'undoneTasks', {
  8540. ...Gleam_defaultTasks
  8541. });
  8542. Gleam_defineProperty(this, 'socialTasks', {
  8543. ...Gleam_defaultTasks
  8544. });
  8545. Gleam_defineProperty(this, 'options', {
  8546. ...Gleam_defaultOptions,
  8547. ...GM_getValue('GleamOptions')
  8548. });
  8549. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8550. }
  8551. static test() {
  8552. return window.location.host === 'gleam.io';
  8553. }
  8554. async after() {
  8555. try {
  8556. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8557. const checkComplete = setInterval(() => {
  8558. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8559. clearInterval(checkComplete);
  8560. window.close();
  8561. }
  8562. });
  8563. for (const task of $('.entry-content .entry-method')) {
  8564. const taskInfo = $(task).find('.user-links');
  8565. const expandInfo = $(task).find('.expandable');
  8566. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8567. if (aElements.length > 0) {
  8568. for (const element of aElements) {
  8569. const $element = $(element);
  8570. const href = $element.attr('href');
  8571. $element.removeAttr('href')[0].click();
  8572. $element.attr('href', href);
  8573. await delay(1e3);
  8574. }
  8575. }
  8576. taskInfo[0].click();
  8577. await delay(1e3);
  8578. }
  8579. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8580. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8581. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8582. }
  8583. } catch (error) {
  8584. throwError(error, 'Gleam.after');
  8585. return false;
  8586. }
  8587. }
  8588. init() {
  8589. try {
  8590. const logStatus = scripts_echoLog({
  8591. text: i18n('initing')
  8592. });
  8593. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  8594. return false;
  8595. }
  8596. this.initialized = true;
  8597. logStatus.success();
  8598. return true;
  8599. } catch (error) {
  8600. throwError(error, 'Gleam.init');
  8601. return false;
  8602. }
  8603. }
  8604. async classifyTask(action) {
  8605. try {
  8606. const logStatus = scripts_echoLog({
  8607. text: i18n('getTasksInfo')
  8608. });
  8609. if (action === 'undo') {
  8610. var _GM_getValue;
  8611. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  8612. ...Gleam_defaultTasks
  8613. };
  8614. }
  8615. const tasks = $('.entry-content .entry-method');
  8616. for (const task of tasks) {
  8617. var _socialIcon$attr;
  8618. const $task = $(task);
  8619. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8620. continue;
  8621. }
  8622. const socialIcon = $task.find('.icon-wrapper i');
  8623. const taskInfo = $task.find('.user-links');
  8624. const taskText = taskInfo.text().trim();
  8625. const expandInfo = $task.find('.expandable');
  8626. const aElements = expandInfo.find('a.btn');
  8627. if (aElements.length > 0) {
  8628. for (const element of aElements) {
  8629. const $element = $(element);
  8630. const href = $element.attr('href');
  8631. $element.removeAttr('href')[0].click();
  8632. $element.attr('href', href);
  8633. }
  8634. }
  8635. if (socialIcon.hasClass('fa-twitter')) {
  8636. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8637. if (!link) {
  8638. continue;
  8639. }
  8640. if (/follow/gi.test(taskText)) {
  8641. if (action === 'undo') {
  8642. this.socialTasks.twitter.userLinks.push(link);
  8643. }
  8644. if (action === 'do') {
  8645. this.undoneTasks.twitter.userLinks.push(link);
  8646. }
  8647. } else if (/retweet/gim.test(taskText)) {
  8648. if (action === 'undo') {
  8649. this.socialTasks.twitter.retweetLinks.push(link);
  8650. }
  8651. if (action === 'do') {
  8652. this.undoneTasks.twitter.retweetLinks.push(link);
  8653. }
  8654. }
  8655. } else if (socialIcon.hasClass('fa-twitch')) {
  8656. if (/follow/gim.test(taskText)) {
  8657. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8658. if (!link) {
  8659. continue;
  8660. }
  8661. if (action === 'undo') {
  8662. this.socialTasks.twitch.channelLinks.push(link);
  8663. }
  8664. if (action === 'do') {
  8665. this.undoneTasks.twitch.channelLinks.push(link);
  8666. }
  8667. }
  8668. } else if (socialIcon.hasClass('fa-discord')) {
  8669. if (/join/gim.test(taskText)) {
  8670. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8671. if (!link) {
  8672. var _$task$find$attr, _$task$find$attr$matc;
  8673. 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];
  8674. if (!ggLink) {
  8675. continue;
  8676. }
  8677. link = `https://discord.com/invite/${ggLink}`;
  8678. }
  8679. if (action === 'undo') {
  8680. this.socialTasks.discord.serverLinks.push(link);
  8681. }
  8682. if (action === 'do') {
  8683. this.undoneTasks.discord.serverLinks.push(link);
  8684. }
  8685. }
  8686. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8687. continue;
  8688. } else if (socialIcon.hasClass('fa-youtube')) {
  8689. if (/subscribe/gim.test(taskText)) {
  8690. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8691. if (!link) {
  8692. continue;
  8693. }
  8694. if (action === 'undo') {
  8695. this.socialTasks.youtube.channelLinks.push(link);
  8696. }
  8697. if (action === 'do') {
  8698. this.undoneTasks.youtube.channelLinks.push(link);
  8699. }
  8700. }
  8701. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8702. if (/join.*group/gi.test(taskText)) {
  8703. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8704. if (!link) {
  8705. continue;
  8706. }
  8707. if (action === 'undo') {
  8708. this.socialTasks.steam.groupLinks.push(link);
  8709. }
  8710. if (action === 'do') {
  8711. this.undoneTasks.steam.groupLinks.push(link);
  8712. }
  8713. } else if (/follow.*curator/gi.test(taskText)) {
  8714. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8715. if (!link) {
  8716. continue;
  8717. }
  8718. if (action === 'undo') {
  8719. this.socialTasks.steam.curatorLinks.push(link);
  8720. }
  8721. if (action === 'do') {
  8722. this.undoneTasks.steam.curatorLinks.push(link);
  8723. }
  8724. }
  8725. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  8726. expandInfo.find('input').val(this.options.vlootUsername);
  8727. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8728. expandInfo.find('input').val(this.options.gameroundUsername);
  8729. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  8730. if (action !== 'do') {
  8731. continue;
  8732. }
  8733. const link = aElements.attr('href');
  8734. if (!link) {
  8735. continue;
  8736. }
  8737. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  8738. if (!gleamLink) {
  8739. continue;
  8740. }
  8741. this.undoneTasks.extra.gleam.push(gleamLink);
  8742. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  8743. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  8744. }
  8745. }
  8746. logStatus.success();
  8747. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8748. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8749. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8750. tasks: this.socialTasks,
  8751. time: new Date().getTime()
  8752. });
  8753. return true;
  8754. } catch (error) {
  8755. throwError(error, 'Gleam.classifyTask');
  8756. return false;
  8757. }
  8758. }
  8759. async extraDoTask(_ref) {
  8760. let {
  8761. gleam
  8762. } = _ref;
  8763. try {
  8764. const pro = [];
  8765. for (const link of gleam) {
  8766. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  8767. }
  8768. return Promise.all(pro).then(() => true);
  8769. } catch (error) {
  8770. throwError(error, 'Gleam.extraDoTask');
  8771. return false;
  8772. }
  8773. }
  8774. async verifyTask() {
  8775. try {
  8776. scripts_echoLog({
  8777. text: `${i18n('verifyingTask')}...`
  8778. });
  8779. const tasks = $('.entry-content .entry-method');
  8780. for (const task of tasks) {
  8781. const $task = $(task);
  8782. if ($task.find('i.fa-question').length === 0) {
  8783. continue;
  8784. }
  8785. const taskInfo = $task.find('.user-links');
  8786. taskInfo[0].click();
  8787. await delay(500);
  8788. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8789. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  8790. for (const button of continueBtn) {
  8791. button.click();
  8792. await delay(500);
  8793. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8794. }
  8795. }
  8796. scripts_echoLog({
  8797. text: i18n('verifiedGleamTasks')
  8798. });
  8799. } catch (error) {
  8800. throwError(error, 'Gleam.verifyTask');
  8801. return false;
  8802. }
  8803. }
  8804. }
  8805. async function _checkSync2() {
  8806. try {
  8807. return await new Promise(resolve => {
  8808. const checker = setInterval(() => {
  8809. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  8810. clearInterval(checker);
  8811. resolve(true);
  8812. }
  8813. }, 500);
  8814. });
  8815. } catch (error) {
  8816. throwError(error, 'Gleam.checkSync');
  8817. return false;
  8818. }
  8819. }
  8820. async function _doGleamTask2(link) {
  8821. try {
  8822. const logStatus = scripts_echoLog({
  8823. text: i18n('doingGleamTask')
  8824. });
  8825. return await new Promise(resolve => {
  8826. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  8827. active: true,
  8828. insert: true,
  8829. setParent: true
  8830. }).onclose = () => {
  8831. logStatus.success();
  8832. resolve(true);
  8833. };
  8834. });
  8835. } catch (error) {
  8836. throwError(error, 'Gleam.doGleamTask');
  8837. return false;
  8838. }
  8839. }
  8840. function Gleam_getGiveawayId2() {
  8841. try {
  8842. const giveawayId = window.location.pathname;
  8843. if (giveawayId) {
  8844. this.giveawayId = giveawayId;
  8845. return true;
  8846. }
  8847. scripts_echoLog({
  8848. text: i18n('getFailed', 'GiveawayId')
  8849. });
  8850. return false;
  8851. } catch (error) {
  8852. throwError(error, 'Gleam.getGiveawayId');
  8853. return false;
  8854. }
  8855. }
  8856. async function _getGleamLink2(link) {
  8857. try {
  8858. const logStatus = scripts_echoLog({
  8859. text: i18n('gettingGleamLink')
  8860. });
  8861. const {
  8862. result,
  8863. statusText,
  8864. status,
  8865. data
  8866. } = await tools_httpRequest({
  8867. url: link,
  8868. method: 'GET'
  8869. });
  8870. if (result === 'Success') {
  8871. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  8872. var _data$responseText$ma;
  8873. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8874. if (gleamLink) {
  8875. logStatus.success();
  8876. return gleamLink;
  8877. }
  8878. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  8879. return false;
  8880. }
  8881. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8882. return false;
  8883. }
  8884. logStatus.error(`${result}:${statusText}(${status})`);
  8885. return false;
  8886. } catch (error) {
  8887. throwError(error, 'Gleam.getGleamLink');
  8888. return false;
  8889. }
  8890. }
  8891. async function Gleam_checkLeftKey2() {
  8892. try {
  8893. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  8894. if (!globalOptions.other.checkLeftKey) {
  8895. return true;
  8896. }
  8897. 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];
  8898. if (!campaignString) {
  8899. return false;
  8900. }
  8901. const {
  8902. campaign,
  8903. incentive
  8904. } = JSON.parse(campaignString);
  8905. 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];
  8906. let ownedKey = false;
  8907. if (controllerString) {
  8908. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  8909. 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) {
  8910. ownedKey = true;
  8911. }
  8912. }
  8913. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  8914. await external_Swal_default().fire({
  8915. icon: 'warning',
  8916. title: i18n('notice'),
  8917. text: i18n('giveawayNotWork'),
  8918. confirmButtonText: i18n('confirm'),
  8919. cancelButtonText: i18n('cancel'),
  8920. showCancelButton: true
  8921. }).then(_ref2 => {
  8922. let {
  8923. value
  8924. } = _ref2;
  8925. if (value) {
  8926. window.close();
  8927. }
  8928. });
  8929. }
  8930. return true;
  8931. } catch (error) {
  8932. throwError(error, 'Gleam.checkLeftKey');
  8933. return false;
  8934. }
  8935. }
  8936. const website_Gleam = Gleam;
  8937. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  8938. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  8939. privateSet.add(obj);
  8940. }
  8941. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  8942. if (privateCollection.has(obj)) {
  8943. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8944. }
  8945. }
  8946. function SweepWidget_defineProperty(obj, key, value) {
  8947. if (key in obj) {
  8948. Object.defineProperty(obj, key, {
  8949. value: value,
  8950. enumerable: true,
  8951. configurable: true,
  8952. writable: true
  8953. });
  8954. } else {
  8955. obj[key] = value;
  8956. }
  8957. return obj;
  8958. }
  8959. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  8960. if (!privateSet.has(receiver)) {
  8961. throw new TypeError('attempted to get private field on non-instance');
  8962. }
  8963. return fn;
  8964. }
  8965. const SweepWidget_defaultOptions = {
  8966. username: '',
  8967. email: ''
  8968. };
  8969. var SweepWidget_checkLogin = new WeakSet();
  8970. var SweepWidget_getGiveawayId = new WeakSet();
  8971. var _checkEnter = new WeakSet();
  8972. var _checkFinish = new WeakSet();
  8973. class SweepWidget extends website_Website {
  8974. constructor() {
  8975. super(...arguments);
  8976. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  8977. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  8978. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  8979. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  8980. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  8981. SweepWidget_defineProperty(this, 'options', {
  8982. ...SweepWidget_defaultOptions,
  8983. ...GM_getValue('SweepWidgetOptions')
  8984. });
  8985. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  8986. }
  8987. static test() {
  8988. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  8989. }
  8990. async after() {
  8991. try {
  8992. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  8993. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8994. }
  8995. } catch (error) {
  8996. throwError(error, 'SweepWidget.after');
  8997. }
  8998. }
  8999. init() {
  9000. try {
  9001. const logStatus = scripts_echoLog({
  9002. text: i18n('initing')
  9003. });
  9004. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9005. logStatus.warning(i18n('needLogin'));
  9006. return false;
  9007. }
  9008. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9009. return false;
  9010. }
  9011. this.initialized = true;
  9012. logStatus.success();
  9013. return true;
  9014. } catch (error) {
  9015. throwError(error, 'SweepWidget.init');
  9016. return false;
  9017. }
  9018. }
  9019. classifyTask() {
  9020. return true;
  9021. }
  9022. async doTask() {
  9023. try {
  9024. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9025. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9026. $('input[name="sw__login_name"]').val(this.options.username);
  9027. }
  9028. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9029. $('input[name="sw__login_email"]').val(this.options.email);
  9030. }
  9031. if ($('#sw_login_button:visible').length > 0) {
  9032. $('#sw_login_button')[0].click();
  9033. }
  9034. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9035. return false;
  9036. }
  9037. }
  9038. const logStatus = scripts_echoLog({
  9039. text: i18n('SweepWidgetNotice')
  9040. });
  9041. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9042. for (const task of tasks) {
  9043. var _aElement$, _$task$find$removeAtt;
  9044. const $task = $(task);
  9045. if ($task.find('i.fa-check:visible').length > 0) {
  9046. continue;
  9047. }
  9048. const title = $task.find('.sw_text_inner');
  9049. title[0].click();
  9050. const aElement = $task.find('a.sw_link');
  9051. const link = aElement.attr('href');
  9052. aElement.attr('href', '#a').attr('target', '_self');
  9053. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9054. await delay(300);
  9055. aElement.attr('href', link).attr('target', '_blank');
  9056. $task.find('input[type="text"]').val('test');
  9057. const verifyBtn = $task.find('input.sw_verify');
  9058. if (verifyBtn.prop('disabled') === true) {
  9059. title[0].click();
  9060. await delay(300);
  9061. title[0].click();
  9062. await delay(300);
  9063. }
  9064. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9065. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9066. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9067. }
  9068. logStatus.success();
  9069. return true;
  9070. } catch (error) {
  9071. throwError(error, 'SweepWidget.doTask');
  9072. return false;
  9073. }
  9074. }
  9075. }
  9076. function SweepWidget_checkLogin2() {
  9077. try {
  9078. if ($('#twitter_login_button').length > 0) {
  9079. $('#twitter_login_button')[0].click();
  9080. }
  9081. return true;
  9082. } catch (error) {
  9083. throwError(error, 'SweepWidget.checkLogin');
  9084. return false;
  9085. }
  9086. }
  9087. function SweepWidget_getGiveawayId2() {
  9088. try {
  9089. var _window$location$href;
  9090. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9091. if (giveawayId) {
  9092. this.giveawayId = giveawayId;
  9093. return true;
  9094. }
  9095. scripts_echoLog({
  9096. text: i18n('getFailed', 'GiveawayId')
  9097. });
  9098. return false;
  9099. } catch (error) {
  9100. throwError(error, 'SweepWidget.getGiveawayId');
  9101. return false;
  9102. }
  9103. }
  9104. async function _checkEnter2() {
  9105. try {
  9106. return new Promise(resolve => {
  9107. const checker = setInterval(() => {
  9108. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9109. clearInterval(checker);
  9110. resolve(true);
  9111. }
  9112. });
  9113. });
  9114. } catch (error) {
  9115. throwError(error, 'SweepWidget.checkEnter');
  9116. return false;
  9117. }
  9118. }
  9119. async function _checkFinish2($task) {
  9120. try {
  9121. return new Promise(resolve => {
  9122. const checker = setInterval(() => {
  9123. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9124. clearInterval(checker);
  9125. resolve(true);
  9126. }
  9127. });
  9128. });
  9129. } catch (error) {
  9130. throwError(error, 'SweepWidget.checkFinish');
  9131. return false;
  9132. }
  9133. }
  9134. const website_SweepWidget = SweepWidget;
  9135. const defaultWhiteList = {
  9136. discord: {
  9137. servers: []
  9138. },
  9139. instagram: {
  9140. users: []
  9141. },
  9142. twitch: {
  9143. channels: []
  9144. },
  9145. twitter: {
  9146. users: [],
  9147. retweets: [],
  9148. likes: []
  9149. },
  9150. vk: {
  9151. names: []
  9152. },
  9153. youtube: {
  9154. channels: [],
  9155. likes: []
  9156. },
  9157. reddit: {
  9158. reddits: []
  9159. },
  9160. steam: {
  9161. groups: [],
  9162. wishlists: [],
  9163. follows: [],
  9164. forums: [],
  9165. workshops: [],
  9166. curators: [],
  9167. workshopVotes: [],
  9168. curatorLikes: [],
  9169. announcements: []
  9170. }
  9171. };
  9172. const link2id = async function(type) {
  9173. 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;
  9174. try {
  9175. const link = $('#socialLink').val();
  9176. let id = '';
  9177. switch (type) {
  9178. case 'discord.servers':
  9179. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9180. break;
  9181.  
  9182. case 'instagram.users':
  9183. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9184. break;
  9185.  
  9186. case 'twitch.channels':
  9187. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9188. break;
  9189.  
  9190. case 'twitter.users':
  9191. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9192. break;
  9193.  
  9194. case 'twitter.retweets':
  9195. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9196. break;
  9197.  
  9198. case 'vk.names':
  9199. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9200. break;
  9201.  
  9202. case 'youtube.channels':
  9203. 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) || '';
  9204. break;
  9205.  
  9206. case 'youtube.likes':
  9207. 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) || '';
  9208. break;
  9209.  
  9210. case 'reddit.reddits':
  9211. 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]) || '';
  9212. break;
  9213.  
  9214. case 'steam.groups':
  9215. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9216. break;
  9217.  
  9218. case 'steam.wishlists':
  9219. case 'steam.follows':
  9220. case 'steam.forums':
  9221. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9222. break;
  9223.  
  9224. case 'steam.workshops':
  9225. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9226. break;
  9227.  
  9228. case 'steam.curators':
  9229. {
  9230. if (link.includes('curator')) {
  9231. var _link$match12;
  9232. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9233. } else {
  9234. var _link$match13;
  9235. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9236. if (!param || param.length !== 2) {
  9237. break;
  9238. }
  9239. const steam = new social_Steam();
  9240. if (await steam.init()) {
  9241. id = await steam.getCuratorId(param[0], param[1]) || '';
  9242. }
  9243. }
  9244. }
  9245. break;
  9246. }
  9247. return id;
  9248. } catch (error) {
  9249. throwError(error, 'link2id');
  9250. return i18n('getFailed', 'id');
  9251. }
  9252. };
  9253. const disabledType = {
  9254. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9255. twitter: [ 'likes' ]
  9256. };
  9257. const whiteListOptions = function(showType) {
  9258. try {
  9259. const whiteList = {
  9260. ...defaultWhiteList,
  9261. ...GM_getValue('whiteList') || {}
  9262. };
  9263. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9264. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9265. for (const [ social, types ] of Object.entries(whiteList)) {
  9266. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9267. var _disabledType$social;
  9268. 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>`;
  9269. }).join('');
  9270. }
  9271. whiteListOptionsForm += '</tbody></table></form>';
  9272. if (showType === 'swal') {
  9273. external_Swal_default().fire({
  9274. title: i18n('whiteListOptions'),
  9275. html: whiteListOptionsForm,
  9276. showConfirmButton: false,
  9277. showCloseButton: true
  9278. });
  9279. } else {
  9280. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9281. }
  9282. $('.editWhiteList').on('click', function() {
  9283. var _whiteList$social;
  9284. const value = $(this).attr('data-value');
  9285. if (!value) {
  9286. return;
  9287. }
  9288. const [ social, type ] = value.split('.');
  9289. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9290. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9291. return;
  9292. }
  9293. external_Swal_default().fire({
  9294. title: i18n('changeWhiteListOption', value),
  9295. input: 'textarea',
  9296. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9297. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9298. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9299. inputValue: whiteList[social][type].join('\n'),
  9300. showConfirmButton: true,
  9301. confirmButtonText: i18n('save'),
  9302. showCancelButton: true,
  9303. cancelButtonText: i18n('close'),
  9304. showDenyButton: true,
  9305. denyButtonText: i18n('return')
  9306. }).then(_ref => {
  9307. let {
  9308. isDenied,
  9309. isConfirmed,
  9310. value
  9311. } = _ref;
  9312. if (isDenied) {
  9313. if (showType === 'swal') {
  9314. whiteListOptions(showType);
  9315. }
  9316. return;
  9317. } else if (isConfirmed) {
  9318. whiteList[social][type] = value.split('\n');
  9319. GM_setValue('whiteList', whiteList);
  9320. external_Swal_default().fire({
  9321. title: i18n('changeWhiteListSuccess'),
  9322. icon: 'success'
  9323. });
  9324. }
  9325. });
  9326. $('#link2id').on('click', async function() {
  9327. const type = $(this).attr('data-type');
  9328. $('#socialLink').val(await link2id(type));
  9329. });
  9330. });
  9331. } catch (error) {
  9332. throwError(error, 'whiteListOptions');
  9333. }
  9334. };
  9335. const whiteList = whiteListOptions;
  9336. const setGistData = async (token, gistId, fileName, content) => {
  9337. try {
  9338. const logStatus = scripts_echoLog({
  9339. text: i18n('settingData')
  9340. });
  9341. const contentData = JSON.stringify({
  9342. files: {
  9343. [fileName]: {
  9344. content: JSON.stringify(content)
  9345. }
  9346. }
  9347. });
  9348. const {
  9349. result,
  9350. statusText,
  9351. status,
  9352. data
  9353. } = await tools_httpRequest({
  9354. url: `https://api.github.com/gists/${gistId}`,
  9355. headers: {
  9356. Accept: 'application/vnd.github.v3+json',
  9357. Authorization: `token ${token}`
  9358. },
  9359. data: contentData,
  9360. responseType: 'json',
  9361. method: 'POST',
  9362. timeout: 3e4
  9363. });
  9364. if (result === 'Success') {
  9365. var _data$response$files, _data$response$files$;
  9366. 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)) {
  9367. logStatus.success();
  9368. return true;
  9369. }
  9370. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9371. return false;
  9372. }
  9373. logStatus.error(`${result}:${statusText}(${status})`);
  9374. return false;
  9375. } catch (error) {
  9376. throwError(error, 'setGistData');
  9377. return false;
  9378. }
  9379. };
  9380. const getGistData = async (token, gistId, fileName) => {
  9381. try {
  9382. const logStatus = scripts_echoLog({
  9383. text: i18n('gettingData')
  9384. });
  9385. const {
  9386. result,
  9387. statusText,
  9388. status,
  9389. data
  9390. } = await tools_httpRequest({
  9391. url: `https://api.github.com/gists/${gistId}`,
  9392. headers: {
  9393. Accept: 'application/vnd.github.v3+json',
  9394. Authorization: `token ${token}`
  9395. },
  9396. responseType: 'json',
  9397. method: 'GET',
  9398. timeout: 3e4
  9399. });
  9400. if (result === 'Success') {
  9401. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9402. var _data$response, _data$response$files2, _data$response$files3;
  9403. logStatus.success();
  9404. 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);
  9405. }
  9406. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9407. return false;
  9408. }
  9409. logStatus.error(`${result}:${statusText}(${status})`);
  9410. return false;
  9411. } catch (error) {
  9412. throwError(error, 'getGistData');
  9413. return false;
  9414. }
  9415. };
  9416. const syncOptions = () => {
  9417. try {
  9418. const {
  9419. TOKEN,
  9420. GIST_ID,
  9421. FILE_NAME,
  9422. SYNC_HISTORY
  9423. } = GM_getValue('gistOptions') || {
  9424. TOKEN: '',
  9425. GIST_ID: '',
  9426. FILE_NAME: '',
  9427. SYNC_HISTORY: true
  9428. };
  9429. external_Swal_default().fire({
  9430. title: i18n('gistOptions'),
  9431. 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;">
  9432. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9433. ${i18n('downloadFromGist')}</button></p>`,
  9434. focusConfirm: false,
  9435. showLoaderOnConfirm: true,
  9436. 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>`,
  9437. preConfirm: async () => {
  9438. const token = $('#github-token').val();
  9439. const gistId = $('#gist-id').val();
  9440. const fileName = $('#file-name').val();
  9441. const syncHistory = $('#sync-history').prop('checked');
  9442. GM_setValue('gistOptions', {
  9443. TOKEN: token,
  9444. GIST_ID: gistId,
  9445. FILE_NAME: fileName,
  9446. SYNC_HISTORY: syncHistory
  9447. });
  9448. return await getGistData(token, gistId, fileName);
  9449. },
  9450. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9451. confirmButtonText: i18n('saveAndTest'),
  9452. showCancelButton: true,
  9453. cancelButtonText: i18n('close')
  9454. }).then(_ref => {
  9455. let {
  9456. value
  9457. } = _ref;
  9458. if (value) {
  9459. external_Swal_default().fire({
  9460. icon: 'success',
  9461. title: i18n('testSuccess')
  9462. }).then(syncOptions);
  9463. } else if (value !== undefined) {
  9464. external_Swal_default().fire({
  9465. icon: 'error',
  9466. title: i18n('testFailed')
  9467. }).then(syncOptions);
  9468. }
  9469. });
  9470. $('#upload-data').on('click', async () => {
  9471. const {
  9472. TOKEN,
  9473. GIST_ID,
  9474. FILE_NAME
  9475. } = GM_getValue('gistOptions') || {};
  9476. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9477. return external_Swal_default().fire({
  9478. icon: 'error',
  9479. title: i18n('saveAndTestNotice')
  9480. }).then(syncOptions);
  9481. }
  9482. external_Swal_default().fire({
  9483. icon: 'info',
  9484. title: i18n('processingData')
  9485. });
  9486. const data = {};
  9487. const names = GM_listValues();
  9488. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9489. for (const name of names) {
  9490. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9491. continue;
  9492. }
  9493. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9494. continue;
  9495. }
  9496. data[name] = GM_getValue(name);
  9497. }
  9498. external_Swal_default().update({
  9499. icon: 'info',
  9500. title: i18n('updatingData')
  9501. });
  9502. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9503. external_Swal_default().fire({
  9504. icon: 'success',
  9505. title: i18n('syncDataSuccess')
  9506. });
  9507. } else {
  9508. external_Swal_default().fire({
  9509. icon: 'error',
  9510. title: i18n('syncDataFailed')
  9511. });
  9512. }
  9513. });
  9514. $('#download-data').on('click', async () => {
  9515. const {
  9516. TOKEN,
  9517. GIST_ID,
  9518. FILE_NAME
  9519. } = GM_getValue('gistOptions') || {};
  9520. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9521. return external_Swal_default().fire({
  9522. icon: 'error',
  9523. title: i18n('saveAndTestNotice')
  9524. }).then(syncOptions);
  9525. }
  9526. external_Swal_default().fire({
  9527. icon: 'info',
  9528. title: i18n('downloadingData')
  9529. });
  9530. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9531. if (!data) {
  9532. return external_Swal_default().fire({
  9533. icon: 'error',
  9534. title: i18n('checkedNoData')
  9535. }).then(syncOptions);
  9536. }
  9537. external_Swal_default().update({
  9538. icon: 'info',
  9539. title: i18n('savingData')
  9540. });
  9541. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9542. for (const [ name, value ] of Object.entries(data)) {
  9543. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9544. continue;
  9545. }
  9546. GM_setValue(name, value);
  9547. }
  9548. external_Swal_default().fire({
  9549. icon: 'success',
  9550. title: i18n('syncDataSuccess')
  9551. });
  9552. });
  9553. } catch (error) {
  9554. throwError(error, 'syncOptions');
  9555. }
  9556. };
  9557. const dataSync = syncOptions;
  9558. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9559. Setting_checkPrivateRedeclaration(obj, privateSet);
  9560. privateSet.add(obj);
  9561. }
  9562. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9563. if (privateCollection.has(obj)) {
  9564. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9565. }
  9566. }
  9567. function Setting_defineProperty(obj, key, value) {
  9568. if (key in obj) {
  9569. Object.defineProperty(obj, key, {
  9570. value: value,
  9571. enumerable: true,
  9572. configurable: true,
  9573. writable: true
  9574. });
  9575. } else {
  9576. obj[key] = value;
  9577. }
  9578. return obj;
  9579. }
  9580. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9581. if (!privateSet.has(receiver)) {
  9582. throw new TypeError('attempted to get private field on non-instance');
  9583. }
  9584. return fn;
  9585. }
  9586. var Setting_getId = new WeakSet();
  9587. var _environment = new WeakSet();
  9588. class Setting {
  9589. constructor() {
  9590. Setting_classPrivateMethodInitSpec(this, _environment);
  9591. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  9592. Setting_defineProperty(this, 'name', 'Setting');
  9593. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  9594. Setting_defineProperty(this, 'dataSync', dataSync);
  9595. }
  9596. tasksHistory() {
  9597. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9598. }
  9599. static test() {
  9600. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9601. }
  9602. before() {
  9603. $('body').html('').addClass('auto-task-options');
  9604. }
  9605. after() {
  9606. try {
  9607. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  9608. changeGlobalOptions('page');
  9609. whiteList('page');
  9610. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9611. $('#getTwitterUserId').on('click', () => {
  9612. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  9613. });
  9614. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9615. $('#getYoutubeChannelId').on('click', () => {
  9616. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  9617. });
  9618. $('input[name^="position"]').on('input', function() {
  9619. const type = $(this).attr('name').replace('position.', '');
  9620. const xLabel = 'rightleft';
  9621. const yLabel = 'topbottpm';
  9622. switch (type) {
  9623. case 'buttonSideX':
  9624. case 'buttonSideY':
  9625. case 'buttonDistance':
  9626. {
  9627. const distance = $('input[name="position.buttonDistance"]').val();
  9628. const sideX = $('input[name="position.buttonSideX"]').val();
  9629. const sideY = $('input[name="position.buttonSideY"]').val();
  9630. if (![ 'right', 'left' ].includes(sideX)) {
  9631. break;
  9632. }
  9633. if (![ 'top', 'bottom' ].includes(sideY)) {
  9634. break;
  9635. }
  9636. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9637. break;
  9638. }
  9639. const distanceArr = distance.split(',');
  9640. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9641. break;
  9642. }
  9643.  
  9644. case 'showButtonSideX':
  9645. case 'showButtonSideY':
  9646. case 'showButtonDistance':
  9647. {
  9648. const distance = $('input[name="position.showButtonDistance"]').val();
  9649. const sideX = $('input[name="position.showButtonSideX"]').val();
  9650. const sideY = $('input[name="position.showButtonSideY"]').val();
  9651. if (![ 'right', 'left' ].includes(sideX)) {
  9652. break;
  9653. }
  9654. if (![ 'top', 'bottom' ].includes(sideY)) {
  9655. break;
  9656. }
  9657. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9658. break;
  9659. }
  9660. const distanceArr = distance.split(',');
  9661. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9662. break;
  9663. }
  9664.  
  9665. case 'logSideX':
  9666. case 'logSideY':
  9667. case 'logDistance':
  9668. {
  9669. const distance = $('input[name="position.logDistance"]').val();
  9670. const sideX = $('input[name="position.logSideX"]').val();
  9671. const sideY = $('input[name="position.logSideY"]').val();
  9672. if (![ 'right', 'left' ].includes(sideX)) {
  9673. break;
  9674. }
  9675. if (![ 'top', 'bottom' ].includes(sideY)) {
  9676. break;
  9677. }
  9678. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9679. break;
  9680. }
  9681. const distanceArr = distance.split(',');
  9682. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9683. break;
  9684. }
  9685.  
  9686. default:
  9687. break;
  9688. }
  9689. });
  9690. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9691. let functionKey = '';
  9692. if (event.altKey) {
  9693. functionKey += 'alt + ';
  9694. } else if (event.ctrlKey) {
  9695. functionKey += 'ctrl + ';
  9696. } else if (event.shiftKey) {
  9697. functionKey += 'shift + ';
  9698. }
  9699. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9700. });
  9701. } catch (error) {
  9702. throwError(error, 'Setting.after');
  9703. }
  9704. }
  9705. saveGlobalOptions() {
  9706. saveData();
  9707. }
  9708. }
  9709. function Setting_getId2(social) {
  9710. try {
  9711. external_Swal_default().fire({
  9712. title: i18n('getId', i18n(social)),
  9713. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9714. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9715. showCancelButton: true,
  9716. cancelButtonText: i18n('close'),
  9717. showConfirmButton: false
  9718. });
  9719. $('#link2id').on('click', async function() {
  9720. const link = $('#socialLink').val();
  9721. if (!link) {
  9722. return;
  9723. }
  9724. const type = $(this).attr('data-type');
  9725. if (type === 'twitterUser') {
  9726. var _link$match;
  9727. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9728. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9729. } else if (type === 'youtubeChannel') {
  9730. var _link$match2, _await$getInfo, _await$getInfo$params;
  9731. 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;
  9732. $('#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) || '');
  9733. }
  9734. });
  9735. } catch (error) {
  9736. throwError(error, 'Setting.getId');
  9737. }
  9738. }
  9739. function _environment2() {
  9740. try {
  9741. const userAgent = (0, javascript_utils_umd_min.ua)();
  9742. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9743. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9744. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9745. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9746. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9747. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9748. </tbody></table></form>`;
  9749. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9750. } catch (error) {
  9751. throwError(error, 'Setting.environment');
  9752. }
  9753. }
  9754. const website_Setting = Setting;
  9755. const external_dayjs_namespaceObject = dayjs;
  9756. function History_classPrivateMethodInitSpec(obj, privateSet) {
  9757. History_checkPrivateRedeclaration(obj, privateSet);
  9758. privateSet.add(obj);
  9759. }
  9760. function History_checkPrivateRedeclaration(obj, privateCollection) {
  9761. if (privateCollection.has(obj)) {
  9762. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9763. }
  9764. }
  9765. function History_defineProperty(obj, key, value) {
  9766. if (key in obj) {
  9767. Object.defineProperty(obj, key, {
  9768. value: value,
  9769. enumerable: true,
  9770. configurable: true,
  9771. writable: true
  9772. });
  9773. } else {
  9774. obj[key] = value;
  9775. }
  9776. return obj;
  9777. }
  9778. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  9779. if (!privateSet.has(receiver)) {
  9780. throw new TypeError('attempted to get private field on non-instance');
  9781. }
  9782. return fn;
  9783. }
  9784. var _addItem = new WeakSet();
  9785. class History extends website_Keylol {
  9786. constructor() {
  9787. super(...arguments);
  9788. History_classPrivateMethodInitSpec(this, _addItem);
  9789. History_defineProperty(this, 'name', 'History');
  9790. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  9791. }
  9792. static test() {
  9793. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9794. }
  9795. before() {
  9796. try {
  9797. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  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. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  9802. }
  9803. } catch (error) {
  9804. throwError(error, 'History.before');
  9805. }
  9806. }
  9807. clearHistory() {
  9808. try {
  9809. const data = GM_listValues() || [];
  9810. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9811. for (const item of tasksHistory) {
  9812. GM_deleteValue(item);
  9813. }
  9814. external_Swal_default().fire({
  9815. title: i18n('clearHistoryFinished'),
  9816. icon: 'success'
  9817. });
  9818. } catch (error) {
  9819. throwError(error, 'History.after');
  9820. }
  9821. }
  9822. }
  9823. function _addItem2(item) {
  9824. try {
  9825. const tasksData = GM_getValue(item);
  9826. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9827. return;
  9828. }
  9829. let html = '';
  9830. let title = '';
  9831. let link = '';
  9832. const [ website, id ] = item.split('-');
  9833. switch (website) {
  9834. case 'fawTasks':
  9835. title = `Freeanywhere[${id}]`;
  9836. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9837. break;
  9838.  
  9839. case 'gasTasks':
  9840. title = `Giveawaysu[${id}]`;
  9841. link = `https://giveaway.su/giveaway/view/${id}`;
  9842. break;
  9843.  
  9844. case 'gcTasks':
  9845. title = `GiveeClub[${id}]`;
  9846. link = `https://givee.club/event/${id}`;
  9847. break;
  9848.  
  9849. case 'gkTasks':
  9850. title = `Givekey[${id}]`;
  9851. link = `https://givekey.ru/giveaway/${id}`;
  9852. break;
  9853.  
  9854. case 'gleamTasks':
  9855. title = `Gleam[${id}]`;
  9856. link = `https://gleam.io${id}`;
  9857. break;
  9858.  
  9859. case 'khTasks':
  9860. title = `keyhub[${id}]`;
  9861. link = `https://key-hub.eu/giveaway/${id}`;
  9862. break;
  9863.  
  9864. case 'prysTasks':
  9865. title = `Prys[${id}]`;
  9866. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  9867. break;
  9868.  
  9869. default:
  9870. return;
  9871. }
  9872. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  9873. for (const [ type, tasks ] of Object.entries(types)) {
  9874. for (const task of tasks) {
  9875. 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>`;
  9876. }
  9877. }
  9878. }
  9879. $('.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>`);
  9880. $('span.delete-task').on('click', function() {
  9881. const itemName = $(this).attr('data-name');
  9882. if (itemName) {
  9883. GM_deleteValue(itemName);
  9884. external_Swal_default().fire({
  9885. title: i18n('clearTaskFinished'),
  9886. text: itemName,
  9887. icon: 'success'
  9888. });
  9889. } else {
  9890. external_Swal_default().fire({
  9891. title: i18n('clearTaskFailed'),
  9892. icon: 'error'
  9893. });
  9894. }
  9895. });
  9896. } catch (error) {
  9897. throwError(error, 'History.addItem');
  9898. }
  9899. }
  9900. const website_History = History;
  9901. 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 ];
  9902. const websiteOptions = function(website, options) {
  9903. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  9904. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  9905. for (const [ option, value ] of Object.entries(options)) {
  9906. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  9907. }
  9908. websiteOptionsForm += '</tbody></table></form>';
  9909. external_Swal_default().fire({
  9910. title: i18n('websiteOptions'),
  9911. html: websiteOptionsForm,
  9912. showConfirmButton: true,
  9913. confirmButtonText: i18n('save'),
  9914. showCancelButton: true,
  9915. cancelButtonText: i18n('close')
  9916. }).then(_ref => {
  9917. let {
  9918. isConfirmed
  9919. } = _ref;
  9920. if (isConfirmed) {
  9921. $('#websiteOptionsForm').serializeArray().map(value => {
  9922. options[value.name] = value.value;
  9923. return value;
  9924. });
  9925. GM_setValue(`${website}Options`, options);
  9926. external_Swal_default().fire({
  9927. title: i18n('changeWebsiteOptionsSuccess'),
  9928. icon: 'success'
  9929. });
  9930. }
  9931. });
  9932. };
  9933. const options = websiteOptions;
  9934. const external_keyboardJS_namespaceObject = keyboardJS;
  9935. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  9936. const checkUpdate = async (updateLink, auto) => {
  9937. try {
  9938. const checkUrl = `${updateLink}package.json`;
  9939. const {
  9940. result,
  9941. statusText,
  9942. status,
  9943. data
  9944. } = await tools_httpRequest({
  9945. url: checkUrl,
  9946. responseType: 'json',
  9947. method: 'GET',
  9948. timeout: 3e4
  9949. });
  9950. if (result === 'Success') {
  9951. var _data$response;
  9952. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  9953. return data.response;
  9954. }
  9955. if (!auto) {
  9956. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  9957. }
  9958. return false;
  9959. }
  9960. if (!auto) {
  9961. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  9962. }
  9963. return false;
  9964. } catch (error) {
  9965. throwError(error, 'checkUpdate');
  9966. return false;
  9967. }
  9968. };
  9969. const updateChecker = async () => {
  9970. try {
  9971. const currentVersion = GM_info.script.version;
  9972. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  9973. const updateLinks = {
  9974. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  9975. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  9976. standby: 'https://auto-task-v4.hclonely.com/'
  9977. };
  9978. let version;
  9979. let updateLink = '';
  9980. let packageData;
  9981. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  9982. updateLink = updateLinks[updateSource];
  9983. packageData = await checkUpdate(updateLink, false);
  9984. } else {
  9985. updateLink = updateLinks.github;
  9986. packageData = await checkUpdate(updateLink, true);
  9987. if (!packageData) {
  9988. updateLink = updateLinks.jsdelivr;
  9989. packageData = await checkUpdate(updateLink, true);
  9990. if (!packageData) {
  9991. updateLink = updateLinks.standby;
  9992. packageData = await checkUpdate(updateLink, true);
  9993. }
  9994. }
  9995. }
  9996. if (packageData) {
  9997. version = packageData.version || currentVersion;
  9998. } else {
  9999. version = currentVersion;
  10000. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10001. }
  10002. if (packageData && version !== currentVersion) {
  10003. var _packageData$change;
  10004. scripts_echoLog({
  10005. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10006. });
  10007. scripts_echoLog({
  10008. 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>`
  10009. });
  10010. }
  10011. } catch (error) {
  10012. throwError(error, 'updateChecker');
  10013. }
  10014. };
  10015. const scripts_updateChecker = updateChecker;
  10016. if (window.location.hostname === 'discord.com') {
  10017. var _window$localStorage, _window$localStorage$;
  10018. 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, '');
  10019. GM_setValue('discordAuth', {
  10020. auth: discordAuth
  10021. });
  10022. if (discordAuth && window.location.hash === '#auth') {
  10023. window.close();
  10024. external_Swal_default().fire('', i18n('closePageNotice'));
  10025. }
  10026. }
  10027. const loadScript = async () => {
  10028. var _website, _website2, _website3, _website4, _website5, _website6;
  10029. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10030. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10031. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10032. if (isLogin) {
  10033. var _commonOptions, _commonOptions$header;
  10034. GM_setValue('twitchAuth', {
  10035. authToken: authToken,
  10036. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10037. });
  10038. window.close();
  10039. external_Swal_default().fire('', i18n('closePageNotice'));
  10040. } else {
  10041. external_Swal_default().fire('', i18n('needLogin'));
  10042. }
  10043. }
  10044. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10045. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10046. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10047. if (isLogin && ct0) {
  10048. GM_setValue('twitterAuth', {
  10049. ct0: ct0
  10050. });
  10051. window.close();
  10052. external_Swal_default().fire('', i18n('closePageNotice'));
  10053. } else {
  10054. external_Swal_default().fire('', i18n('needLogin'));
  10055. }
  10056. }
  10057. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10058. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10059. if (PAPISID) {
  10060. GM_setValue('youtubeAuth', {
  10061. PAPISID: PAPISID
  10062. });
  10063. window.close();
  10064. external_Swal_default().fire('', i18n('closePageNotice'));
  10065. } else {
  10066. external_Swal_default().fire('', i18n('needLogin'));
  10067. }
  10068. }
  10069. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10070. const betaButton = $('#redesign-beta-optin-btn');
  10071. if (betaButton.length > 0) {
  10072. GM_setValue('redditAuth', '#auth');
  10073. return betaButton[0].click();
  10074. }
  10075. GM_setValue('redditAuth', null);
  10076. window.close();
  10077. external_Swal_default().fire('', i18n('closePageNotice'));
  10078. }
  10079. let website;
  10080. for (const Website of Websites) {
  10081. if (Website.test()) {
  10082. website = new Website();
  10083. break;
  10084. }
  10085. }
  10086. if (!website) {
  10087. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10088. return;
  10089. }
  10090. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10091. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10092. }
  10093. $('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>`);
  10094. $('div.show-button-div').on('click', () => {
  10095. $('#auto-task-buttons').show();
  10096. $('div.show-button-div').hide();
  10097. });
  10098. const toggleLog = () => {
  10099. const $this = $('#toggle-log');
  10100. const status = $this.attr('data-status');
  10101. if (status === 'show') {
  10102. $('#auto-task-info').hide();
  10103. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10104. } else {
  10105. $('#auto-task-info').show();
  10106. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10107. }
  10108. };
  10109. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10110. if (website.doTask) {
  10111. website.doTask();
  10112. }
  10113. });
  10114. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10115. if (website.undoTask) {
  10116. website.doTask();
  10117. }
  10118. });
  10119. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10120. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10121. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10122. }
  10123. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10124. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10125. for (const button of website.buttons) {
  10126. if (website[button]) {
  10127. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10128. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10129. website[button]();
  10130. });
  10131. $('#auto-task-buttons').append(btnElement);
  10132. }
  10133. }
  10134. }
  10135. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10136. ${i18n('hideButton')}</a></p>`);
  10137. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10138. $('#auto-task-buttons').hide();
  10139. $('div.show-button-div').show();
  10140. });
  10141. 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'}">
  10142. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10143. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10144. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10145. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10146. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10147. options(website.name, website.options);
  10148. });
  10149. }
  10150. if (website.name !== 'Setting') {
  10151. GM_registerMenuCommand(i18n('whiteList'), () => {
  10152. whiteList('swal');
  10153. });
  10154. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10155. changeGlobalOptions('swal');
  10156. });
  10157. GM_registerMenuCommand(i18n('tasksHistory'), () => {
  10158. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10159. });
  10160. GM_registerMenuCommand(i18n('syncData'), dataSync);
  10161. GM_registerMenuCommand(i18n('settingPage'), () => {
  10162. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10163. });
  10164. }
  10165. GM_addStyle(auto_task.Z);
  10166. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10167. if (!GM_getValue('notice')) {
  10168. var _echoLog$warning$font;
  10169. external_Swal_default().fire({
  10170. title: i18n('swalNotice'),
  10171. icon: 'warning'
  10172. }).then(() => {
  10173. window.open(i18n('noticeLink'), '_blank');
  10174. GM_setValue('notice', new Date().getTime());
  10175. });
  10176. (_echoLog$warning$font = scripts_echoLog({}).warning(i18n('echoNotice', i18n('noticeLink'))).font) === null || _echoLog$warning$font === void 0 ? void 0 : _echoLog$warning$font.find('a').on('click', () => {
  10177. GM_setValue('notice', new Date().getTime());
  10178. });
  10179. }
  10180. scripts_updateChecker();
  10181. };
  10182. if (window.location.hostname === 'opquests.com') {
  10183. loadScript();
  10184. } else {
  10185. $(loadScript);
  10186. }
  10187. }();
  10188. })();