auto-task-v4

赠Key站自动任务

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.1-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_getResourceText
  39. // @grant GM_registerMenuCommand
  40. // @grant GM_info
  41. // @grant GM_openInTab
  42. // @grant GM_notification
  43. // @grant unsafeWindow
  44. // @grant window.close
  45. // @grant window.localStorage
  46.  
  47. // @connect cdn.jsdelivr.net
  48. // @connect store.steampowered.com
  49. // @connect steamcommunity.com
  50. // @connect twitter.com
  51. // @connect api.twitter.com
  52. // @connect youtube.com
  53. // @connect www.youtube.com
  54. // @connect facebook.com
  55. // @connect instagram.com
  56. // @connect vk.com
  57. // @connect twitch.tv
  58. // @connect www.twitch.tv
  59. // @connect gql.twitch.tv
  60. // @connect github.com
  61. // @connect discordapp.com
  62. // @connect discord.gg
  63. // @connect discord.com
  64. // @connect www.reddit.com
  65. // @connect oauth.reddit.com
  66. // @connect raw.githubusercontent.com
  67. // @connect t.me
  68. // @connect bit.ly
  69. // @connect giveaway.su
  70. // @connect google.com
  71. // @connect www.vloot.io
  72. // @connect givee.club
  73. // @connect *
  74. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  75. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  76. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  77. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  78. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  79. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  80. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  81.  
  82. // @compatible Tampermonkey Only
  83. // @noframes
  84. // ==/UserScript==
  85.  
  86. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  87.  
  88. (function() {
  89. var __webpack_modules__ = {
  90. 514: function(__unused_webpack_module, exports) {
  91. !function(e, n) {
  92. true ? n(exports) : 0;
  93. }(this, function(e) {
  94. 'use strict';
  95. var t = function() {
  96. return (t = Object.assign || function(e) {
  97. for (var n, o = 1, t = arguments.length; o < t; o++) {
  98. for (var r in n = arguments[o]) {
  99. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  100. }
  101. }
  102. return e;
  103. }).apply(this, arguments);
  104. };
  105. function r(e, n, o) {
  106. if (o || 2 === arguments.length) {
  107. for (var t, r = 0, i = n.length; r < i; r++) {
  108. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  109. }
  110. }
  111. return e.concat(t || Array.prototype.slice.call(n));
  112. }
  113. function d(e) {
  114. return '[object Object]' === n(e);
  115. }
  116. function l(e, n) {
  117. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  118. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  119. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  120. });
  121. }
  122. var n = function(e) {
  123. return Object.prototype.toString.call(e);
  124. };
  125. var o = (i.prototype.init = function() {
  126. try {
  127. this.getSystemName(), this.getBrowserName();
  128. } catch (e) {
  129. console.warn('[UA formatter error] '.concat(e));
  130. }
  131. }, i.prototype.getEngine = function() {
  132. var e = this.agent;
  133. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  134. }, i.prototype.getSystemName = function() {
  135. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  136. try {
  137. var o = '';
  138. if (/Windows/i.test(n)) {
  139. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  140. switch (this.info.os = 'Windows', t) {
  141. case '6.3':
  142. o = '8.1';
  143. break;
  144.  
  145. case '6.2':
  146. o = '8';
  147. break;
  148.  
  149. case '6.1':
  150. o = '7';
  151. break;
  152.  
  153. case '5.2':
  154. case '5.1':
  155. o = 'XP';
  156. break;
  157.  
  158. default:
  159. o = t;
  160. }
  161. return this.info.device = 'PC', void (this.info.osVersion = o);
  162. }
  163. if (/^Macintosh/i.test(n)) {
  164. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  165. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  166. }
  167. if (/^iPad/i.test(n)) {
  168. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  169. void (this.info.osVersion = o.replace(/_/g, '.'));
  170. }
  171. if (/^iPhone/i.test(n)) {
  172. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  173. void (this.info.osVersion = o.replace(/_/g, '.'));
  174. }
  175. if (-1 !== n.indexOf('Android')) {
  176. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  177. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  178. }
  179. if (/Linux\s[a-z\d_]+/.test(n)) {
  180. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  181. }
  182. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  183. } catch (e) {
  184. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  185. }
  186. }, i.prototype.getBrowserName = function() {
  187. var e = Object.keys(this.browserNameMap).map(function(e) {
  188. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  189. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  190. return -1 !== e.findIndex(function(e) {
  191. return e.test(n);
  192. });
  193. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  194. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  195. }, i.prototype._formatBrowserVersion = function(e) {
  196. var n, o, t, r;
  197. try {
  198. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  199. var d = u[f], l = d[0], h = d[1];
  200. if (new RegExp(l).test(s)) {
  201. c = h;
  202. break;
  203. }
  204. }
  205. var p = {
  206. browserVersion: null != a ? a : 'Unknown',
  207. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  208. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  209. };
  210. return 'Trident' === s && (p.browserVersion = {
  211. '4.0': 8,
  212. '5.0': 9,
  213. '6.0': 10,
  214. '7.0': 11
  215. }[a]), p;
  216. } catch (e) {
  217. return console.warn('[UA formatter error] '.concat(e)), {
  218. browser: 'Unknown',
  219. browserVersion: 'Unknown'
  220. };
  221. }
  222. }, i);
  223. function i(e) {
  224. this.agent = '', this.info = {
  225. browser: '',
  226. browserZH: '',
  227. browserVersion: '',
  228. os: '',
  229. osVersion: '',
  230. device: 'Unknown',
  231. engine: 'WebKit'
  232. }, this.browserNameMap = {
  233. MicroMessenger: {
  234. en: 'MicroMessenger',
  235. zh: '微信'
  236. },
  237. MetaSr: {
  238. en: 'MetaSr',
  239. zh: '搜狗浏览器'
  240. },
  241. 'QQ(Browser)?': {
  242. en: 'QQBrowser',
  243. zh: 'QQ浏览器'
  244. },
  245. UCBrowser: {
  246. en: 'UCBrowser',
  247. zh: 'UC浏览器'
  248. },
  249. '2345Explorer': {
  250. en: '2345Explorer',
  251. zh: '2345极速浏览器'
  252. },
  253. Mb2345Browser: {
  254. en: 'Mb2345Browser',
  255. zh: '2345手机浏览器'
  256. },
  257. Trident: {
  258. en: 'Internet Explorer'
  259. },
  260. 'Edge?': {
  261. en: 'Edge'
  262. },
  263. OPR: {
  264. en: 'Opera'
  265. },
  266. Vivaldi: {
  267. en: 'Vivaldi'
  268. },
  269. Firefox: {
  270. en: 'Firefox'
  271. },
  272. Chrome: {
  273. en: 'Chrome'
  274. },
  275. Safari: {
  276. en: 'Safari'
  277. }
  278. }, this.agent = e, this.init();
  279. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  280. this.info = t(t({}, this.info), {
  281. engine: this.getEngine(),
  282. browserVersion: 'Safari' === o ? n : e
  283. });
  284. }
  285. function s() {
  286. this.cookies = {}, this.init();
  287. }
  288. var a = new (s.prototype.init = function() {
  289. var o = {};
  290. document.cookie.split(/;\s/).forEach(function(e) {
  291. var n = e.split(/=/), e = n[0], n = n[1];
  292. o[e] = n;
  293. }), this.cookies = o;
  294. }, s.prototype.getItem = function(e) {
  295. return this.cookies[e];
  296. }, s.prototype.getAllItems = function() {
  297. return this.cookies;
  298. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  299. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  300. }, s)();
  301. e.countDown = function e(n, o, t, r) {
  302. if (!window) {
  303. throw new Error('window is not defind.');
  304. }
  305. if (0 < n) {
  306. return r && r(), n--, window[o] = window.setTimeout(function() {
  307. e(n, o, t, r);
  308. }, 1e3), function() {
  309. return clearTimeout(window[o]);
  310. };
  311. }
  312. clearTimeout(window[o]), t && t();
  313. }, e.createRandomID = function(e) {
  314. void 0 === e && (e = 12);
  315. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  316. n.push(o[Math.round(Math.random() * t)]);
  317. }
  318. return n.join('');
  319. }, e.dCookie = a, e.debounce = function(o, t, r) {
  320. var i;
  321. void 0 === t && (t = 0);
  322. var s = r = void 0 === r ? !1 : r;
  323. return function() {
  324. var e = this, n = arguments;
  325. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  326. r ? s = !0 : o.apply(e, n);
  327. }, t);
  328. };
  329. }, e.deepCopy = function e(n) {
  330. if (d(n) || Array.isArray(n)) {
  331. var o, t = Array.isArray(n) ? [] : {};
  332. for (o in n) {
  333. t[o] = e(n[o]);
  334. }
  335. return t;
  336. }
  337. return n;
  338. }, e.formatQueryParams = function(e) {
  339. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  340. if (!e) {
  341. return {};
  342. }
  343. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  344. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  345. return t[n] = o, e;
  346. });
  347. }
  348. return t;
  349. }, e.formatThousandth = function(e) {
  350. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  351. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  352. }, e.generateTree = function e(n, o, t, r) {
  353. for (var i = [], s = 0; s < n.length; s++) {
  354. var a = n[s];
  355. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  356. }
  357. return i;
  358. }, e.isEmpty = function(e) {
  359. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  360. }, e.isFunction = function(e) {
  361. return '[object Function]' === n(e);
  362. }, e.isImageUrl = function(e) {
  363. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  364. }, e.isObject = d, e.isRegexp = function(e) {
  365. return '[object RegExp]' === n(e);
  366. }, e.objectKeyToCamelCase = function e(n, o, t) {
  367. if (Array.isArray(n)) {
  368. for (var r = [], i = 0; i < n.length; i++) {
  369. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  370. }
  371. } else if (d(n)) {
  372. r = {};
  373. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  374. var f = (u = c[a])[0], u = u[1];
  375. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  376. }
  377. } else {
  378. r = n;
  379. }
  380. return r;
  381. }, e.realType = n, e.searchParams = function(e, n) {
  382. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  383. new URLSearchParams(e).get(n);
  384. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  385. return e.replace(/([A-Z])/g, function(e) {
  386. return '_'.concat(e.toLocaleLowerCase());
  387. });
  388. }, e.ua = function(e) {
  389. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  390. }, Object.defineProperty(e, '__esModule', {
  391. value: !0
  392. });
  393. });
  394. },
  395. 786: function(module, __webpack_exports__, __webpack_require__) {
  396. 'use strict';
  397. __webpack_require__.d(__webpack_exports__, {
  398. Z: function() {
  399. return __WEBPACK_DEFAULT_EXPORT__;
  400. }
  401. });
  402. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  403. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  404. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  405. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  406. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  407. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(20px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}.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;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:150px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}', '' ]);
  408. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  409. },
  410. 400: function(module) {
  411. 'use strict';
  412. module.exports = function(cssWithMappingToString) {
  413. var list = [];
  414. list.toString = function toString() {
  415. return this.map(function(item) {
  416. var content = '';
  417. var needLayer = typeof item[5] !== 'undefined';
  418. if (item[4]) {
  419. content += '@supports ('.concat(item[4], ') {');
  420. }
  421. if (item[2]) {
  422. content += '@media '.concat(item[2], ' {');
  423. }
  424. if (needLayer) {
  425. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  426. }
  427. content += cssWithMappingToString(item);
  428. if (needLayer) {
  429. content += '}';
  430. }
  431. if (item[2]) {
  432. content += '}';
  433. }
  434. if (item[4]) {
  435. content += '}';
  436. }
  437. return content;
  438. }).join('');
  439. };
  440. list.i = function i(modules, media, dedupe, supports, layer) {
  441. if (typeof modules === 'string') {
  442. modules = [ [ null, modules, undefined ] ];
  443. }
  444. var alreadyImportedModules = {};
  445. if (dedupe) {
  446. for (var k = 0; k < this.length; k++) {
  447. var id = this[k][0];
  448. if (id != null) {
  449. alreadyImportedModules[id] = true;
  450. }
  451. }
  452. }
  453. for (var _k = 0; _k < modules.length; _k++) {
  454. var item = [].concat(modules[_k]);
  455. if (dedupe && alreadyImportedModules[item[0]]) {
  456. continue;
  457. }
  458. if (typeof layer !== 'undefined') {
  459. if (typeof item[5] === 'undefined') {
  460. item[5] = layer;
  461. } else {
  462. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  463. item[5] = layer;
  464. }
  465. }
  466. if (media) {
  467. if (!item[2]) {
  468. item[2] = media;
  469. } else {
  470. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  471. item[2] = media;
  472. }
  473. }
  474. if (supports) {
  475. if (!item[4]) {
  476. item[4] = ''.concat(supports);
  477. } else {
  478. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  479. item[4] = supports;
  480. }
  481. }
  482. list.push(item);
  483. }
  484. };
  485. return list;
  486. };
  487. },
  488. 220: function(module) {
  489. 'use strict';
  490. module.exports = function(i) {
  491. return i[1];
  492. };
  493. }
  494. };
  495. var __webpack_module_cache__ = {};
  496. function __webpack_require__(moduleId) {
  497. var cachedModule = __webpack_module_cache__[moduleId];
  498. if (cachedModule !== undefined) {
  499. return cachedModule.exports;
  500. }
  501. var module = __webpack_module_cache__[moduleId] = {
  502. id: moduleId,
  503. exports: {}
  504. };
  505. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  506. return module.exports;
  507. }
  508. !function() {
  509. __webpack_require__.n = function(module) {
  510. var getter = module && module.__esModule ? function() {
  511. return module['default'];
  512. } : function() {
  513. return module;
  514. };
  515. __webpack_require__.d(getter, {
  516. a: getter
  517. });
  518. return getter;
  519. };
  520. }();
  521. !function() {
  522. __webpack_require__.d = function(exports, definition) {
  523. for (var key in definition) {
  524. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  525. Object.defineProperty(exports, key, {
  526. enumerable: true,
  527. get: definition[key]
  528. });
  529. }
  530. }
  531. };
  532. }();
  533. !function() {
  534. __webpack_require__.o = function(obj, prop) {
  535. return Object.prototype.hasOwnProperty.call(obj, prop);
  536. };
  537. }();
  538. var __webpack_exports__ = {};
  539. !function() {
  540. 'use strict';
  541. const external_Swal_namespaceObject = Swal;
  542. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  543. const external_Cookies_namespaceObject = Cookies;
  544. var auto_task = __webpack_require__(786);
  545. var javascript_utils_umd_min = __webpack_require__(514);
  546. const httpRequest = async function(options) {
  547. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  548. try {
  549. const result = await new Promise(resolve => {
  550. if (options.dataType) {
  551. options.responseType = options.dataType;
  552. }
  553. const requestObj = {
  554. ...{
  555. timeout: 3e4,
  556. ontimeout(data) {
  557. resolve({
  558. result: 'Error',
  559. statusText: 'Timeout',
  560. status: 601,
  561. data: data,
  562. options: options
  563. });
  564. },
  565. onabort(data) {
  566. resolve({
  567. result: 'Error',
  568. statusText: 'Aborted',
  569. status: 602,
  570. data: data,
  571. options: options
  572. });
  573. },
  574. onerror(data) {
  575. resolve({
  576. result: 'Error',
  577. statusText: 'Error',
  578. status: 603,
  579. data: data,
  580. options: options
  581. });
  582. },
  583. onload(data) {
  584. resolve({
  585. result: 'Success',
  586. statusText: 'Load',
  587. status: 600,
  588. data: data,
  589. options: options
  590. });
  591. }
  592. },
  593. ...options
  594. };
  595. GM_xmlhttpRequest(requestObj);
  596. });
  597. console.log('发送请求:', result);
  598. if (result.status !== 600 && times < 2) {
  599. return await httpRequest(options, times + 1);
  600. }
  601. return result;
  602. } catch (error) {
  603. throwError(error, 'httpRequest');
  604. console.log('发送请求:', {
  605. errorMsg: error,
  606. options: options
  607. });
  608. return {
  609. result: 'JsError',
  610. statusText: 'Error',
  611. status: 604,
  612. error: error,
  613. options: options
  614. };
  615. }
  616. };
  617. const tools_httpRequest = httpRequest;
  618. const echoLog = _ref => {
  619. let {
  620. type,
  621. text,
  622. html,
  623. id
  624. } = _ref;
  625. const emptyStatus = {
  626. success: () => emptyStatus,
  627. error: () => emptyStatus,
  628. warning: () => emptyStatus,
  629. info: () => emptyStatus,
  630. view: () => emptyStatus
  631. };
  632. try {
  633. var _ele$;
  634. let ele;
  635. if (type) {
  636. switch (type) {
  637. case 'joiningSteamGroup':
  638. case 'leavingSteamGroup':
  639. case 'gettingSteamGroupId':
  640. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  641. break;
  642.  
  643. case 'subscribingForum':
  644. case 'unsubscribingForum':
  645. case 'gettingForumId':
  646. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  647. break;
  648.  
  649. case 'followingCurator':
  650. case 'unfollowingCurator':
  651. case 'getCuratorId':
  652. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>...<font></font></li>`);
  653. break;
  654.  
  655. case 'addingToWishlist':
  656. case 'removingFromWishlist':
  657. case 'followingGame':
  658. case 'unfollowingGame':
  659. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  660. break;
  661.  
  662. case 'favoritingWorkshop':
  663. case 'unfavoritingWorkshop':
  664. case 'gettingWorkshopAppId':
  665. case 'votingUpWorkshop':
  666. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  667. ${text}</a>...<font></font></li>`);
  668. break;
  669.  
  670. case 'gettingAnnouncementParams':
  671. case 'likingAnnouncement':
  672. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  673. ${id}</a>...<font></font></li>`);
  674. break;
  675.  
  676. case 'joiningDiscordServer':
  677. case 'gettingDiscordGuild':
  678. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  679. break;
  680.  
  681. case 'leavingDiscordServer':
  682. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  683. break;
  684.  
  685. case 'updateDiscordAuth':
  686. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  687. break;
  688.  
  689. case 'followingTwitchChannel':
  690. case 'unfollowingTwitchChannel':
  691. case 'gettingTwitchChannelId':
  692. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  693. break;
  694.  
  695. case 'gettingInsUserId':
  696. case 'followingIns':
  697. case 'unfollowingIns':
  698. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  699. break;
  700.  
  701. case 'gettingTwitterUserId':
  702. case 'followingTwitterUser':
  703. case 'unfollowingTwitterUser':
  704. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  705. break;
  706.  
  707. case 'retweetting':
  708. case 'unretweetting':
  709. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  710. break;
  711.  
  712. case 'joiningReddit':
  713. case 'leavingReddit':
  714. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  715. break;
  716.  
  717. case 'followingRedditUser':
  718. case 'unfollowingRedditUser':
  719. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  720. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  721. break;
  722.  
  723. case 'followingYtbChannel':
  724. case 'unfollowingYtbChannel':
  725. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  726. break;
  727.  
  728. case 'likingYtbVideo':
  729. case 'unlikingYtbVideo':
  730. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  731. break;
  732.  
  733. case 'gettingVkId':
  734. case 'joiningVkGroup':
  735. case 'leavingVkGroup':
  736. case 'joiningVkPublic':
  737. case 'leavingVkPublic':
  738. case 'sendingVkWall':
  739. case 'deletingVkWall':
  740. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  741. break;
  742.  
  743. case 'visitingLink':
  744. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  745. break;
  746.  
  747. case 'verifyingInsAuth':
  748. case 'text':
  749. ele = $(`<li>${i18n(text)}<font></font></li>`);
  750. break;
  751.  
  752. case 'html':
  753. ele = $(text || html);
  754. break;
  755.  
  756. case 'whiteList':
  757. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  758. break;
  759.  
  760. case 'globalOptionsSkip':
  761. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  762. break;
  763.  
  764. default:
  765. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  766. break;
  767. }
  768. } else if (text) {
  769. ele = $(`<li>${i18n(text)}<font></font></li>`);
  770. } else if (html) {
  771. ele = $(html);
  772. } else {
  773. return emptyStatus;
  774. }
  775. ele.addClass('card-text');
  776. $('#auto-task-info').append(ele);
  777. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  778. const font = ele.find('font');
  779. const status = {
  780. font: font,
  781. success() {
  782. var _this$font, _this$font2, _this$font3;
  783. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  784. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  785. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  786. html ? (_this$font2 = this.font) === null || _this$font2 === void 0 ? void 0 : _this$font2.html(text) : (_this$font3 = this.font) === null || _this$font3 === void 0 ? void 0 : _this$font3.text(text);
  787. return this;
  788. },
  789. error() {
  790. var _this$font4, _this$font5, _this$font6;
  791. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  792. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  793. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  794. html ? (_this$font5 = this.font) === null || _this$font5 === void 0 ? void 0 : _this$font5.html(text) : (_this$font6 = this.font) === null || _this$font6 === void 0 ? void 0 : _this$font6.text(text);
  795. return this;
  796. },
  797. warning() {
  798. var _this$font7, _this$font8, _this$font9;
  799. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  800. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  801. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  802. html ? (_this$font8 = this.font) === null || _this$font8 === void 0 ? void 0 : _this$font8.html(text) : (_this$font9 = this.font) === null || _this$font9 === void 0 ? void 0 : _this$font9.text(text);
  803. return this;
  804. },
  805. info() {
  806. var _this$font10, _this$font11, _this$font12;
  807. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  808. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  809. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  810. html ? (_this$font11 = this.font) === null || _this$font11 === void 0 ? void 0 : _this$font11.html(text) : (_this$font12 = this.font) === null || _this$font12 === void 0 ? void 0 : _this$font12.text(text);
  811. return this;
  812. },
  813. view() {
  814. var _this$font13;
  815. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  816. return this;
  817. }
  818. };
  819. return status;
  820. } catch (error) {
  821. throwError(error, 'echoLog');
  822. return emptyStatus;
  823. }
  824. };
  825. const scripts_echoLog = echoLog;
  826. const unique = array => {
  827. try {
  828. return [ ...new Set(array) ];
  829. } catch (error) {
  830. throwError(error, 'unique');
  831. return [];
  832. }
  833. };
  834. const delay = function() {
  835. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  836. return new Promise(resolve => {
  837. setTimeout(() => {
  838. resolve(true);
  839. }, time);
  840. });
  841. };
  842. const getRedirectLink = async link => {
  843. try {
  844. if (!link) {
  845. return null;
  846. }
  847. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  848. if (redirectLinksCache[link]) {
  849. redirectLinksCache[link];
  850. }
  851. return await tools_httpRequest({
  852. url: link,
  853. method: 'GET'
  854. }).then(_ref => {
  855. let {
  856. data
  857. } = _ref;
  858. if (data !== null && data !== void 0 && data.finalUrl) {
  859. redirectLinksCache[link] = data.finalUrl;
  860. GM_setValue('redirectLinks', redirectLinksCache);
  861. return data.finalUrl;
  862. }
  863. return null;
  864. });
  865. } catch (error) {
  866. throwError(error, 'getRedirectLink');
  867. return null;
  868. }
  869. };
  870. const visitLink = async (link, options) => {
  871. try {
  872. const logStatus = scripts_echoLog({
  873. type: 'visitLink',
  874. text: link
  875. });
  876. return await tools_httpRequest({
  877. url: link,
  878. method: 'GET',
  879. ...options
  880. }).then(_ref2 => {
  881. let {
  882. result,
  883. statusText,
  884. status
  885. } = _ref2;
  886. if (result === 'Success') {
  887. logStatus.success();
  888. return true;
  889. }
  890. logStatus.error(`${result}:${statusText}(${status})`);
  891. return false;
  892. });
  893. } catch (error) {
  894. throwError(error, 'visitLink');
  895. return false;
  896. }
  897. };
  898. const getUrlQuery = url => {
  899. try {
  900. const query = {};
  901. if (url) {
  902. if (url.includes('?')) {
  903. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  904. query[key] = value;
  905. return str;
  906. });
  907. }
  908. } else {
  909. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  910. query[key] = value;
  911. return str;
  912. });
  913. }
  914. return query;
  915. } catch (error) {
  916. throwError(error, 'getUrlQuery');
  917. return {};
  918. }
  919. };
  920. const getUuid = () => {
  921. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  922. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  923. };
  924. const stringToColour = str => {
  925. try {
  926. let hash = 0;
  927. for (let i = 0; i < str.length; i++) {
  928. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  929. }
  930. let colour = '#';
  931. for (let i = 0; i < 3; i++) {
  932. const value = hash >> i * 8 & 255;
  933. colour += `00${value.toString(16)}`.slice(-2);
  934. }
  935. return colour;
  936. } catch (error) {
  937. throwError(error, 'stringToColour');
  938. return '#fff';
  939. }
  940. };
  941. const defaultGlobalOptions = {
  942. doTask: {
  943. discord: {
  944. servers: true
  945. },
  946. instagram: {
  947. users: true
  948. },
  949. twitch: {
  950. channels: true
  951. },
  952. twitter: {
  953. users: true,
  954. retweets: true
  955. },
  956. vk: {
  957. names: true
  958. },
  959. youtube: {
  960. channels: true,
  961. likes: true
  962. },
  963. reddit: {
  964. reddits: true
  965. },
  966. steam: {
  967. groups: true,
  968. wishlists: true,
  969. follows: true,
  970. forums: true,
  971. workshops: true,
  972. curators: true,
  973. workshopVotes: true,
  974. announcements: true
  975. }
  976. },
  977. undoTask: {
  978. discord: {
  979. servers: true
  980. },
  981. instagram: {
  982. users: true
  983. },
  984. twitch: {
  985. channels: true
  986. },
  987. twitter: {
  988. users: true,
  989. retweets: true
  990. },
  991. vk: {
  992. names: true
  993. },
  994. youtube: {
  995. channels: true,
  996. likes: true
  997. },
  998. reddit: {
  999. reddits: true
  1000. },
  1001. steam: {
  1002. groups: true,
  1003. wishlists: true,
  1004. follows: true,
  1005. forums: true,
  1006. workshops: true,
  1007. curators: true
  1008. }
  1009. },
  1010. position: {
  1011. buttonSideX: 'right',
  1012. buttonSideY: 'top',
  1013. buttonDistance: '15,30',
  1014. showButtonSideX: 'right',
  1015. showButtonSideY: 'top',
  1016. showButtonDistance: '15,30',
  1017. logSideX: 'right',
  1018. logSideY: 'bottom',
  1019. logDistance: '10,10'
  1020. },
  1021. hotKey: {
  1022. doTaskKey: 'alt + d',
  1023. undoTaskKey: 'alt + u',
  1024. toggleLogKey: 'alt + l'
  1025. },
  1026. other: {
  1027. twitterVerifyId: '783214',
  1028. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1029. autoUpdateSource: 'jsDelivr',
  1030. language: 'zh',
  1031. checkLogin: true,
  1032. checkLeftKey: true,
  1033. defaultShowButton: true,
  1034. defaultShowLog: true
  1035. }
  1036. };
  1037. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1038. const assignObject = (obj1, obj2) => {
  1039. try {
  1040. const newObj = {};
  1041. for (const [ key, value ] of Object.entries(obj1)) {
  1042. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1043. newObj[key] = assignObject(value, obj2[key]);
  1044. } else {
  1045. newObj[key] = obj2[key] ?? value;
  1046. }
  1047. }
  1048. return newObj;
  1049. } catch (error) {
  1050. throwError(error, 'assignObject');
  1051. return defaultGlobalOptions;
  1052. }
  1053. };
  1054. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1055. const saveData = () => {
  1056. try {
  1057. const data = {};
  1058. $('#globalOptionsForm').serializeArray().map(value => {
  1059. data[value.name] = value.value;
  1060. return value;
  1061. });
  1062. $.makeArray($('#globalOptionsForm input')).map(element => {
  1063. const name = $(element).attr('name');
  1064. const keys = name.split('.');
  1065. if (keys.length === 3) {
  1066. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1067. } else if (keys.length === 2) {
  1068. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1069. }
  1070. return element;
  1071. });
  1072. GM_setValue('globalOptions', globalOptions);
  1073. external_Swal_default().fire({
  1074. title: i18n('changeGlobalOptionsSuccess'),
  1075. icon: 'success'
  1076. });
  1077. } catch (error) {
  1078. throwError(error, 'saveData');
  1079. }
  1080. };
  1081. const changeGlobalOptions = showType => {
  1082. try {
  1083. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1084. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1085. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1086. for (const [ option, data2 ] of Object.entries(data1)) {
  1087. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1088. if (typeof data2 === 'boolean') {
  1089. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><label><input type="checkbox" name="${type}.${option}"${data2 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1090. } else {
  1091. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><input class="editOption" type="text" name="${type}.${option}" value="${data2}"/></td></tr>`;
  1092. }
  1093. } else {
  1094. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1095. globalOptionsForm += `<tr style="background-color: ${stringToColour(option)}66">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).map(key => Object.keys(data1[key]).length).reduce((acr, cur) => acr + cur)}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${option}.${i18n(socialType)}</td><td><label><input type="checkbox" name="${type}.${option}.${socialType}"${data3 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1096. }
  1097. }
  1098. }
  1099. }
  1100. globalOptionsForm += '</tbody></table></form>';
  1101. if (showType === 'swal') {
  1102. external_Swal_default().fire({
  1103. title: i18n('globalOptions'),
  1104. html: globalOptionsForm,
  1105. showConfirmButton: true,
  1106. confirmButtonText: i18n('save'),
  1107. showCancelButton: true,
  1108. cancelButtonText: i18n('close')
  1109. }).then(_ref => {
  1110. let {
  1111. isConfirmed
  1112. } = _ref;
  1113. if (isConfirmed) {
  1114. saveData();
  1115. }
  1116. });
  1117. } else {
  1118. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1119. }
  1120. } catch (error) {
  1121. throwError(error, 'changeGlobalOptions');
  1122. }
  1123. };
  1124. const data = {
  1125. website: '网站',
  1126. type: '类型',
  1127. edit: '编辑',
  1128. whiteList: '白名单',
  1129. skipTask: '跳过撤销任务',
  1130. whiteListOptions: '白名单设置',
  1131. changeWhiteListOption: '设置白名单(%0)',
  1132. whiteListNotFound: '找不到此项白名单: %0',
  1133. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1134. changeWebsiteOptions: '网站设置',
  1135. changeGlobalOptions: '全局设置',
  1136. ok: '是',
  1137. save: '保存',
  1138. close: '关闭',
  1139. return: '返回',
  1140. option: '选项',
  1141. value: '值',
  1142. websiteOptions: '当前网站设置',
  1143. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1144. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1145. needLogin: '请先登录!',
  1146. getTasksInfo: '正在获取并处理任务信息...',
  1147. gettingKey: '正在获取Key...',
  1148. verifyingTask: '正在验证任务',
  1149. notice: '自动任务脚本提醒',
  1150. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1151. giveawayEnded: '此活动已结束,是否关闭?',
  1152. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1153. confirm: '确定',
  1154. cancel: '取消',
  1155. unKnown: '未知',
  1156. unKnownTaskType: '未识别的任务',
  1157. doing: '正在做任务',
  1158. allTasksComplete: '所有任务已完成!',
  1159. getTaskIdFailed: '获取任务Id失败!',
  1160. initSuccess: '%0 初始化成功!',
  1161. initFailed: '%0 初始化失败!',
  1162. errorLink: '链接错误: %0',
  1163. needInit: '请先初始化',
  1164. verifyingAuth: '正在验证%0凭证...',
  1165. updatingAuth: '正在更新%0凭证...',
  1166. initing: '正在初始化...',
  1167. getFailed: '获取%0失败!',
  1168. checkLoginFailed: '检测登录状态失败!',
  1169. checkLeftKeyFailed: '检测剩余Key失败!',
  1170. userId: '用户Id',
  1171. joiningGiveaway: '正在加入赠Key',
  1172. needJoinGiveaway: '需要先加入赠Key',
  1173. cannotUndo: '此网站不支持取消任务',
  1174. verifyAuth: '正在验证 %0 凭证...',
  1175. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1176. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1177. visitingLink: '正在访问链接: ',
  1178. doTask: '做任务',
  1179. undoTask: '撤销任务',
  1180. verifyTask: '验证任务',
  1181. getKey: '获取Key',
  1182. selectAll: '全选',
  1183. selectNone: '全不选',
  1184. invertSelect: '反选',
  1185. doFreeTask: '加入免费赠品',
  1186. doPointTask: '加入点数赠品',
  1187. skipTaskOption: '设置中已配置跳过任务',
  1188. other: '其他',
  1189. globalOptions: '全局设置',
  1190. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1191. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1192. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214',
  1193. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q',
  1194. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>auto: 首先使用github源更新,失败后尝试用jsdelivr源更新',
  1195. saveGlobalOptions: '保存全局设置',
  1196. settingPage: '设置页面',
  1197. name: '名称',
  1198. version: '版本',
  1199. scriptManager: '脚本管理器',
  1200. script: '脚本',
  1201. environment: '环境',
  1202. os: '系统',
  1203. browser: '浏览器',
  1204. getId: '获取 %0 id',
  1205. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1206. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1207. showButton: '显示按钮',
  1208. hideButton: '隐藏按钮',
  1209. showLog: '显示日志',
  1210. hideLog: '隐藏日志',
  1211. defaultShowButton: '默认显示按钮',
  1212. defaultShowLog: '默认显示日志',
  1213. position: '组件位置',
  1214. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1215. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1216. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1217. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1218. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1219. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1220. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1221. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1222. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1223. hotKey: '快捷键',
  1224. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1225. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1226. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1227. tasksHistory: '任务历史',
  1228. clearHistory: '清空历史',
  1229. clearHistoryFinished: '已清空任务历史!',
  1230. deleteTask: '删除任务',
  1231. lastChangeTime: '最后一次修改时间',
  1232. clearTaskFinished: '删除以下任务完成!',
  1233. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1234. syncData: '数据同步',
  1235. settingData: '正在上传数据...',
  1236. gettingData: '正在获取数据...',
  1237. help: '帮助',
  1238. fileName: '文件名',
  1239. upload2gist: '同步到Gist',
  1240. downloadFromGist: '从Gist同步',
  1241. saveAndTest: '保存配置并测试',
  1242. testSuccess: '测试成功!',
  1243. testFailed: '测试失败!',
  1244. saveAndTestNotice: '请先保存配置并测试!',
  1245. processingData: '正在处理数据...',
  1246. updatingData: '正在上传数据...',
  1247. syncDataSuccess: '同步数据成功!',
  1248. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1249. downloadingData: '正在下载数据...',
  1250. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1251. savingData: '正在保存数据...',
  1252. syncHistory: '同步任务历史',
  1253. checkUpdateFailed: '检测更新失败',
  1254. newVersionNotice: '检测到新版本V%0, <a href="%1" target="_blank">点此更新</a>',
  1255. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1256. gistOptions: 'Gist 设置',
  1257. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1258. echoNotice: '检测到您第一次安装V4版本脚本,请<a href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1259. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1260. toGithub: '前往Github反馈',
  1261. toKeylol: '前往其乐论坛反馈',
  1262. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1263. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1264. 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 (ended/suspended/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>auto: First use github source to update, after failure, try to update with jsdelivr source.',
  1429. saveGlobalOptions: 'Save global settings',
  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: 'Tasks history',
  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. groups: 'Group',
  1499. wishlists: 'Wishlist',
  1500. follows: 'Follow Game',
  1501. forums: 'Forum',
  1502. workshops: 'Favorite Workshop',
  1503. curators: 'Curator',
  1504. workshopVotes: 'Voteup Workshop',
  1505. announcements: 'Announcement',
  1506. steamCommunity: 'Steam Community',
  1507. steamStore: 'Steam Store',
  1508. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1509. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1510. joiningSteamGroup: 'Joining Steam Group',
  1511. leavingSteamGroup: 'Leaving Steam Group',
  1512. gettingSteamGroupId: 'Getting Steam Group Id',
  1513. subscribingForum: 'Subscribing the Steam Forum',
  1514. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1515. gettingForumId: 'Getting Steam Forum Id',
  1516. followingCurator: 'Following Steam Curator',
  1517. unfollowingCurator: 'Unfollowing Steam Curator',
  1518. addingToWishlist: 'Adding the game to the Steam wishlist',
  1519. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1520. followingGame: 'Following Steam games',
  1521. unfollowingGame: 'Unfollowing Steam games',
  1522. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1523. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1524. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1525. votingUpWorkshop: 'Liking Steam workshop items',
  1526. gettingAnnouncementParams: 'Getting Steam announcement information',
  1527. likingAnnouncement: 'Liking Steam announcement',
  1528. changingArea: 'Changing Steam area: %0...',
  1529. notNeededChangeArea: 'The current area does not need to be changed',
  1530. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1531. gettingAreaInfo: 'Getting Steam area information...',
  1532. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1533. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1534. servers: 'Server',
  1535. joiningDiscordServer: 'Joining Discord Server',
  1536. leavingDiscordServer: 'Leaving Discord Server',
  1537. gettingDiscordGuild: 'Getting Discord server Id',
  1538. users: 'User',
  1539. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1540. insBanned: 'Your Instagram account has been banned',
  1541. verifyingInsAuth: 'Verifying Instagram token...',
  1542. gettingInsUserId: 'Getting Instagram user Id',
  1543. followingIns: 'Following Instagram user',
  1544. unfollowingIns: 'Unfollowing Instagram user',
  1545. reddits: 'Reddit/User',
  1546. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1547. changingRedditVersion: 'Switching Reddit to a new version page...',
  1548. joiningReddit: 'Joining the Reddit',
  1549. leavingReddit: 'Leaving the Reddit',
  1550. followingRedditUser: 'Following Reddit User',
  1551. unfollowingRedditUser: 'Unfollowing Reddit User',
  1552. channels: 'Channel',
  1553. followingTwitchChannel: 'Following Twitch Channel',
  1554. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1555. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1556. twitterUser: 'Twitter User',
  1557. retweets: 'Retweet',
  1558. followingTwitterUser: 'Following Twitter User',
  1559. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1560. retweetting: 'Retweeting',
  1561. unretweetting: 'Unretweeting',
  1562. names: 'Group/Public/Wall',
  1563. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1564. gettingVkId: 'Getting Vk task Id',
  1565. joiningVkGroup: 'Joining Vk Group',
  1566. leavingVkGroup: 'Leaving Vk Group',
  1567. joiningVkPublic: 'Joining Vk Public',
  1568. leavingVkPublic: 'Leaving Vk Public',
  1569. sendingVkWall: 'Sending Vk Wall',
  1570. deletingVkWall: 'Deleting Vk Wall',
  1571. youtubeChannel: 'YouTube Channel',
  1572. likes: 'Like',
  1573. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1574. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1575. gettingYtbToken: 'Getting YouTube Token...',
  1576. followingYtbChannel: 'Subscribing to YouTube channel',
  1577. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1578. likingYtbVideo: 'Liking YouTube video',
  1579. unlikingYtbVideo: 'Unliking YouTube video',
  1580. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1581. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1582. noPoints: 'Not enough points, skip the lottery',
  1583. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1584. joiningLottery: 'Joining the lottery',
  1585. doingGleamTask: 'Doing Gleam Task...',
  1586. gettingGleamLink: 'Getting Gleam task link...',
  1587. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1588. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1589. 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...'
  1590. };
  1591. const en_US = en_US_data;
  1592. const languages = {
  1593. zh: zh_CN,
  1594. en: en_US
  1595. };
  1596. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1597. const I18n = function(key) {
  1598. var _languages$language;
  1599. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1600. argvs[_key - 1] = arguments[_key];
  1601. }
  1602. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1603. return key;
  1604. }
  1605. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1606. };
  1607. const i18n = I18n;
  1608. function throwError(error, name) {
  1609. external_Swal_default().fire({
  1610. title: i18n('errorReport'),
  1611. icon: 'error',
  1612. showCancelButton: true,
  1613. confirmButtonText: i18n('toGithub'),
  1614. showDenyButton: true,
  1615. denyButtonText: i18n('toKeylol'),
  1616. cancelButtonText: i18n('close')
  1617. }).then(_ref => {
  1618. let {
  1619. isDenied,
  1620. isConfirmed
  1621. } = _ref;
  1622. if (isConfirmed) {
  1623. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1624.  
  1625. 环境:
  1626. \`\`\`
  1627. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1628. \`\`\`
  1629. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1630. 脚本版本: \`${GM_info.script.version}\`
  1631.  
  1632. 报错信息:
  1633. \`\`\`
  1634. ${error.stack}
  1635. \`\`\`
  1636.  
  1637. 执行日志:
  1638. \`\`\`
  1639. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1640. \`\`\`
  1641. `)}`, '_blank');
  1642. } else if (isDenied) {
  1643. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1644.  
  1645. 环境:
  1646.  
  1647. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1648.  
  1649. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1650. 脚本版本: ${GM_info.script.version}
  1651.  
  1652. 报错信息:
  1653. [code]${error.stack}[/code]
  1654.  
  1655. 执行日志:
  1656. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1657. const textarea = $('<textarea>');
  1658. $('body').append(textarea);
  1659. textarea.val(text).trigger('select');
  1660. if (document.execCommand('Copy')) {
  1661. external_Swal_default().fire({
  1662. title: i18n('copySuccess'),
  1663. icon: 'success',
  1664. confirmButtonText: i18n('ok')
  1665. }).then(() => {
  1666. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1667. });
  1668. } else {
  1669. external_Swal_default().fire({
  1670. title: i18n('copyFailed'),
  1671. input: 'textarea',
  1672. inputValue: text,
  1673. confirmButtonText: i18n('ok')
  1674. }).then(() => {
  1675. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1676. });
  1677. }
  1678. textarea.remove();
  1679. }
  1680. });
  1681. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1682. }
  1683. function _defineProperty(obj, key, value) {
  1684. if (key in obj) {
  1685. Object.defineProperty(obj, key, {
  1686. value: value,
  1687. enumerable: true,
  1688. configurable: true,
  1689. writable: true
  1690. });
  1691. } else {
  1692. obj[key] = value;
  1693. }
  1694. return obj;
  1695. }
  1696. class Social {
  1697. constructor() {
  1698. _defineProperty(this, 'tasks', void 0);
  1699. }
  1700. getRealParams(name, links, doTask, link2param) {
  1701. try {
  1702. let realParams = [];
  1703. if (links.length > 0) {
  1704. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1705. }
  1706. if (!doTask && this.tasks[name].length > 0) {
  1707. realParams = [ ...realParams, ...this.tasks[name] ];
  1708. }
  1709. return unique(realParams);
  1710. } catch (error) {
  1711. throwError(error, 'Social.getRealParams');
  1712. return [];
  1713. }
  1714. }
  1715. }
  1716. const social_Social = Social;
  1717. function _classPrivateMethodInitSpec(obj, privateSet) {
  1718. _checkPrivateRedeclaration(obj, privateSet);
  1719. privateSet.add(obj);
  1720. }
  1721. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1722. _checkPrivateRedeclaration(obj, privateMap);
  1723. privateMap.set(obj, value);
  1724. }
  1725. function _checkPrivateRedeclaration(obj, privateCollection) {
  1726. if (privateCollection.has(obj)) {
  1727. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1728. }
  1729. }
  1730. function Discord_defineProperty(obj, key, value) {
  1731. if (key in obj) {
  1732. Object.defineProperty(obj, key, {
  1733. value: value,
  1734. enumerable: true,
  1735. configurable: true,
  1736. writable: true
  1737. });
  1738. } else {
  1739. obj[key] = value;
  1740. }
  1741. return obj;
  1742. }
  1743. function _classPrivateFieldSet(receiver, privateMap, value) {
  1744. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1745. _classApplyDescriptorSet(receiver, descriptor, value);
  1746. return value;
  1747. }
  1748. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1749. if (descriptor.set) {
  1750. descriptor.set.call(receiver, value);
  1751. } else {
  1752. if (!descriptor.writable) {
  1753. throw new TypeError('attempted to set read only private field');
  1754. }
  1755. descriptor.value = value;
  1756. }
  1757. }
  1758. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1759. if (!privateSet.has(receiver)) {
  1760. throw new TypeError('attempted to get private field on non-instance');
  1761. }
  1762. return fn;
  1763. }
  1764. function _classPrivateFieldGet(receiver, privateMap) {
  1765. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1766. return _classApplyDescriptorGet(receiver, descriptor);
  1767. }
  1768. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1769. if (!privateMap.has(receiver)) {
  1770. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1771. }
  1772. return privateMap.get(receiver);
  1773. }
  1774. function _classApplyDescriptorGet(receiver, descriptor) {
  1775. if (descriptor.get) {
  1776. return descriptor.get.call(receiver);
  1777. }
  1778. return descriptor.value;
  1779. }
  1780. const defaultTasks = {
  1781. servers: []
  1782. };
  1783. var _auth = new WeakMap();
  1784. var _cache = new WeakMap();
  1785. var _initialized = new WeakMap();
  1786. var _verifyAuth = new WeakSet();
  1787. var _updateAuth = new WeakSet();
  1788. var _joinServer = new WeakSet();
  1789. var _leaveServer = new WeakSet();
  1790. var _getGuild = new WeakSet();
  1791. var _setCache = new WeakSet();
  1792. class Discord extends social_Social {
  1793. constructor() {
  1794. var _GM_getValue;
  1795. super(...arguments);
  1796. _classPrivateMethodInitSpec(this, _setCache);
  1797. _classPrivateMethodInitSpec(this, _getGuild);
  1798. _classPrivateMethodInitSpec(this, _leaveServer);
  1799. _classPrivateMethodInitSpec(this, _joinServer);
  1800. _classPrivateMethodInitSpec(this, _updateAuth);
  1801. _classPrivateMethodInitSpec(this, _verifyAuth);
  1802. Discord_defineProperty(this, 'tasks', {
  1803. ...defaultTasks
  1804. });
  1805. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || {
  1806. ...defaultTasks
  1807. });
  1808. _classPrivateFieldInitSpec(this, _auth, {
  1809. writable: true,
  1810. value: GM_getValue('discordAuth') || {}
  1811. });
  1812. _classPrivateFieldInitSpec(this, _cache, {
  1813. writable: true,
  1814. value: GM_getValue('discordCache') || {}
  1815. });
  1816. _classPrivateFieldInitSpec(this, _initialized, {
  1817. writable: true,
  1818. value: false
  1819. });
  1820. }
  1821. async init() {
  1822. try {
  1823. if (_classPrivateFieldGet(this, _initialized)) {
  1824. return true;
  1825. }
  1826. if (!_classPrivateFieldGet(this, _auth).auth) {
  1827. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1828. _classPrivateFieldSet(this, _initialized, true);
  1829. return true;
  1830. }
  1831. return false;
  1832. }
  1833. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1834. if (isVerified) {
  1835. scripts_echoLog({
  1836. html: `<li><font class="success">${i18n('initSuccess', 'Discord')}</font></li>`
  1837. });
  1838. _classPrivateFieldSet(this, _initialized, true);
  1839. return true;
  1840. }
  1841. GM_setValue('discordAuth', {
  1842. auth: null
  1843. });
  1844. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1845. scripts_echoLog({
  1846. html: `<li><font class="success">${i18n('initSuccess', 'Discord')}</font></li>`
  1847. });
  1848. _classPrivateFieldSet(this, _initialized, true);
  1849. return true;
  1850. }
  1851. scripts_echoLog({
  1852. html: `<li><font class="success">${i18n('initFailed', 'Discord')}</font></li>`
  1853. });
  1854. return false;
  1855. } catch (error) {
  1856. throwError(error, 'Discord.init');
  1857. return false;
  1858. }
  1859. }
  1860. async toggle(_ref) {
  1861. let {
  1862. doTask = true,
  1863. serverLinks = []
  1864. } = _ref;
  1865. try {
  1866. if (!_classPrivateFieldGet(this, _initialized)) {
  1867. scripts_echoLog({
  1868. text: i18n('needInit')
  1869. });
  1870. return false;
  1871. }
  1872. const prom = [];
  1873. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1874. scripts_echoLog({
  1875. type: 'globalOptionsSkip',
  1876. text: 'discord.servers'
  1877. });
  1878. } else {
  1879. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1880. var _link$match;
  1881. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1882. });
  1883. if (realServers.length > 0) {
  1884. for (const server of realServers) {
  1885. if (doTask) {
  1886. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1887. } else {
  1888. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1889. }
  1890. await delay(1e3);
  1891. }
  1892. }
  1893. }
  1894. return await Promise.all(prom).then(() => true);
  1895. } catch (error) {
  1896. throwError(error, 'Discord.toggleServers');
  1897. return false;
  1898. }
  1899. }
  1900. }
  1901. async function _verifyAuth2() {
  1902. try {
  1903. const logStatus = scripts_echoLog({
  1904. text: i18n('verifyingAuth', 'Discord')
  1905. });
  1906. const {
  1907. result,
  1908. statusText,
  1909. status,
  1910. data
  1911. } = await tools_httpRequest({
  1912. url: 'https://discord.com/api/v6/users/@me',
  1913. method: 'HEAD',
  1914. headers: {
  1915. authorization: _classPrivateFieldGet(this, _auth).auth
  1916. }
  1917. });
  1918. if (result === 'Success') {
  1919. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1920. logStatus.success();
  1921. return true;
  1922. }
  1923. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1924. return false;
  1925. }
  1926. logStatus.error(`${result}:${statusText}(${status})`);
  1927. return false;
  1928. } catch (error) {
  1929. throwError(error, 'Discord.verifyAuth');
  1930. return false;
  1931. }
  1932. }
  1933. async function _updateAuth2() {
  1934. try {
  1935. const logStatus = scripts_echoLog({
  1936. text: i18n('updatingAuth', 'Discord')
  1937. });
  1938. return await new Promise(resolve => {
  1939. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1940. active: true,
  1941. insert: true,
  1942. setParent: true
  1943. });
  1944. newTab.onclose = async () => {
  1945. var _GM_getValue2;
  1946. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1947. if (auth) {
  1948. _classPrivateFieldSet(this, _auth, {
  1949. auth: auth
  1950. });
  1951. logStatus.success();
  1952. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1953. } else {
  1954. logStatus.error('Error: Update discord auth failed!');
  1955. resolve(false);
  1956. }
  1957. };
  1958. });
  1959. } catch (error) {
  1960. throwError(error, 'Discord.updateAuth');
  1961. return false;
  1962. }
  1963. }
  1964. async function _joinServer2(inviteId) {
  1965. try {
  1966. const logStatus = scripts_echoLog({
  1967. type: 'joiningDiscordServer',
  1968. text: inviteId
  1969. });
  1970. const {
  1971. result,
  1972. statusText,
  1973. status,
  1974. data
  1975. } = await tools_httpRequest({
  1976. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1977. method: 'POST',
  1978. dataType: 'json',
  1979. headers: {
  1980. authorization: _classPrivateFieldGet(this, _auth).auth
  1981. }
  1982. });
  1983. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1984. var _data$response, _data$response$guild;
  1985. logStatus.success();
  1986. 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);
  1987. if (guild) {
  1988. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1989. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1990. }
  1991. return true;
  1992. }
  1993. logStatus.error(`${result}:${statusText}(${status})`);
  1994. return false;
  1995. } catch (error) {
  1996. throwError(error, 'Discord.joinServer');
  1997. return false;
  1998. }
  1999. }
  2000. async function _leaveServer2(inviteId) {
  2001. try {
  2002. if (this.whiteList.servers.includes(inviteId)) {
  2003. scripts_echoLog({
  2004. type: 'whiteList',
  2005. text: 'Discord.leaveServer',
  2006. id: inviteId
  2007. });
  2008. return true;
  2009. }
  2010. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2011. if (!guild) {
  2012. return false;
  2013. }
  2014. const logStatus = scripts_echoLog({
  2015. type: 'leavingDiscordServer',
  2016. text: guild
  2017. });
  2018. const {
  2019. result,
  2020. statusText,
  2021. status,
  2022. data
  2023. } = await tools_httpRequest({
  2024. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2025. method: 'DELETE',
  2026. headers: {
  2027. authorization: _classPrivateFieldGet(this, _auth).auth
  2028. }
  2029. });
  2030. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2031. logStatus.success();
  2032. return true;
  2033. }
  2034. logStatus.error(`${result}:${statusText}(${status})`);
  2035. return false;
  2036. } catch (error) {
  2037. throwError(error, 'Discord.leaveServer');
  2038. return false;
  2039. }
  2040. }
  2041. async function _getGuild2(inviteId) {
  2042. try {
  2043. const logStatus = scripts_echoLog({
  2044. type: 'gettingDiscordGuild',
  2045. text: inviteId
  2046. });
  2047. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2048. if (guild) {
  2049. logStatus.success();
  2050. return guild;
  2051. }
  2052. const {
  2053. result,
  2054. statusText,
  2055. status,
  2056. data
  2057. } = await tools_httpRequest({
  2058. url: `https://discord.com/invite/${inviteId}`,
  2059. method: 'GET'
  2060. });
  2061. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2062. var _data$responseText$ma;
  2063. 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];
  2064. if (guild) {
  2065. logStatus.success();
  2066. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2067. return guild;
  2068. }
  2069. logStatus.error(`${result}:${statusText}(${status})`);
  2070. return false;
  2071. }
  2072. logStatus.error(`${result}:${statusText}(${status})`);
  2073. return false;
  2074. } catch (error) {
  2075. throwError(error, 'Discord.getGuild');
  2076. return false;
  2077. }
  2078. }
  2079. function _setCache2(inviteId, guild) {
  2080. try {
  2081. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2082. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2083. } catch (error) {
  2084. throwError(error, 'Discord.setCache');
  2085. }
  2086. }
  2087. const social_Discord = Discord;
  2088. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2089. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2090. privateSet.add(obj);
  2091. }
  2092. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2093. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2094. privateMap.set(obj, value);
  2095. }
  2096. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2097. if (privateCollection.has(obj)) {
  2098. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2099. }
  2100. }
  2101. function Instagram_defineProperty(obj, key, value) {
  2102. if (key in obj) {
  2103. Object.defineProperty(obj, key, {
  2104. value: value,
  2105. enumerable: true,
  2106. configurable: true,
  2107. writable: true
  2108. });
  2109. } else {
  2110. obj[key] = value;
  2111. }
  2112. return obj;
  2113. }
  2114. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2115. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2116. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2117. return value;
  2118. }
  2119. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2120. if (descriptor.set) {
  2121. descriptor.set.call(receiver, value);
  2122. } else {
  2123. if (!descriptor.writable) {
  2124. throw new TypeError('attempted to set read only private field');
  2125. }
  2126. descriptor.value = value;
  2127. }
  2128. }
  2129. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2130. if (!privateSet.has(receiver)) {
  2131. throw new TypeError('attempted to get private field on non-instance');
  2132. }
  2133. return fn;
  2134. }
  2135. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2136. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2137. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2138. }
  2139. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2140. if (!privateMap.has(receiver)) {
  2141. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2142. }
  2143. return privateMap.get(receiver);
  2144. }
  2145. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2146. if (descriptor.get) {
  2147. return descriptor.get.call(receiver);
  2148. }
  2149. return descriptor.value;
  2150. }
  2151. const Instagram_defaultTasks = {
  2152. users: []
  2153. };
  2154. var Instagram_cache = new WeakMap();
  2155. var Instagram_auth = new WeakMap();
  2156. var Instagram_initialized = new WeakMap();
  2157. var _getUserInfo = new WeakSet();
  2158. var _followUser = new WeakSet();
  2159. var _unfollowUser = new WeakSet();
  2160. var Instagram_setCache = new WeakSet();
  2161. class Instagram extends social_Social {
  2162. constructor() {
  2163. var _GM_getValue;
  2164. super(...arguments);
  2165. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2166. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2167. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2168. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2169. Instagram_defineProperty(this, 'tasks', {
  2170. ...Instagram_defaultTasks
  2171. });
  2172. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || {
  2173. ...Instagram_defaultTasks
  2174. });
  2175. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2176. writable: true,
  2177. value: GM_getValue('instagramCache') || {}
  2178. });
  2179. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2180. writable: true,
  2181. value: {}
  2182. });
  2183. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2184. writable: true,
  2185. value: false
  2186. });
  2187. }
  2188. async init() {
  2189. try {
  2190. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2191. return true;
  2192. }
  2193. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2194. if (isVerified) {
  2195. scripts_echoLog({
  2196. html: `<li><font class="success">${i18n('initSuccess', 'Instagram')}</font></li>`
  2197. });
  2198. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2199. return true;
  2200. }
  2201. scripts_echoLog({
  2202. html: `<li><font class="success">${i18n('initFailed', 'Instagram')}</font></li>`
  2203. });
  2204. return false;
  2205. } catch (error) {
  2206. throwError(error, 'Instagram.init');
  2207. return false;
  2208. }
  2209. }
  2210. async toggle(_ref) {
  2211. let {
  2212. doTask = true,
  2213. userLinks = []
  2214. } = _ref;
  2215. try {
  2216. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2217. scripts_echoLog({
  2218. text: i18n('needInit')
  2219. });
  2220. return false;
  2221. }
  2222. const prom = [];
  2223. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2224. scripts_echoLog({
  2225. type: 'globalOptionsSkip',
  2226. text: 'instagram.users'
  2227. });
  2228. } else {
  2229. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2230. var _link$match;
  2231. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2232. });
  2233. if (realUsers.length > 0) {
  2234. for (const username of realUsers) {
  2235. if (doTask) {
  2236. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2237. } else {
  2238. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2239. }
  2240. await delay(1e3);
  2241. }
  2242. }
  2243. }
  2244. return await Promise.all(prom).then(() => true);
  2245. } catch (error) {
  2246. throwError(error, 'Instagram.toggleUsers');
  2247. return false;
  2248. }
  2249. }
  2250. }
  2251. async function _getUserInfo2() {
  2252. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2253. try {
  2254. const logStatus = scripts_echoLog({
  2255. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2256. text: name
  2257. });
  2258. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2259. if (userId && name !== 'instagram') {
  2260. logStatus.success();
  2261. return userId;
  2262. }
  2263. const {
  2264. result,
  2265. statusText,
  2266. status,
  2267. data
  2268. } = await tools_httpRequest({
  2269. url: `https://www.instagram.com/${name}/`,
  2270. method: 'GET'
  2271. });
  2272. if (result === 'Success') {
  2273. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2274. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2275. return false;
  2276. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2277. logStatus.error(`Error:${i18n('insBanned')}`);
  2278. return false;
  2279. }
  2280. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2281. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2282. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2283. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2284. if (name === 'instagram') {
  2285. if (csrftoken && hash) {
  2286. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2287. csrftoken: csrftoken,
  2288. hash: hash
  2289. });
  2290. return true;
  2291. }
  2292. return false;
  2293. }
  2294. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2295. if (id) {
  2296. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2297. logStatus.success();
  2298. return id;
  2299. }
  2300. logStatus.error('Error: Get ins data error!');
  2301. return false;
  2302. }
  2303. logStatus.error(`${result}:${statusText}(${status})`);
  2304. return false;
  2305. }
  2306. return false;
  2307. } catch (error) {
  2308. throwError(error, 'Instagram.getUserInfo');
  2309. return false;
  2310. }
  2311. }
  2312. async function _followUser2(name) {
  2313. try {
  2314. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2315. if (!id) {
  2316. return false;
  2317. }
  2318. const logStatus = scripts_echoLog({
  2319. type: 'followingIns',
  2320. text: name
  2321. });
  2322. const {
  2323. result,
  2324. statusText,
  2325. status,
  2326. data
  2327. } = await tools_httpRequest({
  2328. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2329. method: 'POST',
  2330. dataType: 'json',
  2331. headers: {
  2332. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2333. origin: 'https://www.instagram.com',
  2334. referer: `https://www.instagram.com/${name}/`,
  2335. 'content-type': 'application/x-www-form-urlencoded',
  2336. 'sec-fetch-site': 'same-origin',
  2337. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2338. }
  2339. });
  2340. if (result === 'Success') {
  2341. var _data$response, _data$response2;
  2342. 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') {
  2343. logStatus.success();
  2344. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2345. return true;
  2346. }
  2347. 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})`}`);
  2348. return false;
  2349. }
  2350. logStatus.error(`${result}:${statusText}(${status})`);
  2351. return false;
  2352. } catch (error) {
  2353. throwError(error, 'Instagram.followUser');
  2354. return false;
  2355. }
  2356. }
  2357. async function _unfollowUser2(name) {
  2358. try {
  2359. if (this.whiteList.users.includes(name)) {
  2360. scripts_echoLog({
  2361. type: 'whiteList',
  2362. text: 'Instagram.unfollowUser',
  2363. id: name
  2364. });
  2365. return true;
  2366. }
  2367. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2368. if (!id) {
  2369. return false;
  2370. }
  2371. const logStatus = scripts_echoLog({
  2372. type: 'unfollowingIns',
  2373. text: name
  2374. });
  2375. const {
  2376. result,
  2377. statusText,
  2378. status,
  2379. data
  2380. } = await tools_httpRequest({
  2381. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2382. method: 'POST',
  2383. dataType: 'json',
  2384. headers: {
  2385. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2386. origin: 'https://www.instagram.com',
  2387. referer: `https://www.instagram.com/${name}/`,
  2388. 'content-type': 'application/x-www-form-urlencoded',
  2389. 'sec-fetch-site': 'same-origin',
  2390. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2391. }
  2392. });
  2393. if (result === 'Success') {
  2394. var _data$response3;
  2395. 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') {
  2396. logStatus.success();
  2397. return true;
  2398. }
  2399. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2400. return false;
  2401. }
  2402. logStatus.error(`${result}:${statusText}(${status})`);
  2403. return false;
  2404. } catch (error) {
  2405. throwError(error, 'Instagram.unfollowUser');
  2406. return false;
  2407. }
  2408. }
  2409. function Instagram_setCache2(name, id) {
  2410. try {
  2411. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2412. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2413. } catch (error) {
  2414. throwError(error, 'Instagram.setCache');
  2415. }
  2416. }
  2417. const social_Instagram = Instagram;
  2418. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2419. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2420. privateSet.add(obj);
  2421. }
  2422. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2423. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2424. privateMap.set(obj, value);
  2425. }
  2426. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2427. if (privateCollection.has(obj)) {
  2428. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2429. }
  2430. }
  2431. function Reddit_defineProperty(obj, key, value) {
  2432. if (key in obj) {
  2433. Object.defineProperty(obj, key, {
  2434. value: value,
  2435. enumerable: true,
  2436. configurable: true,
  2437. writable: true
  2438. });
  2439. } else {
  2440. obj[key] = value;
  2441. }
  2442. return obj;
  2443. }
  2444. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2445. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2446. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2447. return value;
  2448. }
  2449. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2450. if (descriptor.set) {
  2451. descriptor.set.call(receiver, value);
  2452. } else {
  2453. if (!descriptor.writable) {
  2454. throw new TypeError('attempted to set read only private field');
  2455. }
  2456. descriptor.value = value;
  2457. }
  2458. }
  2459. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2460. if (!privateSet.has(receiver)) {
  2461. throw new TypeError('attempted to get private field on non-instance');
  2462. }
  2463. return fn;
  2464. }
  2465. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2466. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2467. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2468. }
  2469. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2470. if (!privateMap.has(receiver)) {
  2471. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2472. }
  2473. return privateMap.get(receiver);
  2474. }
  2475. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2476. if (descriptor.get) {
  2477. return descriptor.get.call(receiver);
  2478. }
  2479. return descriptor.value;
  2480. }
  2481. const Reddit_defaultTasks = {
  2482. reddits: []
  2483. };
  2484. var Reddit_auth = new WeakMap();
  2485. var Reddit_initialized = new WeakMap();
  2486. var _useBeta = new WeakSet();
  2487. var Reddit_updateAuth = new WeakSet();
  2488. class Reddit extends social_Social {
  2489. constructor() {
  2490. var _GM_getValue;
  2491. super(...arguments);
  2492. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2493. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2494. Reddit_defineProperty(this, 'tasks', {
  2495. ...Reddit_defaultTasks
  2496. });
  2497. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || {
  2498. ...Reddit_defaultTasks
  2499. });
  2500. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2501. writable: true,
  2502. value: void 0
  2503. });
  2504. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2505. writable: true,
  2506. value: false
  2507. });
  2508. }
  2509. async init() {
  2510. try {
  2511. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2512. return true;
  2513. }
  2514. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2515. if (isVerified) {
  2516. scripts_echoLog({
  2517. html: `<li><font class="success">${i18n('initSuccess', 'Reddit')}</font></li>`
  2518. });
  2519. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2520. return true;
  2521. }
  2522. scripts_echoLog({
  2523. html: `<li><font class="error">${i18n('initFailed', 'Reddit')}</font></li>`
  2524. });
  2525. return false;
  2526. } catch (error) {
  2527. throwError(error, 'Reddit.init');
  2528. return false;
  2529. }
  2530. }
  2531. async toggleTask(_ref) {
  2532. let {
  2533. name,
  2534. doTask = true
  2535. } = _ref;
  2536. try {
  2537. if (!doTask && this.whiteList.reddits.includes(name)) {
  2538. scripts_echoLog({
  2539. type: 'whiteList',
  2540. text: 'Reddit.undoTask',
  2541. id: name
  2542. });
  2543. return true;
  2544. }
  2545. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2546. if (/^u_/.test(name)) {
  2547. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2548. }
  2549. const logStatus = scripts_echoLog({
  2550. type: type,
  2551. text: name
  2552. });
  2553. const {
  2554. result,
  2555. statusText,
  2556. status,
  2557. data
  2558. } = await tools_httpRequest({
  2559. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2560. method: 'POST',
  2561. headers: {
  2562. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2563. 'content-type': 'application/x-www-form-urlencoded'
  2564. },
  2565. data: $.param({
  2566. action: doTask ? 'sub' : 'unsub',
  2567. sr_name: name,
  2568. api_type: 'json'
  2569. })
  2570. });
  2571. if (result === 'Success') {
  2572. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2573. logStatus.success();
  2574. if (doTask) {
  2575. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2576. }
  2577. return true;
  2578. }
  2579. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2580. return false;
  2581. }
  2582. logStatus.error(`${result}:${statusText}(${status})`);
  2583. return false;
  2584. } catch (error) {
  2585. throwError(error, 'Reddit.toggleTask');
  2586. return false;
  2587. }
  2588. }
  2589. async toggle(_ref2) {
  2590. let {
  2591. doTask = true,
  2592. redditLinks = []
  2593. } = _ref2;
  2594. try {
  2595. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2596. scripts_echoLog({
  2597. text: i18n('needInit')
  2598. });
  2599. return false;
  2600. }
  2601. const prom = [];
  2602. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2603. scripts_echoLog({
  2604. type: 'globalOptionsSkip',
  2605. text: 'reddit.reddits'
  2606. });
  2607. } else {
  2608. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2609. var _link$match, _link$match2;
  2610. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2611. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2612. if (userName) {
  2613. return name || userName;
  2614. }
  2615. return name;
  2616. });
  2617. if (realReddits.length > 0) {
  2618. for (const name of realReddits) {
  2619. prom.push(this.toggleTask({
  2620. name: name,
  2621. doTask: doTask
  2622. }));
  2623. await delay(1e3);
  2624. }
  2625. }
  2626. }
  2627. return await Promise.all(prom).then(() => true);
  2628. } catch (error) {
  2629. throwError(error, 'Reddit.toggle');
  2630. return false;
  2631. }
  2632. }
  2633. }
  2634. async function _useBeta2() {
  2635. try {
  2636. const logStatus = scripts_echoLog({
  2637. text: i18n('changingRedditVersion')
  2638. });
  2639. GM_setValue('redditAuth', null);
  2640. return await new Promise(resolve => {
  2641. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2642. active: true,
  2643. insert: true,
  2644. setParent: true
  2645. });
  2646. newTab.onclose = async () => {
  2647. logStatus.success();
  2648. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2649. };
  2650. });
  2651. } catch (error) {
  2652. throwError(error, 'Reddit.useBeta');
  2653. return false;
  2654. }
  2655. }
  2656. async function Reddit_updateAuth2() {
  2657. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2658. try {
  2659. const logStatus = scripts_echoLog({
  2660. text: i18n('updatingAuth', 'Reddit')
  2661. });
  2662. const {
  2663. result,
  2664. statusText,
  2665. status,
  2666. data
  2667. } = await tools_httpRequest({
  2668. url: 'https://www.reddit.com/',
  2669. method: 'GET',
  2670. nochche: true,
  2671. headers: {
  2672. 'Cache-Control': 'no-cache'
  2673. }
  2674. });
  2675. if (result === 'Success') {
  2676. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2677. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2678. return false;
  2679. }
  2680. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2681. var _data$responseText$ma;
  2682. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2683. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2684. }
  2685. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2686. if (accessToken) {
  2687. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2688. token: accessToken
  2689. });
  2690. logStatus.success();
  2691. return true;
  2692. }
  2693. logStatus.error('Error: Parameter "accessToken" not found!');
  2694. return false;
  2695. }
  2696. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2697. return false;
  2698. }
  2699. logStatus.error(`${result}:${statusText}(${status})`);
  2700. return false;
  2701. } catch (error) {
  2702. throwError(error, 'Reddit.updateAuth');
  2703. return false;
  2704. }
  2705. }
  2706. const social_Reddit = Reddit;
  2707. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2708. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2709. privateSet.add(obj);
  2710. }
  2711. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2712. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2713. privateMap.set(obj, value);
  2714. }
  2715. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2716. if (privateCollection.has(obj)) {
  2717. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2718. }
  2719. }
  2720. function Twitch_defineProperty(obj, key, value) {
  2721. if (key in obj) {
  2722. Object.defineProperty(obj, key, {
  2723. value: value,
  2724. enumerable: true,
  2725. configurable: true,
  2726. writable: true
  2727. });
  2728. } else {
  2729. obj[key] = value;
  2730. }
  2731. return obj;
  2732. }
  2733. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2734. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2735. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2736. return value;
  2737. }
  2738. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2739. if (descriptor.set) {
  2740. descriptor.set.call(receiver, value);
  2741. } else {
  2742. if (!descriptor.writable) {
  2743. throw new TypeError('attempted to set read only private field');
  2744. }
  2745. descriptor.value = value;
  2746. }
  2747. }
  2748. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2749. if (!privateSet.has(receiver)) {
  2750. throw new TypeError('attempted to get private field on non-instance');
  2751. }
  2752. return fn;
  2753. }
  2754. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2755. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2756. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2757. }
  2758. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2759. if (!privateMap.has(receiver)) {
  2760. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2761. }
  2762. return privateMap.get(receiver);
  2763. }
  2764. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2765. if (descriptor.get) {
  2766. return descriptor.get.call(receiver);
  2767. }
  2768. return descriptor.value;
  2769. }
  2770. const Twitch_defaultTasks = {
  2771. channels: []
  2772. };
  2773. var Twitch_auth = new WeakMap();
  2774. var Twitch_cache = new WeakMap();
  2775. var Twitch_initialized = new WeakMap();
  2776. var Twitch_verifyAuth = new WeakSet();
  2777. var Twitch_updateAuth = new WeakSet();
  2778. var _toggleChannel = new WeakSet();
  2779. var _getChannelId = new WeakSet();
  2780. var Twitch_setCache = new WeakSet();
  2781. class Twitch extends social_Social {
  2782. constructor() {
  2783. var _GM_getValue;
  2784. super(...arguments);
  2785. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2786. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2787. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2788. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2789. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2790. Twitch_defineProperty(this, 'tasks', {
  2791. ...Twitch_defaultTasks
  2792. });
  2793. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || {
  2794. ...Twitch_defaultTasks
  2795. });
  2796. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2797. writable: true,
  2798. value: GM_getValue('twitchAuth') || {}
  2799. });
  2800. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2801. writable: true,
  2802. value: GM_getValue('twitchCache') || {}
  2803. });
  2804. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2805. writable: true,
  2806. value: false
  2807. });
  2808. }
  2809. async init() {
  2810. try {
  2811. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2812. return true;
  2813. }
  2814. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2815. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2816. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2817. return true;
  2818. }
  2819. return false;
  2820. }
  2821. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2822. if (isVerified) {
  2823. scripts_echoLog({
  2824. html: `<li><font class="success">${i18n('initSuccess', 'Twitch')}</font></li>`
  2825. });
  2826. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2827. return true;
  2828. }
  2829. GM_setValue('twitchAuth', null);
  2830. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2831. scripts_echoLog({
  2832. html: `<li><font class="success">${i18n('initSuccess', 'Twitch')}</font></li>`
  2833. });
  2834. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2835. return true;
  2836. }
  2837. scripts_echoLog({
  2838. html: `<li><font class="success">${i18n('initFailed', 'Twitch')}</font></li>`
  2839. });
  2840. return false;
  2841. } catch (error) {
  2842. throwError(error, 'Twitch.init');
  2843. return false;
  2844. }
  2845. }
  2846. async toggle(_ref) {
  2847. let {
  2848. doTask = true,
  2849. channelLinks = []
  2850. } = _ref;
  2851. try {
  2852. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2853. scripts_echoLog({
  2854. text: i18n('needInit')
  2855. });
  2856. return false;
  2857. }
  2858. const prom = [];
  2859. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2860. scripts_echoLog({
  2861. type: 'globalOptionsSkip',
  2862. text: 'twitch.channels'
  2863. });
  2864. } else {
  2865. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2866. var _link$match;
  2867. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2868. });
  2869. if (realChannels.length > 0) {
  2870. for (const channel of realChannels) {
  2871. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2872. name: channel,
  2873. doTask: doTask
  2874. }));
  2875. await delay(1e3);
  2876. }
  2877. }
  2878. }
  2879. return Promise.all(prom).then(() => true);
  2880. } catch (error) {
  2881. throwError(error, 'Twitch.toggle');
  2882. return false;
  2883. }
  2884. }
  2885. }
  2886. async function Twitch_verifyAuth2() {
  2887. try {
  2888. const logStatus = scripts_echoLog({
  2889. text: i18n('verifyingAuth', 'Twitch')
  2890. });
  2891. const {
  2892. result,
  2893. statusText,
  2894. status,
  2895. data
  2896. } = await tools_httpRequest({
  2897. url: 'https://gql.twitch.tv/gql',
  2898. method: 'POST',
  2899. dataType: 'json',
  2900. headers: {
  2901. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2902. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2903. },
  2904. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2905. });
  2906. if (result === 'Success') {
  2907. var _data$response, _data$response$, _data$response$$data;
  2908. 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) {
  2909. logStatus.success();
  2910. return true;
  2911. }
  2912. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2913. return false;
  2914. }
  2915. logStatus.error(`${result}:${statusText}(${status})`);
  2916. return false;
  2917. } catch (error) {
  2918. throwError(error, 'Twitch.verifyAuth');
  2919. return false;
  2920. }
  2921. }
  2922. async function Twitch_updateAuth2() {
  2923. try {
  2924. const logStatus = scripts_echoLog({
  2925. text: i18n('updatingAuth', 'Twitch')
  2926. });
  2927. return await new Promise(resolve => {
  2928. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2929. active: true,
  2930. insert: true,
  2931. setParent: true
  2932. });
  2933. newTab.onclose = async () => {
  2934. const auth = GM_getValue('twitchAuth');
  2935. if (auth) {
  2936. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2937. logStatus.success();
  2938. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2939. } else {
  2940. logStatus.error('Error: Update twitch auth failed!');
  2941. resolve(false);
  2942. }
  2943. };
  2944. });
  2945. } catch (error) {
  2946. throwError(error, 'Twitch.updateAuth');
  2947. return false;
  2948. }
  2949. }
  2950. async function _toggleChannel2(_ref2) {
  2951. let {
  2952. name,
  2953. doTask = true
  2954. } = _ref2;
  2955. try {
  2956. if (!doTask && this.whiteList.channels.includes(name)) {
  2957. scripts_echoLog({
  2958. type: 'whiteList',
  2959. text: 'Twitch.unfollowChannel',
  2960. id: name
  2961. });
  2962. return true;
  2963. }
  2964. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2965. if (!channelId) {
  2966. return false;
  2967. }
  2968. const logStatus = scripts_echoLog({
  2969. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2970. text: name
  2971. });
  2972. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2973. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2974. const {
  2975. result,
  2976. statusText,
  2977. status,
  2978. data
  2979. } = await tools_httpRequest({
  2980. url: 'https://gql.twitch.tv/gql',
  2981. method: 'POST',
  2982. dataType: 'json',
  2983. headers: {
  2984. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2985. },
  2986. data: doTask ? followData : unfollowData
  2987. });
  2988. if (result === 'Success') {
  2989. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2990. logStatus.success();
  2991. if (doTask) {
  2992. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2993. }
  2994. return true;
  2995. }
  2996. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2997. return false;
  2998. }
  2999. logStatus.error(`${result}:${statusText}(${status})`);
  3000. return false;
  3001. } catch (error) {
  3002. throwError(error, 'Twitch.toggleChannel');
  3003. return false;
  3004. }
  3005. }
  3006. async function _getChannelId2(name) {
  3007. try {
  3008. const logStatus = scripts_echoLog({
  3009. type: 'gettingTwitchChannelId',
  3010. text: name
  3011. });
  3012. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3013. if (channelId) {
  3014. logStatus.success();
  3015. return channelId;
  3016. }
  3017. const {
  3018. result,
  3019. statusText,
  3020. status,
  3021. data
  3022. } = await tools_httpRequest({
  3023. url: 'https://gql.twitch.tv/gql',
  3024. method: 'POST',
  3025. headers: {
  3026. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3027. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3028. },
  3029. responseType: 'json',
  3030. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3031. });
  3032. if (result === 'Success') {
  3033. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3034. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3035. 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);
  3036. if (channelId) {
  3037. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3038. logStatus.success();
  3039. return channelId;
  3040. }
  3041. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3042. return false;
  3043. }
  3044. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3045. return false;
  3046. }
  3047. logStatus.error(`${result}:${statusText}(${status})`);
  3048. return false;
  3049. } catch (error) {
  3050. throwError(error, 'Twitch.getChannelId');
  3051. return false;
  3052. }
  3053. }
  3054. function Twitch_setCache2(name, id) {
  3055. try {
  3056. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3057. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3058. } catch (error) {
  3059. throwError(error, 'Twitch.setCache');
  3060. }
  3061. }
  3062. const social_Twitch = Twitch;
  3063. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3064. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3065. privateSet.add(obj);
  3066. }
  3067. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3068. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3069. privateMap.set(obj, value);
  3070. }
  3071. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3072. if (privateCollection.has(obj)) {
  3073. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3074. }
  3075. }
  3076. function Twitter_defineProperty(obj, key, value) {
  3077. if (key in obj) {
  3078. Object.defineProperty(obj, key, {
  3079. value: value,
  3080. enumerable: true,
  3081. configurable: true,
  3082. writable: true
  3083. });
  3084. } else {
  3085. obj[key] = value;
  3086. }
  3087. return obj;
  3088. }
  3089. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3090. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3091. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3092. return value;
  3093. }
  3094. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3095. if (descriptor.set) {
  3096. descriptor.set.call(receiver, value);
  3097. } else {
  3098. if (!descriptor.writable) {
  3099. throw new TypeError('attempted to set read only private field');
  3100. }
  3101. descriptor.value = value;
  3102. }
  3103. }
  3104. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3105. if (!privateSet.has(receiver)) {
  3106. throw new TypeError('attempted to get private field on non-instance');
  3107. }
  3108. return fn;
  3109. }
  3110. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3111. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3112. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3113. }
  3114. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3115. if (!privateMap.has(receiver)) {
  3116. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3117. }
  3118. return privateMap.get(receiver);
  3119. }
  3120. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3121. if (descriptor.get) {
  3122. return descriptor.get.call(receiver);
  3123. }
  3124. return descriptor.value;
  3125. }
  3126. const Twitter_defaultTasks = {
  3127. users: [],
  3128. retweets: [],
  3129. likes: []
  3130. };
  3131. var _verifyId = new WeakMap();
  3132. var Twitter_auth = new WeakMap();
  3133. var Twitter_cache = new WeakMap();
  3134. var Twitter_initialized = new WeakMap();
  3135. var Twitter_verifyAuth = new WeakSet();
  3136. var Twitter_updateAuth = new WeakSet();
  3137. var _toggleUser = new WeakSet();
  3138. var _toggleRetweet = new WeakSet();
  3139. var Twitter_setCache = new WeakSet();
  3140. class Twitter extends social_Social {
  3141. constructor() {
  3142. var _GM_getValue;
  3143. super(...arguments);
  3144. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3145. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3146. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3147. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3148. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3149. Twitter_defineProperty(this, 'tasks', {
  3150. ...Twitter_defaultTasks
  3151. });
  3152. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || {
  3153. ...Twitter_defaultTasks
  3154. });
  3155. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3156. writable: true,
  3157. value: globalOptions.other.twitterVerifyId
  3158. });
  3159. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3160. writable: true,
  3161. value: GM_getValue('twitterAuth') || {}
  3162. });
  3163. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3164. writable: true,
  3165. value: GM_getValue('twitterCache') || {}
  3166. });
  3167. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3168. writable: true,
  3169. value: false
  3170. });
  3171. }
  3172. async init() {
  3173. try {
  3174. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3175. return true;
  3176. }
  3177. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3178. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3179. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3180. return true;
  3181. }
  3182. return false;
  3183. }
  3184. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3185. if (isVerified) {
  3186. scripts_echoLog({
  3187. html: `<li><font class="success">${i18n('initSuccess', 'Twitter')}</font></li>`
  3188. });
  3189. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3190. return true;
  3191. }
  3192. GM_setValue('twitterAuth', null);
  3193. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3194. scripts_echoLog({
  3195. html: `<li><font class="success">${i18n('initSuccess', 'Twitter')}</font></li>`
  3196. });
  3197. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3198. return true;
  3199. }
  3200. scripts_echoLog({
  3201. html: `<li><font class="success">${i18n('initFailed', 'Twitter')}</font></li>`
  3202. });
  3203. return false;
  3204. } catch (error) {
  3205. throwError(error, 'Twitter.init');
  3206. return false;
  3207. }
  3208. }
  3209. async userName2id(name) {
  3210. try {
  3211. const logStatus = scripts_echoLog({
  3212. type: 'gettingTwitterUserId',
  3213. text: name
  3214. });
  3215. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3216. if (userId) {
  3217. logStatus.success();
  3218. return userId;
  3219. }
  3220. const {
  3221. result,
  3222. statusText,
  3223. status,
  3224. data
  3225. } = await tools_httpRequest({
  3226. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3227. method: 'GET',
  3228. headers: {
  3229. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3230. 'content-type': 'application/json'
  3231. },
  3232. responseType: 'json',
  3233. anonymous: true
  3234. });
  3235. if (result === 'Success') {
  3236. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3237. var _response, _response$data, _response$data$user;
  3238. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3239. if (!response) {
  3240. try {
  3241. response = JSON.parse(data.responseText);
  3242. } catch (error) {
  3243. response = null;
  3244. }
  3245. }
  3246. 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);
  3247. if (userId) {
  3248. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3249. logStatus.success();
  3250. return userId;
  3251. }
  3252. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3253. return false;
  3254. }
  3255. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3256. return false;
  3257. }
  3258. logStatus.error(`${result}:${statusText}(${status})`);
  3259. return false;
  3260. } catch (error) {
  3261. throwError(error, 'Twitter.getUserId');
  3262. return false;
  3263. }
  3264. }
  3265. async toggle(_ref) {
  3266. let {
  3267. doTask = true,
  3268. userLinks = [],
  3269. retweetLinks = []
  3270. } = _ref;
  3271. try {
  3272. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3273. scripts_echoLog({
  3274. text: i18n('needInit')
  3275. });
  3276. return false;
  3277. }
  3278. const prom = [];
  3279. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3280. scripts_echoLog({
  3281. type: 'globalOptionsSkip',
  3282. text: 'twitter.users'
  3283. });
  3284. } else {
  3285. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3286. var _link$match;
  3287. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3288. });
  3289. if (realUsers.length > 0) {
  3290. for (const user of realUsers) {
  3291. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3292. name: user,
  3293. doTask: doTask
  3294. }));
  3295. await delay(1e3);
  3296. }
  3297. }
  3298. }
  3299. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3300. scripts_echoLog({
  3301. type: 'globalOptionsSkip',
  3302. text: 'twitter.retweets'
  3303. });
  3304. } else {
  3305. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3306. var _link$match2;
  3307. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3308. });
  3309. if (realRetweets.length > 0) {
  3310. for (const retweet of realRetweets) {
  3311. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3312. retweetId: retweet,
  3313. doTask: doTask
  3314. }));
  3315. await delay(1e3);
  3316. }
  3317. }
  3318. }
  3319. return Promise.all(prom).then(() => true);
  3320. } catch (error) {
  3321. throwError(error, 'Twitter.toggle');
  3322. return false;
  3323. }
  3324. }
  3325. }
  3326. async function Twitter_verifyAuth2() {
  3327. try {
  3328. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3329. name: 'verify',
  3330. doTask: true,
  3331. verify: true
  3332. });
  3333. } catch (error) {
  3334. throwError(error, 'Twitter.verifyAuth');
  3335. return false;
  3336. }
  3337. }
  3338. async function Twitter_updateAuth2() {
  3339. try {
  3340. const logStatus = scripts_echoLog({
  3341. text: i18n('updatingAuth', 'Twitter')
  3342. });
  3343. return await new Promise(resolve => {
  3344. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3345. active: true,
  3346. insert: true,
  3347. setParent: true
  3348. });
  3349. newTab.onclose = async () => {
  3350. const auth = GM_getValue('twitterAuth');
  3351. if (auth) {
  3352. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3353. logStatus.success();
  3354. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3355. } else {
  3356. logStatus.error('Error: Update twitter auth failed!');
  3357. resolve(false);
  3358. }
  3359. };
  3360. });
  3361. } catch (error) {
  3362. throwError(error, 'Twitter.updateToken');
  3363. return false;
  3364. }
  3365. }
  3366. async function _toggleUser2(_ref2) {
  3367. let {
  3368. name,
  3369. doTask = true,
  3370. verify = false
  3371. } = _ref2;
  3372. try {
  3373. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3374. scripts_echoLog({
  3375. type: 'whiteList',
  3376. text: 'Twitter.unfollowUser',
  3377. id: name
  3378. });
  3379. return true;
  3380. }
  3381. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3382. if (!userId) {
  3383. return false;
  3384. }
  3385. const logStatus = verify ? scripts_echoLog({
  3386. text: i18n('verifyingAuth', 'Twitter')
  3387. }) : scripts_echoLog({
  3388. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3389. text: name
  3390. });
  3391. const {
  3392. result,
  3393. statusText,
  3394. status,
  3395. data
  3396. } = await tools_httpRequest({
  3397. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3398. method: 'POST',
  3399. headers: {
  3400. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3401. 'Content-Type': 'application/x-www-form-urlencoded',
  3402. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3403. },
  3404. responseType: 'json',
  3405. data: $.param({
  3406. include_profile_interstitial_type: 1,
  3407. include_blocking: 1,
  3408. include_blocked_by: 1,
  3409. include_followed_by: 1,
  3410. include_want_retweets: 1,
  3411. include_mute_edge: 1,
  3412. include_can_dm: 1,
  3413. include_can_media_tag: 1,
  3414. skip_status: 1,
  3415. id: userId
  3416. })
  3417. });
  3418. if (result === 'Success') {
  3419. var _data$response, _data$response$errors, _data$response$errors2;
  3420. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3421. logStatus.success();
  3422. if (doTask && !verify) {
  3423. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3424. }
  3425. return true;
  3426. }
  3427. 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) {
  3428. logStatus.success();
  3429. return true;
  3430. }
  3431. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3432. return false;
  3433. }
  3434. logStatus.error(`${result}:${statusText}(${status})`);
  3435. return false;
  3436. } catch (error) {
  3437. throwError(error, 'Twitter.toggleUser');
  3438. return false;
  3439. }
  3440. }
  3441. async function _toggleRetweet2(_ref3) {
  3442. let {
  3443. retweetId,
  3444. doTask = true
  3445. } = _ref3;
  3446. try {
  3447. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3448. scripts_echoLog({
  3449. type: 'whiteList',
  3450. text: 'Twitter.unretweet',
  3451. id: retweetId
  3452. });
  3453. return true;
  3454. }
  3455. const logStatus = scripts_echoLog({
  3456. type: `${doTask ? '' : 'un'}retweetting`,
  3457. text: retweetId
  3458. });
  3459. const {
  3460. result,
  3461. statusText,
  3462. status,
  3463. data
  3464. } = await tools_httpRequest({
  3465. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3466. method: 'POST',
  3467. headers: {
  3468. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3469. 'Content-Type': 'application/x-www-form-urlencoded',
  3470. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3471. },
  3472. data: $.param({
  3473. tweet_mode: 'extended',
  3474. id: retweetId
  3475. }),
  3476. responseType: 'json'
  3477. });
  3478. if (result === 'Success') {
  3479. var _data$response2, _data$response2$error, _data$response2$error2;
  3480. 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) {
  3481. logStatus.success();
  3482. if (doTask) {
  3483. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3484. }
  3485. return true;
  3486. }
  3487. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3488. return false;
  3489. }
  3490. logStatus.error(`${result}:${statusText}(${status})`);
  3491. return false;
  3492. } catch (error) {
  3493. throwError(error, 'Twitter.toggleRetweet');
  3494. return false;
  3495. }
  3496. }
  3497. function Twitter_setCache2(name, id) {
  3498. try {
  3499. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3500. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3501. } catch (error) {
  3502. throwError(error, 'Twitter.setCache');
  3503. }
  3504. }
  3505. const social_Twitter = Twitter;
  3506. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3507. Vk_checkPrivateRedeclaration(obj, privateSet);
  3508. privateSet.add(obj);
  3509. }
  3510. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3511. Vk_checkPrivateRedeclaration(obj, privateMap);
  3512. privateMap.set(obj, value);
  3513. }
  3514. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3515. if (privateCollection.has(obj)) {
  3516. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3517. }
  3518. }
  3519. function Vk_defineProperty(obj, key, value) {
  3520. if (key in obj) {
  3521. Object.defineProperty(obj, key, {
  3522. value: value,
  3523. enumerable: true,
  3524. configurable: true,
  3525. writable: true
  3526. });
  3527. } else {
  3528. obj[key] = value;
  3529. }
  3530. return obj;
  3531. }
  3532. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3533. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3534. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3535. return value;
  3536. }
  3537. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3538. if (descriptor.set) {
  3539. descriptor.set.call(receiver, value);
  3540. } else {
  3541. if (!descriptor.writable) {
  3542. throw new TypeError('attempted to set read only private field');
  3543. }
  3544. descriptor.value = value;
  3545. }
  3546. }
  3547. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3548. if (!privateSet.has(receiver)) {
  3549. throw new TypeError('attempted to get private field on non-instance');
  3550. }
  3551. return fn;
  3552. }
  3553. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3554. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3555. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3556. }
  3557. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3558. if (!privateMap.has(receiver)) {
  3559. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3560. }
  3561. return privateMap.get(receiver);
  3562. }
  3563. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3564. if (descriptor.get) {
  3565. return descriptor.get.call(receiver);
  3566. }
  3567. return descriptor.value;
  3568. }
  3569. const Vk_defaultTasks = {
  3570. names: []
  3571. };
  3572. var _username = new WeakMap();
  3573. var Vk_cache = new WeakMap();
  3574. var Vk_initialized = new WeakMap();
  3575. var Vk_verifyAuth = new WeakSet();
  3576. var _toggleGroup = new WeakSet();
  3577. var _togglePublic = new WeakSet();
  3578. var _sendWall = new WeakSet();
  3579. var _deleteWall = new WeakSet();
  3580. var _getId = new WeakSet();
  3581. var _toggleVk = new WeakSet();
  3582. var Vk_setCache = new WeakSet();
  3583. class Vk extends social_Social {
  3584. constructor() {
  3585. var _GM_getValue;
  3586. super(...arguments);
  3587. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3588. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3589. Vk_classPrivateMethodInitSpec(this, _getId);
  3590. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3591. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3592. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3593. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3594. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3595. Vk_defineProperty(this, 'tasks', {
  3596. ...Vk_defaultTasks
  3597. });
  3598. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || {
  3599. ...Vk_defaultTasks
  3600. });
  3601. Vk_classPrivateFieldInitSpec(this, _username, {
  3602. writable: true,
  3603. value: ''
  3604. });
  3605. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3606. writable: true,
  3607. value: GM_getValue('vkCache') || {}
  3608. });
  3609. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3610. writable: true,
  3611. value: false
  3612. });
  3613. }
  3614. async init() {
  3615. try {
  3616. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3617. return true;
  3618. }
  3619. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3620. if (isVerified) {
  3621. scripts_echoLog({
  3622. html: `<li><font class="success">${i18n('initSuccess', 'Vk')}</font></li>`
  3623. });
  3624. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3625. return true;
  3626. }
  3627. scripts_echoLog({
  3628. html: `<li><font class="success">${i18n('initFailed', 'Vk')}</font></li>`
  3629. });
  3630. return false;
  3631. } catch (error) {
  3632. throwError(error, 'Vk.init');
  3633. return false;
  3634. }
  3635. }
  3636. async toggle(_ref) {
  3637. let {
  3638. doTask = true,
  3639. nameLinks = []
  3640. } = _ref;
  3641. try {
  3642. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3643. scripts_echoLog({
  3644. text: i18n('needInit')
  3645. });
  3646. return false;
  3647. }
  3648. const prom = [];
  3649. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3650. scripts_echoLog({
  3651. type: 'globalOptionsSkip',
  3652. text: 'vk.names'
  3653. });
  3654. } else {
  3655. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3656. var _link$match;
  3657. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3658. });
  3659. if (realNames.length > 0) {
  3660. for (const name of realNames) {
  3661. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3662. name: name,
  3663. doTask: doTask
  3664. }));
  3665. await delay(1e3);
  3666. }
  3667. }
  3668. }
  3669. return Promise.all(prom).then(() => true);
  3670. } catch (error) {
  3671. throwError(error, 'Vk.toggle');
  3672. return false;
  3673. }
  3674. }
  3675. }
  3676. async function Vk_verifyAuth2() {
  3677. try {
  3678. const logStatus = scripts_echoLog({
  3679. text: i18n('verifyAuth', 'Vk')
  3680. });
  3681. const {
  3682. result,
  3683. statusText,
  3684. status,
  3685. data
  3686. } = await tools_httpRequest({
  3687. url: 'https://vk.com/im',
  3688. method: 'GET'
  3689. });
  3690. if (result === 'Success') {
  3691. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3692. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3693. return false;
  3694. }
  3695. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3696. var _data$responseText$ma;
  3697. 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]) || '');
  3698. logStatus.success();
  3699. return true;
  3700. }
  3701. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3702. return false;
  3703. }
  3704. logStatus.error(`${result}:${statusText}(${status})`);
  3705. return false;
  3706. } catch (error) {
  3707. throwError(error, 'Vk.verifyAuth');
  3708. return false;
  3709. }
  3710. }
  3711. async function _toggleGroup2(name, dataParam) {
  3712. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3713. try {
  3714. const logStatus = scripts_echoLog({
  3715. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3716. text: name
  3717. });
  3718. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3719. logStatus.success();
  3720. return true;
  3721. }
  3722. const reqData = {
  3723. act: doTask ? 'enter' : 'leave',
  3724. al: 1,
  3725. gid: dataParam.groupId,
  3726. hash: dataParam.groupHash
  3727. };
  3728. if (doTask) {
  3729. reqData.context = '_';
  3730. }
  3731. const {
  3732. result,
  3733. statusText,
  3734. status,
  3735. data
  3736. } = await tools_httpRequest({
  3737. url: 'https://vk.com/al_groups.php',
  3738. method: 'POST',
  3739. headers: {
  3740. origin: 'https://vk.com',
  3741. referer: `https://vk.com/${name}`,
  3742. 'content-type': 'application/x-www-form-urlencoded'
  3743. },
  3744. data: $.param(reqData)
  3745. });
  3746. if (result === 'Success') {
  3747. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3748. logStatus.success();
  3749. if (doTask) {
  3750. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3751. }
  3752. return true;
  3753. }
  3754. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3755. return false;
  3756. }
  3757. logStatus.error(`${result}:${statusText}(${status})`);
  3758. return false;
  3759. } catch (error) {
  3760. throwError(error, 'Vk.toggleGroup');
  3761. return false;
  3762. }
  3763. }
  3764. async function _togglePublic2(name, dataParam) {
  3765. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3766. try {
  3767. const logStatus = scripts_echoLog({
  3768. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3769. text: name
  3770. });
  3771. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3772. logStatus.success();
  3773. return true;
  3774. }
  3775. const {
  3776. result,
  3777. statusText,
  3778. status,
  3779. data
  3780. } = await tools_httpRequest({
  3781. url: 'https://vk.com/al_public.php',
  3782. method: 'POST',
  3783. headers: {
  3784. origin: 'https://vk.com',
  3785. referer: `https://vk.com/${name}`,
  3786. 'content-type': 'application/x-www-form-urlencoded'
  3787. },
  3788. data: $.param({
  3789. act: doTask ? 'a_enter' : 'a_leave',
  3790. al: 1,
  3791. pid: dataParam.publicPid,
  3792. hash: dataParam.publicHash
  3793. })
  3794. });
  3795. if (result === 'Success') {
  3796. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3797. logStatus.success();
  3798. if (doTask) {
  3799. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3800. }
  3801. return true;
  3802. }
  3803. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3804. return false;
  3805. }
  3806. logStatus.error(`${result}:${statusText}(${status})`);
  3807. return false;
  3808. } catch (error) {
  3809. throwError(error, 'Vk.togglePublic');
  3810. return false;
  3811. }
  3812. }
  3813. async function _sendWall2(name) {
  3814. try {
  3815. const logStatus = scripts_echoLog({
  3816. type: 'sendingVkWall',
  3817. text: name
  3818. });
  3819. const {
  3820. result,
  3821. statusText,
  3822. status,
  3823. data
  3824. } = await tools_httpRequest({
  3825. url: 'https://vk.com/like.php',
  3826. method: 'POST',
  3827. headers: {
  3828. origin: 'https://vk.com',
  3829. referer: `https://vk.com/${name}`,
  3830. 'content-type': 'application/x-www-form-urlencoded'
  3831. },
  3832. data: $.param({
  3833. act: 'publish_box',
  3834. al: 1,
  3835. object: name
  3836. })
  3837. });
  3838. if (result === 'Success') {
  3839. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3840. var _data$responseText$ma2;
  3841. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3842. if (hash) {
  3843. const {
  3844. result: resultR,
  3845. statusText: statusTextR,
  3846. status: statusR,
  3847. data: dataR
  3848. } = await tools_httpRequest({
  3849. url: 'https://vk.com/like.php',
  3850. method: 'POST',
  3851. headers: {
  3852. origin: 'https://vk.com',
  3853. referer: `https://vk.com/${name}`,
  3854. 'content-type': 'application/x-www-form-urlencoded'
  3855. },
  3856. data: $.param({
  3857. Message: '',
  3858. act: 'a_do_publish',
  3859. al: 1,
  3860. close_comments: 0,
  3861. friends_only: 0,
  3862. from: 'box',
  3863. hash: hash,
  3864. list: '',
  3865. mark_as_ads: 0,
  3866. mute_notifications: 0,
  3867. object: name,
  3868. ret_data: 1,
  3869. to: 0
  3870. })
  3871. });
  3872. if (resultR === 'Success') {
  3873. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3874. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3875. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3876. 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) {
  3877. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3878. logStatus.success();
  3879. 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);
  3880. 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);
  3881. if (postId && ownerId) {
  3882. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3883. }
  3884. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3885. return true;
  3886. }
  3887. }
  3888. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3889. return false;
  3890. }
  3891. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3892. return false;
  3893. }
  3894. logStatus.error('Error: Get "hash" failed');
  3895. return false;
  3896. }
  3897. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3898. return false;
  3899. }
  3900. logStatus.error(`${result}:${statusText}(${status})`);
  3901. return false;
  3902. } catch (error) {
  3903. throwError(error, 'Vk.sendWall');
  3904. return false;
  3905. }
  3906. }
  3907. async function _deleteWall2(name, dataParams) {
  3908. try {
  3909. const logStatus = scripts_echoLog({
  3910. type: 'deletingVkWall',
  3911. text: name
  3912. });
  3913. const {
  3914. result,
  3915. statusText,
  3916. status,
  3917. data
  3918. } = await tools_httpRequest({
  3919. url: 'https://vk.com/al_wall.php?act=delete',
  3920. method: 'POST',
  3921. headers: {
  3922. origin: 'https://vk.com',
  3923. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3924. 'content-type': 'application/x-www-form-urlencoded'
  3925. },
  3926. data: $.param({
  3927. act: 'delete',
  3928. al: 1,
  3929. confirm: 0,
  3930. from: 'wkview',
  3931. hash: dataParams.wallHash,
  3932. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3933. })
  3934. });
  3935. if (result === 'Success') {
  3936. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3937. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3938. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3939. 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]) {
  3940. logStatus.success();
  3941. return true;
  3942. }
  3943. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3944. return false;
  3945. }
  3946. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3947. return false;
  3948. }
  3949. logStatus.error(`${result}:${statusText}(${status})`);
  3950. return false;
  3951. } catch (error) {
  3952. throwError(error, 'Vk.deleteWall');
  3953. return false;
  3954. }
  3955. }
  3956. async function _getId2(name, doTask) {
  3957. try {
  3958. let url = `https://vk.com/${name}`;
  3959. if (/^wall-/.test(name)) {
  3960. if (doTask) {
  3961. return {
  3962. type: 'sendWall'
  3963. };
  3964. }
  3965. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3966. return {
  3967. type: 'unSupport'
  3968. };
  3969. }
  3970. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3971. }
  3972. const logStatus = scripts_echoLog({
  3973. type: 'gettingVkId',
  3974. text: name
  3975. });
  3976. const {
  3977. result,
  3978. statusText,
  3979. status,
  3980. data
  3981. } = await tools_httpRequest({
  3982. url: url,
  3983. method: 'GET'
  3984. });
  3985. if (result === 'Success') {
  3986. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3987. var _data$responseText$ma3, _data$responseText$ma4;
  3988. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3989. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3990. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3991. const publicJoined = !data.responseText.includes('Public.subscribe');
  3992. if (groupAct && groupId && groupHash) {
  3993. logStatus.success();
  3994. return {
  3995. groupAct: groupAct,
  3996. groupId: groupId,
  3997. groupHash: groupHash,
  3998. type: 'group'
  3999. };
  4000. } else if (publicHash && publicPid) {
  4001. logStatus.success();
  4002. return {
  4003. publicHash: publicHash,
  4004. publicPid: publicPid,
  4005. publicJoined: publicJoined,
  4006. type: 'public'
  4007. };
  4008. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4009. var _data$responseText$ma5;
  4010. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4011. if (wallHash) {
  4012. logStatus.success();
  4013. return {
  4014. type: 'deleteWall',
  4015. wallHash: wallHash
  4016. };
  4017. }
  4018. } else if (name.includes('wall') && doTask) {
  4019. logStatus.success();
  4020. return {
  4021. type: 'sendWall'
  4022. };
  4023. }
  4024. logStatus.error('Error: Parameters not found!');
  4025. return false;
  4026. }
  4027. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4028. return false;
  4029. }
  4030. logStatus.error(`${result}:${statusText}(${status})`);
  4031. return false;
  4032. } catch (error) {
  4033. throwError(error, 'Vk.getId');
  4034. return false;
  4035. }
  4036. }
  4037. async function _toggleVk2(_ref2) {
  4038. let {
  4039. name,
  4040. doTask = true
  4041. } = _ref2;
  4042. try {
  4043. if (!doTask && this.whiteList.names.includes(name)) {
  4044. scripts_echoLog({
  4045. type: 'whiteList',
  4046. text: 'Vk.undoTask',
  4047. id: name
  4048. });
  4049. return true;
  4050. }
  4051. const formatName = name.replace(/\/$/, '');
  4052. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4053. if (!data) {
  4054. return false;
  4055. }
  4056. switch (data.type) {
  4057. case 'group':
  4058. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4059.  
  4060. case 'public':
  4061. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4062.  
  4063. case 'sendWall':
  4064. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4065.  
  4066. case 'deleteWall':
  4067. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4068.  
  4069. default:
  4070. return false;
  4071. }
  4072. } catch (error) {
  4073. throwError(error, 'Vk.toggleVk');
  4074. return false;
  4075. }
  4076. }
  4077. function Vk_setCache2(name, postId) {
  4078. try {
  4079. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4080. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4081. } catch (error) {
  4082. throwError(error, 'Vk.setCache');
  4083. }
  4084. }
  4085. const social_Vk = Vk;
  4086. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4087. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4088. privateSet.add(obj);
  4089. }
  4090. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4091. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4092. privateMap.set(obj, value);
  4093. }
  4094. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4095. if (privateCollection.has(obj)) {
  4096. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4097. }
  4098. }
  4099. function Youtube_defineProperty(obj, key, value) {
  4100. if (key in obj) {
  4101. Object.defineProperty(obj, key, {
  4102. value: value,
  4103. enumerable: true,
  4104. configurable: true,
  4105. writable: true
  4106. });
  4107. } else {
  4108. obj[key] = value;
  4109. }
  4110. return obj;
  4111. }
  4112. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4113. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4114. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4115. return value;
  4116. }
  4117. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4118. if (descriptor.set) {
  4119. descriptor.set.call(receiver, value);
  4120. } else {
  4121. if (!descriptor.writable) {
  4122. throw new TypeError('attempted to set read only private field');
  4123. }
  4124. descriptor.value = value;
  4125. }
  4126. }
  4127. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4128. if (!privateSet.has(receiver)) {
  4129. throw new TypeError('attempted to get private field on non-instance');
  4130. }
  4131. return fn;
  4132. }
  4133. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4134. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4135. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4136. }
  4137. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4138. if (!privateMap.has(receiver)) {
  4139. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4140. }
  4141. return privateMap.get(receiver);
  4142. }
  4143. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4144. if (descriptor.get) {
  4145. return descriptor.get.call(receiver);
  4146. }
  4147. return descriptor.value;
  4148. }
  4149. const Youtube_defaultTasks = {
  4150. channels: [],
  4151. likes: []
  4152. };
  4153. const getInfo = async function(link, type) {
  4154. try {
  4155. const logStatus = scripts_echoLog({
  4156. text: i18n('gettingYtbToken')
  4157. });
  4158. const {
  4159. result,
  4160. statusText,
  4161. status,
  4162. data
  4163. } = await tools_httpRequest({
  4164. url: link,
  4165. method: 'GET'
  4166. });
  4167. if (result === 'Success') {
  4168. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4169. var _data$responseText$ma, _ref;
  4170. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4171. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4172. return {
  4173. needLogin: true
  4174. };
  4175. }
  4176. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4177. 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]) || '{}';
  4178. const {
  4179. client,
  4180. request
  4181. } = JSON.parse(context);
  4182. if (apiKey && client && request) {
  4183. client.hl = 'en';
  4184. if (type === 'channel') {
  4185. var _data$responseText$ma2;
  4186. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4187. if (channelId) {
  4188. logStatus.success();
  4189. return {
  4190. params: {
  4191. apiKey: apiKey,
  4192. client: client,
  4193. request: request,
  4194. channelId: channelId
  4195. }
  4196. };
  4197. }
  4198. logStatus.error('Error: Get "channelId" failed!');
  4199. return {};
  4200. } else if (type === 'likeVideo') {
  4201. var _data$responseText$ma3, _data$responseText$ma4;
  4202. 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];
  4203. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4204. if (videoId) {
  4205. logStatus.success();
  4206. return {
  4207. params: {
  4208. apiKey: apiKey,
  4209. client: client,
  4210. request: request,
  4211. videoId: videoId,
  4212. likeParams: likeParams
  4213. }
  4214. };
  4215. }
  4216. logStatus.error('Error: Get "videoId" failed!');
  4217. return {};
  4218. }
  4219. logStatus.error('Error: Unknown type');
  4220. return {};
  4221. }
  4222. logStatus.error('Error: Parameter "apiKey" not found!');
  4223. return {};
  4224. }
  4225. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4226. return {};
  4227. }
  4228. logStatus.error(`${result}:${statusText}(${status})`);
  4229. return {};
  4230. } catch (error) {
  4231. throwError(error, 'Youtube.getInfo');
  4232. return {};
  4233. }
  4234. };
  4235. var Youtube_auth = new WeakMap();
  4236. var Youtube_initialized = new WeakMap();
  4237. var _verifyChannel = new WeakMap();
  4238. var Youtube_verifyAuth = new WeakSet();
  4239. var Youtube_updateAuth = new WeakSet();
  4240. var _getInfo = new WeakSet();
  4241. var Youtube_toggleChannel = new WeakSet();
  4242. var _toggleLikeVideo = new WeakSet();
  4243. class Youtube extends social_Social {
  4244. constructor() {
  4245. var _GM_getValue;
  4246. super(...arguments);
  4247. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4248. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4249. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4250. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4251. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4252. Youtube_defineProperty(this, 'tasks', {
  4253. ...Youtube_defaultTasks
  4254. });
  4255. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || {
  4256. ...Youtube_defaultTasks
  4257. });
  4258. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4259. writable: true,
  4260. value: GM_getValue('youtubeAuth') || {}
  4261. });
  4262. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4263. writable: true,
  4264. value: false
  4265. });
  4266. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4267. writable: true,
  4268. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4269. });
  4270. }
  4271. async init() {
  4272. try {
  4273. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4274. return true;
  4275. }
  4276. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4277. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4278. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4279. return true;
  4280. }
  4281. return false;
  4282. }
  4283. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4284. if (isVerified) {
  4285. scripts_echoLog({
  4286. html: `<li><font class="success">${i18n('initSuccess', 'Youtube')}</font></li>`
  4287. });
  4288. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4289. return true;
  4290. }
  4291. GM_setValue('youtubeAuth', null);
  4292. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4293. scripts_echoLog({
  4294. html: `<li><font class="success">${i18n('initSuccess', 'Youtube')}</font></li>`
  4295. });
  4296. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4297. return true;
  4298. }
  4299. scripts_echoLog({
  4300. html: `<li><font class="success">${i18n('initFailed', 'Youtube')}</font></li>`
  4301. });
  4302. return false;
  4303. } catch (error) {
  4304. throwError(error, 'Youtube.init');
  4305. return false;
  4306. }
  4307. }
  4308. async toggle(_ref2) {
  4309. let {
  4310. doTask = true,
  4311. channelLinks = [],
  4312. videoLinks = []
  4313. } = _ref2;
  4314. try {
  4315. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4316. scripts_echoLog({
  4317. text: i18n('needInit')
  4318. });
  4319. return false;
  4320. }
  4321. const prom = [];
  4322. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4323. scripts_echoLog({
  4324. type: 'globalOptionsSkip',
  4325. text: 'youtube.channels'
  4326. });
  4327. } else {
  4328. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4329. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4330. var _link$match;
  4331. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4332. }
  4333. return link;
  4334. });
  4335. if (realChannels.length > 0) {
  4336. for (const channel of realChannels) {
  4337. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4338. link: channel,
  4339. doTask: doTask
  4340. }));
  4341. await delay(1e3);
  4342. }
  4343. }
  4344. }
  4345. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4346. scripts_echoLog({
  4347. type: 'globalOptionsSkip',
  4348. text: 'youtube.likes'
  4349. });
  4350. } else {
  4351. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4352. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4353. var _link$match2;
  4354. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4355. }
  4356. return link;
  4357. });
  4358. if (realLikes.length > 0) {
  4359. for (const video of realLikes) {
  4360. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4361. link: video,
  4362. doTask: doTask
  4363. }));
  4364. await delay(1e3);
  4365. }
  4366. }
  4367. }
  4368. return Promise.all(prom).then(() => true);
  4369. } catch (error) {
  4370. throwError(error, 'Youtube.toggle');
  4371. return false;
  4372. }
  4373. }
  4374. }
  4375. async function Youtube_verifyAuth2() {
  4376. try {
  4377. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4378. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4379. doTask: true,
  4380. verify: true
  4381. });
  4382. } catch (error) {
  4383. throwError(error, 'Youtube.verifyAuth');
  4384. return false;
  4385. }
  4386. }
  4387. async function Youtube_updateAuth2() {
  4388. try {
  4389. const logStatus = scripts_echoLog({
  4390. text: i18n('updatingAuth', 'Youtube')
  4391. });
  4392. return await new Promise(resolve => {
  4393. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4394. active: true,
  4395. insert: true,
  4396. setParent: true
  4397. });
  4398. newTab.onclose = async () => {
  4399. const auth = GM_getValue('youtubeAuth');
  4400. if (auth) {
  4401. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4402. logStatus.success();
  4403. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4404. resolve(result);
  4405. });
  4406. } else {
  4407. logStatus.error('Error: Update youtube auth failed!');
  4408. resolve(false);
  4409. }
  4410. };
  4411. });
  4412. } catch (error) {
  4413. throwError(error, 'Discord.updateAuth');
  4414. return false;
  4415. }
  4416. }
  4417. function _getInfo2(link, type) {
  4418. return getInfo(link, type);
  4419. }
  4420. async function Youtube_toggleChannel2(_ref3) {
  4421. let {
  4422. link,
  4423. doTask = true,
  4424. verify = false
  4425. } = _ref3;
  4426. try {
  4427. const {
  4428. params,
  4429. needLogin
  4430. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4431. const {
  4432. apiKey,
  4433. client,
  4434. request,
  4435. channelId
  4436. } = params || {};
  4437. if (needLogin) {
  4438. scripts_echoLog({
  4439. html: i18n('loginYtb')
  4440. });
  4441. return false;
  4442. }
  4443. if (!(apiKey && client && request && channelId)) {
  4444. scripts_echoLog({
  4445. text: '"getYtbToken" failed'
  4446. });
  4447. return false;
  4448. }
  4449. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4450. scripts_echoLog({
  4451. type: 'whiteList',
  4452. text: 'Youtube.unfollowChannel',
  4453. id: channelId
  4454. });
  4455. return true;
  4456. }
  4457. const logStatus = verify ? scripts_echoLog({
  4458. text: i18n('verifyingAuth', 'Youtube')
  4459. }) : scripts_echoLog({
  4460. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4461. text: channelId
  4462. });
  4463. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4464. const {
  4465. result,
  4466. statusText,
  4467. status,
  4468. data
  4469. } = await tools_httpRequest({
  4470. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4471. method: 'POST',
  4472. headers: {
  4473. origin: 'https://www.youtube.com',
  4474. referer: `https://www.youtube.com/channel/${channelId}`,
  4475. 'content-type': 'application/json',
  4476. 'x-goog-authuser': '0',
  4477. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4478. 'x-origin': 'https://www.youtube.com',
  4479. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4480. },
  4481. data: JSON.stringify({
  4482. context: {
  4483. client: client,
  4484. request: {
  4485. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4486. internalExperimentFlags: [],
  4487. consistencyTokenJars: []
  4488. },
  4489. user: {}
  4490. },
  4491. channelIds: [ channelId ],
  4492. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4493. })
  4494. });
  4495. if (result === 'Success') {
  4496. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4497. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4498. logStatus.success();
  4499. if (doTask && !verify) {
  4500. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4501. }
  4502. return true;
  4503. }
  4504. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4505. return false;
  4506. }
  4507. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4508. return false;
  4509. }
  4510. logStatus.error(`${result}:${statusText}(${status})`);
  4511. return false;
  4512. } catch (error) {
  4513. throwError(error, 'Youtube.toggleChannel');
  4514. return false;
  4515. }
  4516. }
  4517. async function _toggleLikeVideo2(_ref4) {
  4518. let {
  4519. link,
  4520. doTask = true
  4521. } = _ref4;
  4522. try {
  4523. const {
  4524. params,
  4525. needLogin
  4526. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4527. const {
  4528. apiKey,
  4529. client,
  4530. request,
  4531. videoId,
  4532. likeParams
  4533. } = params || {};
  4534. if (needLogin) {
  4535. scripts_echoLog({
  4536. html: `${i18n('loginYtb')}`
  4537. });
  4538. return false;
  4539. }
  4540. if (!(apiKey && client && request && videoId && likeParams)) {
  4541. scripts_echoLog({
  4542. text: '"getYtbToken" failed'
  4543. });
  4544. return false;
  4545. }
  4546. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4547. scripts_echoLog({
  4548. type: 'whiteList',
  4549. text: 'Youtube.unlikeVideo',
  4550. id: videoId
  4551. });
  4552. return true;
  4553. }
  4554. const logStatus = scripts_echoLog({
  4555. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4556. text: videoId
  4557. });
  4558. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4559. const likeVideoData = {
  4560. context: {
  4561. client: client,
  4562. request: {
  4563. sessionId: request.sessionId,
  4564. internalExperimentFlags: [],
  4565. consistencyTokenJars: []
  4566. },
  4567. user: {}
  4568. },
  4569. target: {
  4570. videoId: videoId
  4571. }
  4572. };
  4573. if (doTask) {
  4574. if (likeParams) {
  4575. likeVideoData.params = likeParams;
  4576. } else {
  4577. logStatus.error('Empty likeParams');
  4578. return false;
  4579. }
  4580. }
  4581. const {
  4582. result,
  4583. statusText,
  4584. status,
  4585. data
  4586. } = await tools_httpRequest({
  4587. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4588. method: 'POST',
  4589. headers: {
  4590. origin: 'https://www.youtube.com',
  4591. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4592. 'content-type': 'application/json',
  4593. 'x-goog-authuser': '0',
  4594. 'x-goog-visitor-id': client.visitorData,
  4595. 'x-origin': 'https://www.youtube.com',
  4596. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4597. },
  4598. data: JSON.stringify(likeVideoData)
  4599. });
  4600. if (result === 'Success') {
  4601. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4602. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4603. logStatus.success();
  4604. if (doTask) {
  4605. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4606. }
  4607. return true;
  4608. }
  4609. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4610. return false;
  4611. }
  4612. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4613. return false;
  4614. }
  4615. logStatus.error(`${result}:${statusText}(${status})`);
  4616. return false;
  4617. } catch (error) {
  4618. throwError(error, 'Youtube.toggleLikeVideo');
  4619. return false;
  4620. }
  4621. }
  4622. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4623. Steam_checkPrivateRedeclaration(obj, privateSet);
  4624. privateSet.add(obj);
  4625. }
  4626. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4627. Steam_checkPrivateRedeclaration(obj, privateMap);
  4628. privateMap.set(obj, value);
  4629. }
  4630. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4631. if (privateCollection.has(obj)) {
  4632. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4633. }
  4634. }
  4635. function Steam_defineProperty(obj, key, value) {
  4636. if (key in obj) {
  4637. Object.defineProperty(obj, key, {
  4638. value: value,
  4639. enumerable: true,
  4640. configurable: true,
  4641. writable: true
  4642. });
  4643. } else {
  4644. obj[key] = value;
  4645. }
  4646. return obj;
  4647. }
  4648. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4649. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4650. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4651. return value;
  4652. }
  4653. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4654. if (descriptor.set) {
  4655. descriptor.set.call(receiver, value);
  4656. } else {
  4657. if (!descriptor.writable) {
  4658. throw new TypeError('attempted to set read only private field');
  4659. }
  4660. descriptor.value = value;
  4661. }
  4662. }
  4663. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4664. if (!privateSet.has(receiver)) {
  4665. throw new TypeError('attempted to get private field on non-instance');
  4666. }
  4667. return fn;
  4668. }
  4669. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4670. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4671. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4672. }
  4673. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4674. if (!privateMap.has(receiver)) {
  4675. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4676. }
  4677. return privateMap.get(receiver);
  4678. }
  4679. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4680. if (descriptor.get) {
  4681. return descriptor.get.call(receiver);
  4682. }
  4683. return descriptor.value;
  4684. }
  4685. const Steam_defaultTasks = {
  4686. groups: [],
  4687. wishlists: [],
  4688. follows: [],
  4689. forums: [],
  4690. workshops: [],
  4691. workshopVotes: [],
  4692. curators: [],
  4693. curatorLikes: [],
  4694. announcements: []
  4695. };
  4696. var Steam_cache = new WeakMap();
  4697. var Steam_auth = new WeakMap();
  4698. var Steam_initialized = new WeakMap();
  4699. var _area = new WeakMap();
  4700. var _updateStoreAuth = new WeakSet();
  4701. var _updateCommunityAuth = new WeakSet();
  4702. var _getAreaInfo = new WeakSet();
  4703. var _changeArea = new WeakSet();
  4704. var _joinGroup = new WeakSet();
  4705. var _leaveGroup = new WeakSet();
  4706. var _getGroupId = new WeakSet();
  4707. var _addToWishlist = new WeakSet();
  4708. var _removeFromWishlist = new WeakSet();
  4709. var _toggleFollowGame = new WeakSet();
  4710. var _isFollowedGame = new WeakSet();
  4711. var _toggleForum = new WeakSet();
  4712. var _getForumId = new WeakSet();
  4713. var _toggleFavoriteWorkshop = new WeakSet();
  4714. var _getWorkshopAppId = new WeakSet();
  4715. var _voteUpWorkshop = new WeakSet();
  4716. var _toggleCurator = new WeakSet();
  4717. var _toggleCuratorLike = new WeakSet();
  4718. var _getAnnouncementParams = new WeakSet();
  4719. var _likeAnnouncement = new WeakSet();
  4720. var Steam_setCache = new WeakSet();
  4721. class Steam extends social_Social {
  4722. constructor() {
  4723. var _GM_getValue;
  4724. super(...arguments);
  4725. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4726. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4727. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4728. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4729. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4730. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4731. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4732. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4733. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4734. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4735. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4736. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4737. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4738. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4739. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4740. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4741. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4742. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4743. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4744. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4745. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4746. Steam_defineProperty(this, 'tasks', {
  4747. ...Steam_defaultTasks
  4748. });
  4749. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || {
  4750. ...Steam_defaultTasks
  4751. });
  4752. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4753. writable: true,
  4754. value: GM_getValue('steamCache') || {
  4755. group: {},
  4756. forum: {},
  4757. workshop: {},
  4758. curator: {}
  4759. }
  4760. });
  4761. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4762. writable: true,
  4763. value: {}
  4764. });
  4765. Steam_classPrivateFieldInitSpec(this, Steam_initialized, {
  4766. writable: true,
  4767. value: false
  4768. });
  4769. Steam_classPrivateFieldInitSpec(this, _area, {
  4770. writable: true,
  4771. value: 'CN'
  4772. });
  4773. }
  4774. async init() {
  4775. try {
  4776. if (Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4777. return true;
  4778. }
  4779. const isVerified = await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this) && await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this);
  4780. if (isVerified) {
  4781. Steam_classPrivateFieldSet(this, Steam_initialized, true);
  4782. scripts_echoLog({
  4783. html: `<li><font class="success">${i18n('initSuccess', 'Steam')}</font></li>`
  4784. });
  4785. return true;
  4786. }
  4787. scripts_echoLog({
  4788. html: `<li><font class="success">${i18n('initFailed', 'Steam')}</font></li>`
  4789. });
  4790. return false;
  4791. } catch (error) {
  4792. throwError(error, 'Steam.init');
  4793. return false;
  4794. }
  4795. }
  4796. async getCuratorId(path, name) {
  4797. try {
  4798. const logStatus = scripts_echoLog({
  4799. type: 'gettingCuratorId',
  4800. text: `${path}/${name}`
  4801. });
  4802. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4803. if (curatorId) {
  4804. logStatus.success();
  4805. return curatorId;
  4806. }
  4807. const {
  4808. result,
  4809. statusText,
  4810. status,
  4811. data
  4812. } = await tools_httpRequest({
  4813. url: `https://store.steampowered.com/${path}/${name}`,
  4814. method: 'GET',
  4815. headers: {
  4816. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4817. }
  4818. });
  4819. if (result === 'Success') {
  4820. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4821. var _data$responseText$ma;
  4822. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4823. if (curatorId) {
  4824. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4825. logStatus.success();
  4826. return curatorId;
  4827. }
  4828. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4829. return false;
  4830. }
  4831. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4832. return false;
  4833. }
  4834. logStatus.error(`${result}:${statusText}(${status})`);
  4835. return false;
  4836. } catch (error) {
  4837. throwError(error, 'Steam.getCuratorID');
  4838. return false;
  4839. }
  4840. }
  4841. async toggle(_ref) {
  4842. let {
  4843. doTask = true,
  4844. groupLinks = [],
  4845. wishlistLinks = [],
  4846. followLinks = [],
  4847. forumLinks = [],
  4848. workshopLinks = [],
  4849. workshopVoteLinks = [],
  4850. curatorLinks = [],
  4851. curatorLikeLinks = [],
  4852. announcementLinks = []
  4853. } = _ref;
  4854. try {
  4855. if (!Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4856. scripts_echoLog({
  4857. text: i18n('needInit')
  4858. });
  4859. return false;
  4860. }
  4861. const prom = [];
  4862. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4863. scripts_echoLog({
  4864. type: 'globalOptionsSkip',
  4865. text: 'steam.groups'
  4866. });
  4867. } else {
  4868. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4869. var _link$match;
  4870. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4871. });
  4872. if (realGroups.length > 0) {
  4873. for (const group of realGroups) {
  4874. if (doTask) {
  4875. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4876. } else {
  4877. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4878. }
  4879. await delay(1e3);
  4880. }
  4881. }
  4882. }
  4883. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4884. scripts_echoLog({
  4885. type: 'globalOptionsSkip',
  4886. text: 'steam.wishlists'
  4887. });
  4888. } else {
  4889. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4890. var _link$match2;
  4891. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4892. });
  4893. if (realWishlists.length > 0) {
  4894. for (const game of realWishlists) {
  4895. if (doTask) {
  4896. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4897. } else {
  4898. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4899. }
  4900. await delay(1e3);
  4901. }
  4902. }
  4903. }
  4904. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4905. scripts_echoLog({
  4906. type: 'globalOptionsSkip',
  4907. text: 'steam.follows'
  4908. });
  4909. } else {
  4910. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4911. var _link$match3;
  4912. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4913. });
  4914. if (realFollows.length > 0) {
  4915. for (const game of realFollows) {
  4916. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4917. await delay(1e3);
  4918. }
  4919. }
  4920. }
  4921. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4922. scripts_echoLog({
  4923. type: 'globalOptionsSkip',
  4924. text: 'steam.forums'
  4925. });
  4926. } else {
  4927. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4928. var _link$match4;
  4929. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4930. });
  4931. if (realForums.length > 0) {
  4932. for (const forum of realForums) {
  4933. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4934. await delay(1e3);
  4935. }
  4936. }
  4937. }
  4938. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4939. scripts_echoLog({
  4940. type: 'globalOptionsSkip',
  4941. text: 'steam.workshops'
  4942. });
  4943. } else {
  4944. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4945. var _link$match5;
  4946. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4947. });
  4948. if (realWorkshops.length > 0) {
  4949. for (const workshop of realWorkshops) {
  4950. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4951. await delay(1e3);
  4952. }
  4953. }
  4954. }
  4955. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4956. scripts_echoLog({
  4957. type: 'globalOptionsSkip',
  4958. text: 'steam.workshopVotes'
  4959. });
  4960. } else {
  4961. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4962. var _link$match6;
  4963. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4964. });
  4965. if (doTask && realworkshopVotes.length > 0) {
  4966. for (const workshop of realworkshopVotes) {
  4967. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4968. await delay(1e3);
  4969. }
  4970. }
  4971. }
  4972. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4973. scripts_echoLog({
  4974. type: 'globalOptionsSkip',
  4975. text: 'steam.curators'
  4976. });
  4977. } else {
  4978. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4979. var _link$match7;
  4980. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4981. });
  4982. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4983. var _link$match8;
  4984. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4985. });
  4986. if (realCurators.length > 0) {
  4987. for (const curator of realCurators) {
  4988. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4989. await delay(1e3);
  4990. }
  4991. }
  4992. if (realCuratorLikes.length > 0) {
  4993. for (const curatorLike of realCuratorLikes) {
  4994. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4995. await delay(1e3);
  4996. }
  4997. }
  4998. }
  4999. if (doTask && !globalOptions.doTask.steam.announcements) {
  5000. scripts_echoLog({
  5001. type: 'globalOptionsSkip',
  5002. text: 'steam.announcements'
  5003. });
  5004. } else {
  5005. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5006. var _link$match10;
  5007. if (link.includes('store.steampowered.com')) {
  5008. var _link$match9;
  5009. 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('/');
  5010. }
  5011. 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('/');
  5012. });
  5013. if (doTask && realAnnouncements.length > 0) {
  5014. for (const id of realAnnouncements) {
  5015. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5016. await delay(1e3);
  5017. }
  5018. }
  5019. }
  5020. return Promise.all(prom).then(async () => {
  5021. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5022. scripts_echoLog({
  5023. html: `<li><font class="warning">${i18n('steamFinishNotice')}</font></li>`
  5024. });
  5025. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5026. }
  5027. return true;
  5028. });
  5029. } catch (error) {
  5030. throwError(error, 'Steam.toggle');
  5031. return false;
  5032. }
  5033. }
  5034. }
  5035. async function _updateStoreAuth2() {
  5036. try {
  5037. const logStatus = scripts_echoLog({
  5038. text: i18n('updatingAuth', i18n('steamStore'))
  5039. });
  5040. const {
  5041. result,
  5042. statusText,
  5043. status,
  5044. data
  5045. } = await tools_httpRequest({
  5046. url: 'https://store.steampowered.com/stats/',
  5047. method: 'GET'
  5048. });
  5049. if (result === 'Success') {
  5050. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5051. var _data$responseText$ma2;
  5052. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5053. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5054. return false;
  5055. }
  5056. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5057. if (storeSessionID) {
  5058. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5059. logStatus.success();
  5060. return true;
  5061. }
  5062. logStatus.error('Error: Get "sessionID" failed');
  5063. return false;
  5064. }
  5065. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5066. return false;
  5067. }
  5068. logStatus.error(`${result}:${statusText}(${status})`);
  5069. return false;
  5070. } catch (error) {
  5071. throwError(error, 'Steam.updateStoreAuth');
  5072. return false;
  5073. }
  5074. }
  5075. async function _updateCommunityAuth2() {
  5076. try {
  5077. const logStatus = scripts_echoLog({
  5078. text: i18n('updatingAuth', i18n('steamCommunity'))
  5079. });
  5080. const {
  5081. result,
  5082. statusText,
  5083. status,
  5084. data
  5085. } = await tools_httpRequest({
  5086. url: 'https://steamcommunity.com/my',
  5087. method: 'GET'
  5088. });
  5089. if (result === 'Success') {
  5090. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5091. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5092. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5093. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5094. return false;
  5095. }
  5096. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5097. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5098. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5099. if (steam64Id) {
  5100. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5101. }
  5102. if (userName) {
  5103. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5104. }
  5105. if (communitySessionID) {
  5106. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5107. logStatus.success();
  5108. return true;
  5109. }
  5110. logStatus.error('Error: Get "sessionID" failed');
  5111. return false;
  5112. }
  5113. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5114. return false;
  5115. }
  5116. logStatus.error(`${result}:${statusText}(${status})`);
  5117. return false;
  5118. } catch (error) {
  5119. throwError(error, 'Steam.updateCommunityAuth');
  5120. return false;
  5121. }
  5122. }
  5123. async function _getAreaInfo2() {
  5124. try {
  5125. const logStatus = scripts_echoLog({
  5126. text: i18n('gettingAreaInfo')
  5127. });
  5128. const {
  5129. result,
  5130. statusText,
  5131. status,
  5132. data
  5133. } = await tools_httpRequest({
  5134. url: 'https://store.steampowered.com/cart/',
  5135. method: 'GET'
  5136. });
  5137. if (result === 'Success') {
  5138. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5139. var _data$responseText$ma6;
  5140. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5141. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5142. if (currentArea && areas.length > 0) {
  5143. Steam_classPrivateFieldSet(this, _area, currentArea);
  5144. logStatus.success();
  5145. return {
  5146. currentArea: currentArea,
  5147. areas: areas
  5148. };
  5149. }
  5150. logStatus.error('Error: get country info filed');
  5151. return {};
  5152. }
  5153. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5154. return {};
  5155. }
  5156. logStatus.error(`${result}:${statusText}(${status})`);
  5157. return {};
  5158. } catch (error) {
  5159. throwError(error, 'Steam.getAreaInfo');
  5160. return {};
  5161. }
  5162. }
  5163. async function _changeArea2(area) {
  5164. try {
  5165. let aimedArea = area;
  5166. if (!aimedArea) {
  5167. const {
  5168. currentArea,
  5169. areas
  5170. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5171. if (!currentArea || !areas) {
  5172. return false;
  5173. }
  5174. if (currentArea !== 'CN') {
  5175. scripts_echoLog({
  5176. text: 'notNeededChangeArea'
  5177. });
  5178. return 'skip';
  5179. }
  5180. const anotherArea = areas.filter(area => area && area !== 'CN');
  5181. if (!anotherArea || anotherArea.length === 0) {
  5182. scripts_echoLog({
  5183. text: 'noAnotherArea'
  5184. });
  5185. return false;
  5186. }
  5187. [ aimedArea ] = anotherArea;
  5188. }
  5189. const logStatus = scripts_echoLog({
  5190. text: i18n('changingArea', aimedArea)
  5191. });
  5192. const {
  5193. result,
  5194. statusText,
  5195. status,
  5196. data
  5197. } = await tools_httpRequest({
  5198. url: 'https://store.steampowered.com/account/setcountry',
  5199. method: 'POST',
  5200. headers: {
  5201. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5202. },
  5203. data: $.param({
  5204. cc: aimedArea,
  5205. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5206. })
  5207. });
  5208. if (result === 'Success') {
  5209. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5210. const {
  5211. currentArea
  5212. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5213. if (currentArea === aimedArea) {
  5214. logStatus.success();
  5215. return currentArea;
  5216. }
  5217. logStatus.error('Error: change country filed');
  5218. return 'CN';
  5219. }
  5220. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5221. return 'CN';
  5222. }
  5223. logStatus.error(`${result}:${statusText}(${status})`);
  5224. return 'CN';
  5225. } catch (error) {
  5226. throwError(error, 'Steam.changeArea');
  5227. return false;
  5228. }
  5229. }
  5230. async function _joinGroup2(groupName) {
  5231. try {
  5232. const logStatus = scripts_echoLog({
  5233. type: 'joiningSteamGroup',
  5234. text: groupName
  5235. });
  5236. const {
  5237. result,
  5238. statusText,
  5239. status,
  5240. data
  5241. } = await tools_httpRequest({
  5242. url: `https://steamcommunity.com/groups/${groupName}`,
  5243. method: 'POST',
  5244. headers: {
  5245. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5246. },
  5247. data: $.param({
  5248. action: 'join',
  5249. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5250. })
  5251. });
  5252. if (result === 'Success') {
  5253. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5254. logStatus.success();
  5255. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5256. return true;
  5257. }
  5258. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5259. return false;
  5260. }
  5261. logStatus.error(`${result}:${statusText}(${status})`);
  5262. return false;
  5263. } catch (error) {
  5264. throwError(error, 'Steam.joinGroup');
  5265. return false;
  5266. }
  5267. }
  5268. async function _leaveGroup2(groupName) {
  5269. try {
  5270. if (this.whiteList.groups.includes(groupName)) {
  5271. scripts_echoLog({
  5272. type: 'whiteList',
  5273. text: 'Steam.leaveGroup',
  5274. id: groupName
  5275. });
  5276. return true;
  5277. }
  5278. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5279. if (!groupId) {
  5280. return false;
  5281. }
  5282. const logStatus = scripts_echoLog({
  5283. type: 'leavingSteamGroup',
  5284. text: groupName
  5285. });
  5286. const {
  5287. result,
  5288. statusText,
  5289. status,
  5290. data
  5291. } = await tools_httpRequest({
  5292. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5293. method: 'POST',
  5294. headers: {
  5295. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5296. },
  5297. data: $.param({
  5298. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5299. action: 'leaveGroup',
  5300. groupId: groupId
  5301. })
  5302. });
  5303. if (result === 'Success') {
  5304. 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) {
  5305. logStatus.success();
  5306. return true;
  5307. }
  5308. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5309. return false;
  5310. }
  5311. logStatus.error(`${result}:${statusText}(${status})`);
  5312. return false;
  5313. } catch (error) {
  5314. throwError(error, 'Steam.leaveGroup');
  5315. return false;
  5316. }
  5317. }
  5318. async function _getGroupId2(groupName) {
  5319. try {
  5320. const logStatus = scripts_echoLog({
  5321. type: 'gettingSteamGroupId',
  5322. text: groupName
  5323. });
  5324. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5325. if (groupId) {
  5326. logStatus.success();
  5327. return groupId;
  5328. }
  5329. const {
  5330. result,
  5331. statusText,
  5332. status,
  5333. data
  5334. } = await tools_httpRequest({
  5335. url: `https://steamcommunity.com/groups/${groupName}`,
  5336. method: 'GET',
  5337. headers: {
  5338. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5339. }
  5340. });
  5341. if (result === 'Success') {
  5342. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5343. var _data$responseText$ma7;
  5344. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5345. if (groupId) {
  5346. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5347. logStatus.success();
  5348. return groupId;
  5349. }
  5350. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5351. return false;
  5352. }
  5353. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5354. return false;
  5355. }
  5356. logStatus.error(`${result}:${statusText}(${status})`);
  5357. return false;
  5358. } catch (error) {
  5359. throwError(error, 'Steam.getGroupID');
  5360. return false;
  5361. }
  5362. }
  5363. async function _addToWishlist2(gameId) {
  5364. try {
  5365. var _data$response;
  5366. const logStatus = scripts_echoLog({
  5367. type: 'addingToWishlist',
  5368. text: gameId
  5369. });
  5370. const {
  5371. result,
  5372. data
  5373. } = await tools_httpRequest({
  5374. url: 'https://store.steampowered.com/api/addtowishlist',
  5375. method: 'POST',
  5376. headers: {
  5377. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5378. },
  5379. data: $.param({
  5380. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5381. appid: gameId
  5382. }),
  5383. dataType: 'json'
  5384. });
  5385. 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) {
  5386. logStatus.success();
  5387. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5388. return true;
  5389. }
  5390. const {
  5391. result: resultR,
  5392. statusText: statusTextR,
  5393. status: statusR,
  5394. data: dataR
  5395. } = await tools_httpRequest({
  5396. url: `https://store.steampowered.com/app/${gameId}`,
  5397. method: 'GET'
  5398. });
  5399. if (resultR === 'Success') {
  5400. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5401. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5402. logStatus.warning(i18n('changeAreaNotice'));
  5403. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5404. return false;
  5405. }
  5406. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5407. }
  5408. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5409. logStatus.success();
  5410. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5411. return true;
  5412. } 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"')) {
  5413. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5414. return false;
  5415. }
  5416. logStatus.success();
  5417. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5418. return true;
  5419. }
  5420. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5421. return false;
  5422. }
  5423. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5424. return false;
  5425. } catch (error) {
  5426. throwError(error, 'Steam.addToWishlist');
  5427. return false;
  5428. }
  5429. }
  5430. async function _removeFromWishlist2(gameId) {
  5431. try {
  5432. var _data$response2;
  5433. if (this.whiteList.wishlists.includes(gameId)) {
  5434. scripts_echoLog({
  5435. type: 'whiteList',
  5436. text: 'Steam.removeFromWishlist',
  5437. id: gameId
  5438. });
  5439. return true;
  5440. }
  5441. const logStatus = scripts_echoLog({
  5442. type: 'removingFromWishlist',
  5443. text: gameId
  5444. });
  5445. const {
  5446. result,
  5447. data
  5448. } = await tools_httpRequest({
  5449. url: 'https://store.steampowered.com/api/removefromwishlist',
  5450. method: 'POST',
  5451. headers: {
  5452. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5453. },
  5454. data: $.param({
  5455. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5456. appid: gameId
  5457. }),
  5458. dataType: 'json'
  5459. });
  5460. 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) {
  5461. logStatus.success();
  5462. return true;
  5463. }
  5464. const {
  5465. result: resultR,
  5466. statusText: statusTextR,
  5467. status: statusR,
  5468. data: dataR
  5469. } = await tools_httpRequest({
  5470. url: `https://store.steampowered.com/app/${gameId}`,
  5471. method: 'GET'
  5472. });
  5473. if (resultR === 'Success') {
  5474. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5475. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5476. logStatus.warning(i18n('changeAreaNotice'));
  5477. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5478. if (!result || result === 'CN' || result === 'skip') {
  5479. return false;
  5480. }
  5481. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5482. }
  5483. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5484. logStatus.success();
  5485. return true;
  5486. }
  5487. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5488. return false;
  5489. }
  5490. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5491. return false;
  5492. }
  5493. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5494. return false;
  5495. } catch (error) {
  5496. throwError(error, 'Steam.removeFromWishlist');
  5497. return false;
  5498. }
  5499. }
  5500. async function _toggleFollowGame2(gameId, doTask) {
  5501. try {
  5502. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5503. scripts_echoLog({
  5504. type: 'whiteList',
  5505. text: 'Steam.unfollowGame',
  5506. id: gameId
  5507. });
  5508. return true;
  5509. }
  5510. const logStatus = scripts_echoLog({
  5511. type: `${doTask ? '' : 'un'}followingGame`,
  5512. text: gameId
  5513. });
  5514. const requestData = {
  5515. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5516. appid: gameId
  5517. };
  5518. if (!doTask) {
  5519. requestData.unfollow = '1';
  5520. }
  5521. const {
  5522. result,
  5523. data
  5524. } = await tools_httpRequest({
  5525. url: 'https://store.steampowered.com/explore/followgame/',
  5526. method: 'POST',
  5527. headers: {
  5528. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5529. },
  5530. data: $.param(requestData)
  5531. });
  5532. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5533. logStatus.success();
  5534. return true;
  5535. }
  5536. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5537. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5538. logStatus.warning(i18n('changeAreaNotice'));
  5539. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5540. return false;
  5541. }
  5542. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5543. }
  5544. if (doTask === followed) {
  5545. logStatus.success();
  5546. if (doTask) {
  5547. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5548. }
  5549. return true;
  5550. }
  5551. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5552. return false;
  5553. } catch (error) {
  5554. throwError(error, 'Steam.toggleFollowGame');
  5555. return false;
  5556. }
  5557. }
  5558. async function _isFollowedGame2(gameId) {
  5559. try {
  5560. const {
  5561. result,
  5562. data
  5563. } = await tools_httpRequest({
  5564. url: `https://store.steampowered.com/app/${gameId}`,
  5565. method: 'GET'
  5566. });
  5567. if (result === 'Success') {
  5568. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5569. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5570. return 'areaLocked';
  5571. }
  5572. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5573. return true;
  5574. }
  5575. return false;
  5576. }
  5577. return false;
  5578. }
  5579. return false;
  5580. } catch (error) {
  5581. throwError(error, 'Steam.isFollowedGame');
  5582. return false;
  5583. }
  5584. }
  5585. async function _toggleForum2(gameId) {
  5586. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5587. try {
  5588. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5589. scripts_echoLog({
  5590. type: 'whiteList',
  5591. text: 'Steam.unsubscribForum',
  5592. id: gameId
  5593. });
  5594. return true;
  5595. }
  5596. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5597. if (!forumId) {
  5598. return false;
  5599. }
  5600. const logStatus = scripts_echoLog({
  5601. type: `${doTask ? '' : 'un'}subscribingForum`,
  5602. text: gameId
  5603. });
  5604. const [ id, feature ] = forumId.split('_');
  5605. const {
  5606. result,
  5607. statusText,
  5608. status,
  5609. data
  5610. } = await tools_httpRequest({
  5611. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5612. method: 'POST',
  5613. responseType: 'json',
  5614. headers: {
  5615. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5616. },
  5617. data: $.param({
  5618. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5619. })
  5620. });
  5621. if (result === 'Success') {
  5622. var _data$response3, _data$response4;
  5623. 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)) {
  5624. if (doTask) {
  5625. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5626. }
  5627. logStatus.success();
  5628. return true;
  5629. }
  5630. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5631. return true;
  5632. }
  5633. logStatus.error(`${result}:${statusText}(${status})`);
  5634. return true;
  5635. } catch (error) {
  5636. throwError(error, 'Steam.toggleForum');
  5637. return true;
  5638. }
  5639. }
  5640. async function _getForumId2(gameId) {
  5641. try {
  5642. const logStatus = scripts_echoLog({
  5643. type: 'gettingForumId',
  5644. text: gameId
  5645. });
  5646. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5647. if (forumId) {
  5648. logStatus.success();
  5649. return forumId;
  5650. }
  5651. const {
  5652. result,
  5653. statusText,
  5654. status,
  5655. data
  5656. } = await tools_httpRequest({
  5657. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5658. method: 'GET'
  5659. });
  5660. if (result === 'Success') {
  5661. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5662. var _data$responseText, _data$responseText$ma8;
  5663. 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];
  5664. if (forumId) {
  5665. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5666. logStatus.success();
  5667. return forumId;
  5668. }
  5669. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5670. return false;
  5671. }
  5672. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5673. return false;
  5674. }
  5675. logStatus.error(`${result}:${statusText}(${status})`);
  5676. return false;
  5677. } catch (error) {
  5678. throwError(error, 'Steam.getForumId');
  5679. return false;
  5680. }
  5681. }
  5682. async function _toggleFavoriteWorkshop2(id) {
  5683. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5684. try {
  5685. if (!doTask && this.whiteList.workshops.includes(id)) {
  5686. scripts_echoLog({
  5687. type: 'whiteList',
  5688. text: 'Steam.unfavoriteWorkshop',
  5689. id: id
  5690. });
  5691. return true;
  5692. }
  5693. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5694. if (!appid) {
  5695. return false;
  5696. }
  5697. const logStatus = scripts_echoLog({
  5698. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5699. text: id
  5700. });
  5701. const {
  5702. result,
  5703. statusText,
  5704. status,
  5705. data
  5706. } = await tools_httpRequest({
  5707. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5708. method: 'POST',
  5709. headers: {
  5710. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5711. },
  5712. data: $.param({
  5713. id: id,
  5714. appid: appid,
  5715. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5716. })
  5717. });
  5718. if (result === 'Success') {
  5719. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5720. if (doTask) {
  5721. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5722. }
  5723. logStatus.success();
  5724. return true;
  5725. }
  5726. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5727. return false;
  5728. }
  5729. logStatus.error(`${result}:${statusText}(${status})`);
  5730. return false;
  5731. } catch (error) {
  5732. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5733. return false;
  5734. }
  5735. }
  5736. async function _getWorkshopAppId2(id) {
  5737. try {
  5738. const logStatus = scripts_echoLog({
  5739. type: 'gettingWorkshopAppId',
  5740. text: id
  5741. });
  5742. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5743. if (appId) {
  5744. logStatus.success();
  5745. return appId;
  5746. }
  5747. const {
  5748. result,
  5749. statusText,
  5750. status,
  5751. data
  5752. } = await tools_httpRequest({
  5753. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5754. method: 'GET'
  5755. });
  5756. if (result === 'Success') {
  5757. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5758. var _data$responseText$ma9;
  5759. 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];
  5760. if (appId) {
  5761. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5762. logStatus.success();
  5763. return appId;
  5764. }
  5765. logStatus.error('Error: getWorkshopAppId failed');
  5766. return false;
  5767. }
  5768. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5769. return false;
  5770. }
  5771. logStatus.error(`${result}:${statusText}(${status})`);
  5772. return false;
  5773. } catch (error) {
  5774. throwError(error, 'Steam.getWorkshopAppId');
  5775. return false;
  5776. }
  5777. }
  5778. async function _voteUpWorkshop2(id) {
  5779. try {
  5780. const logStatus = scripts_echoLog({
  5781. type: 'votingUpWorkshop',
  5782. text: id
  5783. });
  5784. const {
  5785. result,
  5786. statusText,
  5787. status,
  5788. data
  5789. } = await tools_httpRequest({
  5790. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5791. method: 'POST',
  5792. responseType: 'json',
  5793. headers: {
  5794. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5795. },
  5796. data: $.param({
  5797. id: id,
  5798. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5799. })
  5800. });
  5801. if (result === 'Success') {
  5802. var _data$response5;
  5803. 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) {
  5804. logStatus.success();
  5805. return true;
  5806. }
  5807. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5808. return true;
  5809. }
  5810. logStatus.error(`${result}:${statusText}(${status})`);
  5811. return true;
  5812. } catch (error) {
  5813. throwError(error, 'Steam.voteupWorkshop');
  5814. return true;
  5815. }
  5816. }
  5817. async function _toggleCurator2(curatorId) {
  5818. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5819. try {
  5820. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5821. scripts_echoLog({
  5822. type: 'whiteList',
  5823. text: 'Steam.unfollowCurator',
  5824. id: curatorId
  5825. });
  5826. return true;
  5827. }
  5828. const logStatus = scripts_echoLog({
  5829. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5830. text: curatorId
  5831. });
  5832. const {
  5833. result,
  5834. statusText,
  5835. status,
  5836. data
  5837. } = await tools_httpRequest({
  5838. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5839. method: 'POST',
  5840. headers: {
  5841. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5842. },
  5843. data: $.param({
  5844. clanid: curatorId,
  5845. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5846. follow: doTask
  5847. }),
  5848. dataType: 'json'
  5849. });
  5850. if (result === 'Success') {
  5851. var _data$response6, _data$response6$succe, _data$response7;
  5852. 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) {
  5853. logStatus.success();
  5854. return true;
  5855. }
  5856. 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})`);
  5857. return false;
  5858. }
  5859. logStatus.error(`${result}:${statusText}(${status})`);
  5860. return false;
  5861. } catch (error) {
  5862. throwError(error, 'Steam.toggleCurator');
  5863. return false;
  5864. }
  5865. }
  5866. async function _toggleCuratorLike2(link) {
  5867. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5868. try {
  5869. const [ path, name ] = link.split('/');
  5870. if (!(path && name)) {
  5871. scripts_echoLog({
  5872. text: i18n('errorLink', link)
  5873. });
  5874. return false;
  5875. }
  5876. const curatorId = await this.getCuratorId(path, name);
  5877. if (curatorId) {
  5878. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5879. }
  5880. return false;
  5881. } catch (error) {
  5882. throwError(error, 'Steam.toggleCuratorLike');
  5883. return false;
  5884. }
  5885. }
  5886. async function _getAnnouncementParams2(appId, viewId) {
  5887. try {
  5888. const logStatus = scripts_echoLog({
  5889. type: 'gettingAnnouncementParams',
  5890. text: appId,
  5891. id: viewId
  5892. });
  5893. const {
  5894. result,
  5895. statusText,
  5896. status,
  5897. data
  5898. } = await tools_httpRequest({
  5899. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5900. method: 'GET',
  5901. headers: {
  5902. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5903. }
  5904. });
  5905. if (result === 'Success') {
  5906. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5907. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5908. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5909. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5910. 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];
  5911. if (authWgToken && clanId) {
  5912. logStatus.success();
  5913. return {
  5914. authWgToken: authWgToken,
  5915. clanId: clanId,
  5916. gid: gid
  5917. };
  5918. }
  5919. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5920. return {};
  5921. }
  5922. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5923. return {};
  5924. }
  5925. logStatus.error(`${result}:${statusText}(${status})`);
  5926. return {};
  5927. } catch (error) {
  5928. throwError(error, 'Steam.likeAnnouncement');
  5929. return {};
  5930. }
  5931. }
  5932. async function _likeAnnouncement2(id) {
  5933. try {
  5934. const [ appId, viewId ] = id.split('/');
  5935. if (!(appId && viewId)) {
  5936. scripts_echoLog({
  5937. type: 'lost params',
  5938. text: id
  5939. });
  5940. return false;
  5941. }
  5942. const {
  5943. authWgToken,
  5944. clanId,
  5945. gid
  5946. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5947. if (!(authWgToken && clanId)) {
  5948. return false;
  5949. }
  5950. const logStatus = scripts_echoLog({
  5951. type: 'likingAnnouncement',
  5952. text: appId,
  5953. id: viewId
  5954. });
  5955. const {
  5956. result,
  5957. statusText,
  5958. status,
  5959. data
  5960. } = await tools_httpRequest({
  5961. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5962. method: 'POST',
  5963. headers: {
  5964. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5965. Host: 'store.steampowered.com',
  5966. Origin: 'https://store.steampowered.com',
  5967. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5968. },
  5969. data: $.param({
  5970. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5971. wgauthtoken: authWgToken,
  5972. voteup: 1,
  5973. clanid: clanId,
  5974. ajax: 1
  5975. }),
  5976. dataType: 'json'
  5977. });
  5978. if (result === 'Success') {
  5979. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5980. logStatus.success();
  5981. return true;
  5982. }
  5983. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5984. return false;
  5985. }
  5986. logStatus.error(`${result}:${statusText}(${status})`);
  5987. return false;
  5988. } catch (error) {
  5989. throwError(error, 'Steam.likeAnnouncement');
  5990. return false;
  5991. }
  5992. }
  5993. function Steam_setCache2(type, name, id) {
  5994. try {
  5995. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  5996. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  5997. } catch (error) {
  5998. throwError(error, 'Steam.setCache');
  5999. }
  6000. }
  6001. const social_Steam = Steam;
  6002. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6003. Website_checkPrivateRedeclaration(obj, privateSet);
  6004. privateSet.add(obj);
  6005. }
  6006. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6007. if (privateCollection.has(obj)) {
  6008. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6009. }
  6010. }
  6011. function Website_defineProperty(obj, key, value) {
  6012. if (key in obj) {
  6013. Object.defineProperty(obj, key, {
  6014. value: value,
  6015. enumerable: true,
  6016. configurable: true,
  6017. writable: true
  6018. });
  6019. } else {
  6020. obj[key] = value;
  6021. }
  6022. return obj;
  6023. }
  6024. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6025. if (!privateSet.has(receiver)) {
  6026. throw new TypeError('attempted to get private field on non-instance');
  6027. }
  6028. return fn;
  6029. }
  6030. var _bind = new WeakSet();
  6031. class Website {
  6032. constructor() {
  6033. Website_classPrivateMethodInitSpec(this, _bind);
  6034. Website_defineProperty(this, 'undoneTasks', void 0);
  6035. Website_defineProperty(this, 'socialTasks', void 0);
  6036. Website_defineProperty(this, 'giveawayId', void 0);
  6037. Website_defineProperty(this, 'socialInitialized', {
  6038. discord: false,
  6039. instagram: false,
  6040. reddit: false,
  6041. twitch: false,
  6042. twitter: false,
  6043. vk: false,
  6044. youtube: false,
  6045. steam: false
  6046. });
  6047. Website_defineProperty(this, 'initialized', false);
  6048. Website_defineProperty(this, 'social', {});
  6049. }
  6050. async initSocial(action) {
  6051. try {
  6052. const pro = [];
  6053. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6054. if (tasks.discord) {
  6055. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6056. if (hasDiscord && !this.socialInitialized.discord) {
  6057. this.social.discord = new social_Discord();
  6058. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6059. }
  6060. }
  6061. if (tasks.instagram) {
  6062. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6063. if (hasInstagram && !this.socialInitialized.instagram) {
  6064. this.social.instagram = new social_Instagram();
  6065. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6066. }
  6067. }
  6068. if (tasks.reddit) {
  6069. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6070. if (hasReddit && !this.socialInitialized.reddit) {
  6071. this.social.reddit = new social_Reddit();
  6072. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6073. }
  6074. }
  6075. if (tasks.twitch) {
  6076. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6077. if (hasTwitch && !this.socialInitialized.twitch) {
  6078. this.social.twitch = new social_Twitch();
  6079. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6080. }
  6081. }
  6082. if (tasks.twitter) {
  6083. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6084. if (hasTwitter && !this.socialInitialized.twitter) {
  6085. this.social.twitter = new social_Twitter();
  6086. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6087. }
  6088. }
  6089. if (tasks.vk) {
  6090. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6091. if (hasVk && !this.socialInitialized.vk) {
  6092. this.social.vk = new social_Vk();
  6093. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6094. }
  6095. }
  6096. if (tasks.youtube) {
  6097. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6098. if (hasYoutube && !this.socialInitialized.youtube) {
  6099. this.social.youtube = new Youtube();
  6100. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6101. }
  6102. }
  6103. if (tasks.steam) {
  6104. const hasSteam = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6105. if (hasSteam && !this.socialInitialized.steam) {
  6106. this.social.steam = new social_Steam();
  6107. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steam', this.social.steam.init()));
  6108. }
  6109. }
  6110. if (tasks.links && tasks.links.length > 0) {
  6111. this.social.visitLink = visitLink;
  6112. }
  6113. return await Promise.all(pro).then(result => {
  6114. let checked = true;
  6115. for (const data of result) {
  6116. if (data.result) {
  6117. this.socialInitialized[data.name] = data.result;
  6118. } else {
  6119. checked = false;
  6120. }
  6121. }
  6122. return checked;
  6123. });
  6124. } catch (error) {
  6125. throwError(error, 'Website.initSocial');
  6126. return false;
  6127. }
  6128. }
  6129. uniqueTasks(allTasks) {
  6130. const result = {};
  6131. for (const [ social, types ] of Object.entries(allTasks)) {
  6132. result[social] = {};
  6133. for (const [ type, tasks ] of Object.entries(types)) {
  6134. result[social][type] = unique(tasks);
  6135. }
  6136. }
  6137. return result;
  6138. }
  6139. async toggleTask(action) {
  6140. try {
  6141. if (!this.initialized && !this.init()) {
  6142. return false;
  6143. }
  6144. if (!await this.classifyTask(action)) {
  6145. return false;
  6146. }
  6147. if (!await this.initSocial(action)) {
  6148. return false;
  6149. }
  6150. const pro = [];
  6151. const doTask = action === 'do';
  6152. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6153. if (this.social.discord) {
  6154. pro.push(this.social.discord.toggle({
  6155. doTask: doTask,
  6156. ...tasks.discord
  6157. }));
  6158. }
  6159. if (this.social.instagram) {
  6160. pro.push(this.social.instagram.toggle({
  6161. doTask: doTask,
  6162. ...tasks.instagram
  6163. }));
  6164. }
  6165. if (this.social.reddit) {
  6166. pro.push(this.social.reddit.toggle({
  6167. doTask: doTask,
  6168. ...tasks.reddit
  6169. }));
  6170. }
  6171. if (this.social.twitch) {
  6172. pro.push(this.social.twitch.toggle({
  6173. doTask: doTask,
  6174. ...tasks.twitch
  6175. }));
  6176. }
  6177. if (this.social.twitter) {
  6178. pro.push(this.social.twitter.toggle({
  6179. doTask: doTask,
  6180. ...tasks.twitter
  6181. }));
  6182. }
  6183. if (this.social.vk) {
  6184. pro.push(this.social.vk.toggle({
  6185. doTask: doTask,
  6186. ...tasks.vk
  6187. }));
  6188. }
  6189. if (this.social.youtube) {
  6190. pro.push(this.social.youtube.toggle({
  6191. doTask: doTask,
  6192. ...tasks.youtube
  6193. }));
  6194. }
  6195. if (this.social.steam) {
  6196. pro.push(this.social.steam.toggle({
  6197. doTask: doTask,
  6198. ...tasks.steam
  6199. }));
  6200. }
  6201. if (this.social.visitLink && tasks.links && doTask) {
  6202. for (const link of tasks.links) {
  6203. pro.push(this.social.visitLink(link));
  6204. }
  6205. }
  6206. if (doTask && tasks.extra && this.extraDoTask) {
  6207. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6208. if (hasExtra) {
  6209. pro.push(this.extraDoTask(tasks.extra));
  6210. }
  6211. }
  6212. await Promise.all(pro);
  6213. scripts_echoLog({
  6214. html: `<li><font class="success">${i18n('allTasksComplete')}</font></li>`
  6215. });
  6216. return true;
  6217. } catch (error) {
  6218. throwError(error, 'Website.toggleTask');
  6219. return false;
  6220. }
  6221. }
  6222. async doTask() {
  6223. try {
  6224. return await this.toggleTask('do');
  6225. } catch (error) {
  6226. throwError(error, 'Website.doTask');
  6227. return false;
  6228. }
  6229. }
  6230. async undoTask() {
  6231. try {
  6232. return await this.toggleTask('undo');
  6233. } catch (error) {
  6234. throwError(error, 'Website.undoTask');
  6235. return false;
  6236. }
  6237. }
  6238. checkLogin() {
  6239. return true;
  6240. }
  6241. checkLeftKey() {
  6242. return true;
  6243. }
  6244. }
  6245. async function _bind2(name, init) {
  6246. try {
  6247. return {
  6248. name: name,
  6249. result: await init
  6250. };
  6251. } catch (error) {
  6252. throwError(error, 'Website.bind');
  6253. return {
  6254. name: name,
  6255. result: false
  6256. };
  6257. }
  6258. }
  6259. const website_Website = Website;
  6260. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6261. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6262. privateSet.add(obj);
  6263. }
  6264. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6265. if (privateCollection.has(obj)) {
  6266. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6267. }
  6268. }
  6269. function FreeAnyWhere_defineProperty(obj, key, value) {
  6270. if (key in obj) {
  6271. Object.defineProperty(obj, key, {
  6272. value: value,
  6273. enumerable: true,
  6274. configurable: true,
  6275. writable: true
  6276. });
  6277. } else {
  6278. obj[key] = value;
  6279. }
  6280. return obj;
  6281. }
  6282. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6283. if (!privateSet.has(receiver)) {
  6284. throw new TypeError('attempted to get private field on non-instance');
  6285. }
  6286. return fn;
  6287. }
  6288. const FreeAnyWhere_defaultTasks = {
  6289. steam: {
  6290. groupLinks: [],
  6291. wishlistLinks: [],
  6292. curatorLinks: [],
  6293. followLinks: []
  6294. },
  6295. vk: {
  6296. nameLinks: []
  6297. }
  6298. };
  6299. var _getGiveawayId = new WeakSet();
  6300. var _verify = new WeakSet();
  6301. class FreeAnyWhere extends website_Website {
  6302. constructor() {
  6303. super(...arguments);
  6304. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6305. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6306. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6307. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6308. FreeAnyWhere_defineProperty(this, 'socialTasks', {
  6309. ...FreeAnyWhere_defaultTasks
  6310. });
  6311. FreeAnyWhere_defineProperty(this, 'undoneTasks', {
  6312. ...FreeAnyWhere_defaultTasks
  6313. });
  6314. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6315. }
  6316. static test() {
  6317. return window.location.host === 'freeanywhere.net';
  6318. }
  6319. init() {
  6320. try {
  6321. const logStatus = scripts_echoLog({
  6322. text: i18n('initing')
  6323. });
  6324. if ($('a[href="#/login"]').length > 0) {
  6325. window.open('/#/login', '_self');
  6326. logStatus.warning(i18n('needLogin'));
  6327. return false;
  6328. }
  6329. if (window.location.href.includes('/login')) {
  6330. logStatus.warning(i18n('needLogin'));
  6331. return false;
  6332. }
  6333. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6334. var _window$location$href;
  6335. 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];
  6336. if (!id) {
  6337. logStatus.error(i18n('getFailed', 'Id'));
  6338. return false;
  6339. }
  6340. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6341. }
  6342. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6343. return false;
  6344. }
  6345. this.initialized = true;
  6346. logStatus.success();
  6347. return true;
  6348. } catch (error) {
  6349. throwError(error, 'Freeanywhere.init');
  6350. return false;
  6351. }
  6352. }
  6353. async classifyTask(action) {
  6354. try {
  6355. const logStatus = scripts_echoLog({
  6356. text: i18n('getTasksInfo')
  6357. });
  6358. if (action === 'undo') {
  6359. var _GM_getValue;
  6360. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  6361. ...FreeAnyWhere_defaultTasks
  6362. };
  6363. }
  6364. const {
  6365. result,
  6366. statusText,
  6367. status,
  6368. data
  6369. } = await tools_httpRequest({
  6370. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6371. method: 'GET',
  6372. headers: {
  6373. authorization: `Token ${window.localStorage.getItem('token')}`,
  6374. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6375. },
  6376. responseType: 'json'
  6377. });
  6378. if (result === 'Success') {
  6379. var _data$response;
  6380. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6381. if (tasks) {
  6382. if (action === 'verify') {
  6383. this.tasks = [];
  6384. }
  6385. for (const task of tasks) {
  6386. const type = task.challenge;
  6387. const social = task.challenge_provider;
  6388. const taskInfo = {
  6389. id: task.id,
  6390. title: task.title
  6391. };
  6392. if (action === 'verify' && !task.is_success) {
  6393. this.tasks.push(taskInfo);
  6394. continue;
  6395. }
  6396. switch (social) {
  6397. case 'steam':
  6398. taskInfo.social = 'steam';
  6399. switch (type) {
  6400. case 'WL':
  6401. if (action === 'undo') {
  6402. this.socialTasks.steam.wishlistLinks.push(task.link);
  6403. }
  6404. if (action === 'do' && !task.is_success) {
  6405. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6406. }
  6407. break;
  6408.  
  6409. case 'JTG':
  6410. if (action === 'undo') {
  6411. this.socialTasks.steam.groupLinks.push(task.link);
  6412. }
  6413. if (action === 'do' && !task.is_success) {
  6414. this.undoneTasks.steam.groupLinks.push(task.link);
  6415. }
  6416. break;
  6417.  
  6418. case 'STC':
  6419. if (action === 'undo') {
  6420. this.socialTasks.steam.curatorLinks.push(task.link);
  6421. }
  6422. if (action === 'do' && !task.is_success) {
  6423. this.undoneTasks.steam.curatorLinks.push(task.link);
  6424. }
  6425. break;
  6426.  
  6427. case 'GF':
  6428. if (action === 'undo') {
  6429. this.socialTasks.steam.followLinks.push(task.link);
  6430. }
  6431. if (action === 'do' && !task.is_success) {
  6432. this.undoneTasks.steam.followLinks.push(task.link);
  6433. }
  6434. break;
  6435. }
  6436. break;
  6437.  
  6438. case 'vk-oauth2':
  6439. if (action === 'undo') {
  6440. this.socialTasks.vk.nameLinks.push(task.link);
  6441. }
  6442. if (action === 'do' && !task.is_success) {
  6443. this.undoneTasks.vk.nameLinks.push(task.link);
  6444. }
  6445. break;
  6446.  
  6447. case 'website':
  6448. break;
  6449.  
  6450. default:
  6451. scripts_echoLog({
  6452. html: `<li><font class="warning">${i18n('unKnownTaskType')}: ${social}</font></li>`
  6453. });
  6454. break;
  6455. }
  6456. }
  6457. logStatus.success();
  6458. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6459. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6460. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6461. tasks: this.socialTasks,
  6462. time: new Date().getTime()
  6463. });
  6464. return true;
  6465. }
  6466. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6467. console.error(data);
  6468. return false;
  6469. }
  6470. logStatus.error(`${result}:${statusText}(${status})`);
  6471. return false;
  6472. } catch (error) {
  6473. throwError(error, 'Freeanywhere.classifyTask');
  6474. return false;
  6475. }
  6476. }
  6477. async verifyTask() {
  6478. try {
  6479. if (!this.initialized && !this.init()) {
  6480. return false;
  6481. }
  6482. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6483. return false;
  6484. }
  6485. const pro = [];
  6486. for (const task of this.tasks) {
  6487. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6488. await delay(1e3);
  6489. }
  6490. await Promise.all(pro);
  6491. scripts_echoLog({
  6492. html: `<li><font class="success">${i18n('allTasksComplete')}</font></li>`
  6493. });
  6494. return !!await this.getKey(true);
  6495. } catch (error) {
  6496. throwError(error, 'Freeanywhere.verifyTask');
  6497. return false;
  6498. }
  6499. }
  6500. async getKey(initialized) {
  6501. try {
  6502. if (!initialized && !this.initialized && !this.init()) {
  6503. return false;
  6504. }
  6505. const logStatus = scripts_echoLog({
  6506. text: i18n('gettingKey')
  6507. });
  6508. const {
  6509. result,
  6510. statusText,
  6511. status,
  6512. data
  6513. } = await tools_httpRequest({
  6514. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6515. method: 'GET',
  6516. dataType: 'json',
  6517. headers: {
  6518. authorization: `Token ${window.localStorage.getItem('token')}`
  6519. }
  6520. });
  6521. if (result === 'Success') {
  6522. var _data$response2;
  6523. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6524. logStatus.success();
  6525. scripts_echoLog({
  6526. html: `<li><font class="success">${data.response.reward}</font></li>`
  6527. });
  6528. return data.response.reward;
  6529. }
  6530. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6531. return false;
  6532. }
  6533. logStatus.error(`${result}:${statusText}(${status})`);
  6534. return false;
  6535. } catch (error) {
  6536. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6537. return false;
  6538. }
  6539. }
  6540. }
  6541. function _getGiveawayId2() {
  6542. try {
  6543. var _window$location$href2;
  6544. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6545. if (giveawayId) {
  6546. this.giveawayId = giveawayId;
  6547. return true;
  6548. }
  6549. scripts_echoLog({
  6550. html: `<li><font class="error">${i18n('getFailed', 'GiveawayId')}</font></li>`
  6551. });
  6552. return false;
  6553. } catch (error) {
  6554. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6555. }
  6556. }
  6557. async function _verify2(task) {
  6558. try {
  6559. const logStatus = scripts_echoLog({
  6560. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6561. });
  6562. const {
  6563. result,
  6564. statusText,
  6565. status,
  6566. data
  6567. } = await tools_httpRequest({
  6568. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6569. method: 'GET',
  6570. dataType: 'json',
  6571. headers: {
  6572. authorization: `Token ${window.localStorage.getItem('token')}`,
  6573. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6574. }
  6575. });
  6576. if (result === 'Success') {
  6577. var _data$response3;
  6578. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6579. logStatus.success();
  6580. return true;
  6581. }
  6582. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6583. return false;
  6584. }
  6585. logStatus.error(`${result}:${statusText}(${status})`);
  6586. return false;
  6587. } catch (error) {
  6588. throwError(error, 'Freeanywhere.verify');
  6589. return false;
  6590. }
  6591. }
  6592. const website_FreeAnyWhere = FreeAnyWhere;
  6593. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6594. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6595. privateSet.add(obj);
  6596. }
  6597. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6598. if (privateCollection.has(obj)) {
  6599. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6600. }
  6601. }
  6602. function GiveawaySu_defineProperty(obj, key, value) {
  6603. if (key in obj) {
  6604. Object.defineProperty(obj, key, {
  6605. value: value,
  6606. enumerable: true,
  6607. configurable: true,
  6608. writable: true
  6609. });
  6610. } else {
  6611. obj[key] = value;
  6612. }
  6613. return obj;
  6614. }
  6615. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6616. if (!privateSet.has(receiver)) {
  6617. throw new TypeError('attempted to get private field on non-instance');
  6618. }
  6619. return fn;
  6620. }
  6621. const GiveawaySu_defaultTasks = {
  6622. steam: {
  6623. groupLinks: [],
  6624. wishlistLinks: [],
  6625. curatorLinks: [],
  6626. curatorLikeLinks: [],
  6627. followLinks: [],
  6628. forumLinks: [],
  6629. announcementLinks: [],
  6630. workshopVoteLinks: []
  6631. },
  6632. discord: {
  6633. serverLinks: []
  6634. },
  6635. instagram: {
  6636. userLinks: []
  6637. },
  6638. vk: {
  6639. nameLinks: []
  6640. },
  6641. twitch: {
  6642. channelLinks: []
  6643. },
  6644. reddit: {
  6645. redditLinks: []
  6646. },
  6647. youtube: {
  6648. channelLinks: [],
  6649. likeLinks: []
  6650. }
  6651. };
  6652. var _checkLogin = new WeakSet();
  6653. var _checkLeftKey = new WeakSet();
  6654. var GiveawaySu_getGiveawayId = new WeakSet();
  6655. class GiveawaySu extends website_Website {
  6656. constructor() {
  6657. super(...arguments);
  6658. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6659. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6660. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6661. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6662. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6663. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6664. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6665. }
  6666. static test() {
  6667. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6668. }
  6669. async after() {
  6670. try {
  6671. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6672. scripts_echoLog({
  6673. html: `<li><font class="warning">${i18n('checkLoginFailed')}</font></li>`
  6674. });
  6675. }
  6676. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6677. scripts_echoLog({
  6678. html: `<li><font class="warning">${i18n('checkLeftKeyFailed')}</font></li>`
  6679. });
  6680. }
  6681. } catch (error) {
  6682. throwError(error, 'Giveawaysu.after');
  6683. }
  6684. }
  6685. init() {
  6686. try {
  6687. const logStatus = scripts_echoLog({
  6688. text: i18n('initing')
  6689. });
  6690. if ($('a.steam-login').length > 0) {
  6691. window.open('/steam/redirect', '_self');
  6692. logStatus.warning(i18n('needLogin'));
  6693. return false;
  6694. }
  6695. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6696. return false;
  6697. }
  6698. this.initialized = true;
  6699. logStatus.success();
  6700. return true;
  6701. } catch (error) {
  6702. throwError(error, 'Giveawaysu.init');
  6703. return false;
  6704. }
  6705. }
  6706. async classifyTask(action) {
  6707. try {
  6708. const logStatus = scripts_echoLog({
  6709. text: i18n('getTasksInfo')
  6710. });
  6711. if (action === 'undo') {
  6712. var _GM_getValue;
  6713. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6714. return true;
  6715. }
  6716. const pro = [];
  6717. const tasks = $('#actions tr');
  6718. if ($('div.bind-discord').is(':visible')) {
  6719. $('div.bind-discord a')[0].click();
  6720. }
  6721. if ($('div.bind-twitch').is(':visible')) {
  6722. $('div.bind-twitch a')[0].click();
  6723. }
  6724. for (const task of tasks) {
  6725. pro.push(new Promise(resolve => {
  6726. const td = $(task).find('td:not(".hidden")');
  6727. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6728. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6729. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6730. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6731. const taskName = taskDes.text().trim();
  6732. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6733. return resolve(true);
  6734. }
  6735. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6736. if (!taskLink) {
  6737. return resolve(false);
  6738. }
  6739. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6740. this.undoneTasks.steam.groupLinks.push(taskLink);
  6741. } else if (/like.*announcement/gi.test(taskName)) {
  6742. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6743. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6744. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6745. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6746. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6747. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6748. this.undoneTasks.steam.forumLinks.push(taskLink);
  6749. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6750. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6751. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6752. this.undoneTasks.discord.serverLinks.push(taskLink);
  6753. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6754. this.undoneTasks.instagram.userLinks.push(taskLink);
  6755. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6756. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6757. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6758. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6759. } else if (/watch.*art/gim.test(taskName)) {
  6760. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6761. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6762. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6763. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6764. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6765. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6766. this.undoneTasks.vk.nameLinks.push(taskLink);
  6767. } else {
  6768. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6769. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6770. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6771. }
  6772. if (/follow.*button/gim.test(taskName)) {
  6773. this.undoneTasks.steam.followLinks.push(taskLink);
  6774. }
  6775. }
  6776. }
  6777. resolve(true);
  6778. }).catch(error => {
  6779. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6780. return false;
  6781. });
  6782. }));
  6783. }
  6784. await Promise.all(pro);
  6785. logStatus.success();
  6786. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6787. this.socialTasks = this.undoneTasks;
  6788. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6789. tasks: this.socialTasks,
  6790. time: new Date().getTime()
  6791. });
  6792. return true;
  6793. } catch (error) {
  6794. throwError(error, 'Giveawaysu.classifyTask');
  6795. return false;
  6796. }
  6797. }
  6798. }
  6799. function _checkLogin2() {
  6800. try {
  6801. if (!globalOptions.other.checkLogin) {
  6802. return true;
  6803. }
  6804. if ($('a.steam-login').length > 0) {
  6805. window.open('/steam/redirect', '_self');
  6806. }
  6807. return true;
  6808. } catch (error) {
  6809. throwError(error, 'Giveawaysu.checkLogin');
  6810. return false;
  6811. }
  6812. }
  6813. async function _checkLeftKey2() {
  6814. try {
  6815. if (!globalOptions.other.checkLeftKey) {
  6816. return true;
  6817. }
  6818. if ($('.giveaway-ended').length > 0) {
  6819. await external_Swal_default().fire({
  6820. icon: 'warning',
  6821. title: i18n('notice'),
  6822. text: i18n('noKeysLeft'),
  6823. confirmButtonText: i18n('confirm'),
  6824. cancelButtonText: i18n('cancel'),
  6825. showCancelButton: true
  6826. }).then(_ref => {
  6827. let {
  6828. value
  6829. } = _ref;
  6830. if (value) {
  6831. window.close();
  6832. }
  6833. });
  6834. }
  6835. return true;
  6836. } catch (error) {
  6837. throwError(error, 'Giveawaysu.checkLeftKey');
  6838. return false;
  6839. }
  6840. }
  6841. function GiveawaySu_getGiveawayId2() {
  6842. var _window$location$href;
  6843. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6844. if (giveawayId) {
  6845. this.giveawayId = giveawayId;
  6846. return true;
  6847. }
  6848. scripts_echoLog({
  6849. text: i18n('getFailed', 'GiveawayId')
  6850. });
  6851. return false;
  6852. }
  6853. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6854. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6855. privateSet.add(obj);
  6856. }
  6857. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6858. if (privateCollection.has(obj)) {
  6859. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6860. }
  6861. }
  6862. function Indiedb_defineProperty(obj, key, value) {
  6863. if (key in obj) {
  6864. Object.defineProperty(obj, key, {
  6865. value: value,
  6866. enumerable: true,
  6867. configurable: true,
  6868. writable: true
  6869. });
  6870. } else {
  6871. obj[key] = value;
  6872. }
  6873. return obj;
  6874. }
  6875. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6876. if (!privateSet.has(receiver)) {
  6877. throw new TypeError('attempted to get private field on non-instance');
  6878. }
  6879. return fn;
  6880. }
  6881. var _join = new WeakSet();
  6882. var _do = new WeakSet();
  6883. var Indiedb_checkLogin = new WeakSet();
  6884. var Indiedb_checkLeftKey = new WeakSet();
  6885. class Indiedb {
  6886. constructor() {
  6887. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6888. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6889. Indiedb_classPrivateMethodInitSpec(this, _do);
  6890. Indiedb_classPrivateMethodInitSpec(this, _join);
  6891. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6892. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6893. }
  6894. static test() {
  6895. return window.location.host === 'www.indiedb.com';
  6896. }
  6897. async after() {
  6898. try {
  6899. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  6900. scripts_echoLog({
  6901. html: `<li><font class="warning">${i18n('checkLoginFailed')}</font></li>`
  6902. });
  6903. }
  6904. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  6905. scripts_echoLog({
  6906. html: `<li><font class="warning">${i18n('checkLeftKeyFailed')}</font></li>`
  6907. });
  6908. }
  6909. } catch (error) {
  6910. throwError(error, 'Indiedb.after');
  6911. }
  6912. }
  6913. async doTask() {
  6914. try {
  6915. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  6916. return false;
  6917. }
  6918. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  6919. } catch (error) {
  6920. throwError(error, 'Indiedb.doTask');
  6921. return false;
  6922. }
  6923. }
  6924. }
  6925. async function _join2() {
  6926. try {
  6927. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6928. scripts_echoLog({
  6929. html: `<li><font class="error">${i18n('needLogin')}</font></li>`
  6930. });
  6931. return false;
  6932. }
  6933. const currentoption = $('a.buttonenter.buttongiveaway');
  6934. if (/join giveaway/gim.test(currentoption.text())) {
  6935. const logStatus = scripts_echoLog({
  6936. text: `${i18n('joiningGiveaway')}...`
  6937. });
  6938. const {
  6939. result,
  6940. statusText,
  6941. status,
  6942. data
  6943. } = await tools_httpRequest({
  6944. url: currentoption.attr('href'),
  6945. method: 'POST',
  6946. data: 'ajax=t',
  6947. dataType: 'json',
  6948. headers: {
  6949. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6950. accept: 'application/json, text/javascript, */*; q=0.01',
  6951. origin: window.location.origin
  6952. }
  6953. });
  6954. if (result === 'Success') {
  6955. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6956. var _data$response, _data$response4, _data$response5;
  6957. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6958. var _data$response2, _data$response3;
  6959. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6960. $('#giveawaysjoined').slideDown();
  6961. $('#giveawaysrecommend').slideDown();
  6962. 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}` : ''}`);
  6963. return true;
  6964. }
  6965. 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}` : ''}`);
  6966. return false;
  6967. }
  6968. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6969. return false;
  6970. }
  6971. logStatus.error(`${result}:${statusText}(${status})`);
  6972. return false;
  6973. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6974. return true;
  6975. }
  6976. scripts_echoLog({
  6977. html: `<li><font class="warning">${i18n('needJoinGiveaway')}</font></li>`
  6978. });
  6979. return false;
  6980. } catch (error) {
  6981. throwError(error, 'Indiedb.init');
  6982. return false;
  6983. }
  6984. }
  6985. async function _do2() {
  6986. try {
  6987. const id = $('script').map((index, script) => {
  6988. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6989. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6990. 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] ];
  6991. }
  6992. return null;
  6993. });
  6994. if (id.length === 2) {
  6995. const pro = [];
  6996. const tasks = $('#giveawaysjoined a[class*=promo]');
  6997. for (const task of tasks) {
  6998. const promo = $(task);
  6999. if (!promo.hasClass('buttonentered')) {
  7000. const status = scripts_echoLog({
  7001. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7002. });
  7003. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7004. let text = '';
  7005. if (promo.hasClass('facebookpromo')) {
  7006. text = 'facebookpromo';
  7007. } else if (promo.hasClass('twitterpromo')) {
  7008. text = 'twitterpromo';
  7009. } else {
  7010. text = 'visitpromo';
  7011. }
  7012. pro.push(new Promise(resolve => {
  7013. $.ajax({
  7014. type: 'POST',
  7015. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7016. timeout: 6e4,
  7017. dataType: 'json',
  7018. data: {
  7019. ajax: 't'
  7020. },
  7021. error(response, error, exception) {
  7022. console.log({
  7023. response: response,
  7024. error: error,
  7025. exception: exception
  7026. });
  7027. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7028. resolve(true);
  7029. },
  7030. success(response) {
  7031. console.log(response);
  7032. if (response.success) {
  7033. status.success(`Success:${response.text}`);
  7034. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7035. resolve(true);
  7036. } else {
  7037. status.error(`Error:${response.text}`);
  7038. resolve(true);
  7039. }
  7040. }
  7041. });
  7042. }));
  7043. } else if (promo.hasClass('emailoptinpromo')) {
  7044. pro.push(new Promise(resolve => {
  7045. $.ajax({
  7046. type: 'POST',
  7047. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7048. timeout: 6e4,
  7049. dataType: 'json',
  7050. data: {
  7051. ajax: 't',
  7052. emailsystoggle: 4
  7053. },
  7054. error(response, error, exception) {
  7055. console.log({
  7056. response: response,
  7057. error: error,
  7058. exception: exception
  7059. });
  7060. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7061. resolve(true);
  7062. },
  7063. success(response) {
  7064. console.log(response);
  7065. if (response.success) {
  7066. status.success(`Success:${response.text}`);
  7067. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7068. resolve(true);
  7069. } else {
  7070. status.error(`Error:${response.text}`);
  7071. resolve(true);
  7072. }
  7073. }
  7074. });
  7075. }));
  7076. } else if (promo.hasClass('watchingpromo')) {
  7077. pro.push(new Promise(resolve => {
  7078. var _promo$attr;
  7079. const data = getUrlQuery(promo.attr('href'));
  7080. data.ajax = 't';
  7081. $.ajax({
  7082. type: 'POST',
  7083. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7084. timeout: 6e4,
  7085. dataType: 'json',
  7086. data: data,
  7087. error(response, error, exception) {
  7088. console.log({
  7089. response: response,
  7090. error: error,
  7091. exception: exception
  7092. });
  7093. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7094. resolve(true);
  7095. },
  7096. success(response) {
  7097. console.log(response);
  7098. if (response.success) {
  7099. status.success(`Success:${response.text}`);
  7100. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7101. resolve(true);
  7102. } else {
  7103. status.error(`Error:${response.text}`);
  7104. resolve(true);
  7105. }
  7106. }
  7107. });
  7108. }));
  7109. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7110. pro.push(new Promise(resolve => {
  7111. $.ajax({
  7112. type: 'POST',
  7113. url: urlPath(promo.attr('href')),
  7114. timeout: 6e4,
  7115. dataType: 'json',
  7116. data: {
  7117. ajax: 't'
  7118. },
  7119. error(response, error, exception) {
  7120. console.log({
  7121. response: response,
  7122. error: error,
  7123. exception: exception
  7124. });
  7125. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7126. resolve(true);
  7127. },
  7128. success(response) {
  7129. console.log(response);
  7130. if (response.success) {
  7131. status.success(`Success:${response.text}`);
  7132. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7133. resolve(true);
  7134. } else {
  7135. status.error(`Error:${response.text}`);
  7136. resolve(true);
  7137. }
  7138. }
  7139. });
  7140. }));
  7141. } else {
  7142. status.error(`Error:${i18n('unKnownTaskType')}`);
  7143. }
  7144. }
  7145. }
  7146. await Promise.all(pro);
  7147. scripts_echoLog({
  7148. html: `<li><font class="success">${i18n('allTasksComplete')}</font></li>`
  7149. });
  7150. return true;
  7151. }
  7152. scripts_echoLog({
  7153. html: `<li><font class="error">${i18n('getFailed', 'TaskId')}</font></li>`
  7154. });
  7155. return false;
  7156. } catch (error) {
  7157. throwError(error, 'Indiedb.classifyTask');
  7158. return false;
  7159. }
  7160. }
  7161. function Indiedb_checkLogin2() {
  7162. try {
  7163. if (!globalOptions.other.checkLogin) {
  7164. return true;
  7165. }
  7166. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7167. window.open('/members/login', '_self');
  7168. }
  7169. return true;
  7170. } catch (error) {
  7171. throwError(error, 'Indiedb.checkLogin');
  7172. return false;
  7173. }
  7174. }
  7175. async function Indiedb_checkLeftKey2() {
  7176. try {
  7177. if (!globalOptions.other.checkLeftKey) {
  7178. return true;
  7179. }
  7180. if ($('a.buttonenter:contains("next time")').length > 0) {
  7181. await external_Swal_default().fire({
  7182. icon: 'warning',
  7183. title: i18n('notice'),
  7184. text: i18n('giveawayEnded'),
  7185. confirmButtonText: i18n('confirm'),
  7186. cancelButtonText: i18n('cancel'),
  7187. showCancelButton: true
  7188. }).then(_ref => {
  7189. let {
  7190. value
  7191. } = _ref;
  7192. if (value) {
  7193. window.close();
  7194. }
  7195. });
  7196. }
  7197. return true;
  7198. } catch (error) {
  7199. throwError(error, 'Indiedb.checkLeftKey');
  7200. return false;
  7201. }
  7202. }
  7203. const website_Indiedb = Indiedb;
  7204. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7205. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7206. privateSet.add(obj);
  7207. }
  7208. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7209. if (privateCollection.has(obj)) {
  7210. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7211. }
  7212. }
  7213. function Keyhub_defineProperty(obj, key, value) {
  7214. if (key in obj) {
  7215. Object.defineProperty(obj, key, {
  7216. value: value,
  7217. enumerable: true,
  7218. configurable: true,
  7219. writable: true
  7220. });
  7221. } else {
  7222. obj[key] = value;
  7223. }
  7224. return obj;
  7225. }
  7226. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7227. if (!privateSet.has(receiver)) {
  7228. throw new TypeError('attempted to get private field on non-instance');
  7229. }
  7230. return fn;
  7231. }
  7232. const Keyhub_defaultTasks = {
  7233. steam: {
  7234. groupLinks: [],
  7235. wishlistLinks: [],
  7236. curatorLinks: []
  7237. },
  7238. discord: {
  7239. serverLinks: []
  7240. },
  7241. links: []
  7242. };
  7243. var Keyhub_getGiveawayId = new WeakSet();
  7244. var Keyhub_checkLeftKey = new WeakSet();
  7245. var Keyhub_checkLogin = new WeakSet();
  7246. class Keyhub extends website_Website {
  7247. constructor() {
  7248. super(...arguments);
  7249. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7250. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7251. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7252. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7253. Keyhub_defineProperty(this, 'socialTasks', {
  7254. ...Keyhub_defaultTasks
  7255. });
  7256. Keyhub_defineProperty(this, 'undoneTasks', {
  7257. ...Keyhub_defaultTasks
  7258. });
  7259. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7260. }
  7261. static test() {
  7262. return window.location.host === 'key-hub.eu';
  7263. }
  7264. async after() {
  7265. try {
  7266. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7267. scripts_echoLog({
  7268. html: `<li><font class="warning">${i18n('checkLoginFailed')}</font></li>`
  7269. });
  7270. }
  7271. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7272. scripts_echoLog({
  7273. html: `<li><font class="warning">${i18n('checkLeftKeyFailed')}</font></li>`
  7274. });
  7275. }
  7276. } catch (error) {
  7277. throwError(error, 'Keyhub.after');
  7278. }
  7279. }
  7280. init() {
  7281. try {
  7282. const logStatus = scripts_echoLog({
  7283. text: i18n('initing')
  7284. });
  7285. if ($('a[href*="/connect/steam"]').length > 0) {
  7286. window.open('/connect/steam', '_self');
  7287. logStatus.warning(i18n('needLogin'));
  7288. return false;
  7289. }
  7290. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7291. return false;
  7292. }
  7293. $('#VPNoverlay').hide();
  7294. $('#mainArticleSection').show();
  7295. this.initialized = true;
  7296. logStatus.success();
  7297. return true;
  7298. } catch (error) {
  7299. throwError(error, 'Keyhub.init');
  7300. return false;
  7301. }
  7302. }
  7303. async classifyTask(action) {
  7304. try {
  7305. const logStatus = scripts_echoLog({
  7306. text: i18n('getTasksInfo')
  7307. });
  7308. if (action === 'undo') {
  7309. var _GM_getValue;
  7310. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  7311. ...Keyhub_defaultTasks
  7312. };
  7313. }
  7314. const tasks = $('.task a');
  7315. for (const task of tasks) {
  7316. let link = $(task).attr('href');
  7317. const taskDes = $(task).text().trim();
  7318. if (!link) {
  7319. continue;
  7320. }
  7321. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7322. link = await getRedirectLink(link) || link;
  7323. }
  7324. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7325. window.open(link, '_blank');
  7326. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7327. if (action === 'undo') {
  7328. this.socialTasks.steam.groupLinks.push(link);
  7329. }
  7330. if (action === 'do') {
  7331. this.undoneTasks.steam.groupLinks.push(link);
  7332. }
  7333. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7334. if (action === 'undo') {
  7335. this.socialTasks.steam.wishlistLinks.push(link);
  7336. }
  7337. if (action === 'do') {
  7338. this.undoneTasks.steam.wishlistLinks.push(link);
  7339. }
  7340. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7341. if (action === 'undo') {
  7342. this.socialTasks.steam.curatorLinks.push(link);
  7343. }
  7344. if (action === 'do') {
  7345. this.undoneTasks.steam.curatorLinks.push(link);
  7346. }
  7347. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7348. if (action === 'undo') {
  7349. this.socialTasks.discord.serverLinks.push(link);
  7350. }
  7351. if (action === 'do') {
  7352. this.undoneTasks.discord.serverLinks.push(link);
  7353. }
  7354. } else {
  7355. scripts_echoLog({
  7356. html: `<li><font class="warning">${i18n('unKnownTaskType', `${taskDes}(${link})`)}</font></li>`
  7357. });
  7358. }
  7359. }
  7360. logStatus.success();
  7361. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7362. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7363. GM_setValue(`khTasks-${this.giveawayId}`, {
  7364. tasks: this.socialTasks,
  7365. time: new Date().getTime()
  7366. });
  7367. return true;
  7368. } catch (error) {
  7369. throwError(error, 'Keyhub.classifyTask');
  7370. return false;
  7371. }
  7372. }
  7373. verifyTask() {
  7374. try {
  7375. scripts_echoLog({
  7376. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7377. });
  7378. $.get(window.location.href, res => {
  7379. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7380. });
  7381. } catch (error) {
  7382. throwError(error, 'keyhub.verifyTask');
  7383. }
  7384. }
  7385. }
  7386. function Keyhub_getGiveawayId2() {
  7387. try {
  7388. var _window$location$href;
  7389. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7390. if (giveawayId) {
  7391. this.giveawayId = giveawayId;
  7392. return true;
  7393. }
  7394. scripts_echoLog({
  7395. html: `<li><font class="error">${i18n('getFailed', 'GiveawayId')}</font></li>`
  7396. });
  7397. return false;
  7398. } catch (error) {
  7399. throwError(error, 'Keyhub.getGiveawayId');
  7400. return false;
  7401. }
  7402. }
  7403. async function Keyhub_checkLeftKey2() {
  7404. try {
  7405. if (!globalOptions.other.checkLeftKey) {
  7406. return true;
  7407. }
  7408. const leftKey = $('#keysleft').text().trim();
  7409. if (leftKey === '0') {
  7410. await external_Swal_default().fire({
  7411. icon: 'warning',
  7412. title: i18n('notice'),
  7413. text: i18n('noKeysLeft'),
  7414. confirmButtonText: i18n('confirm'),
  7415. cancelButtonText: i18n('cancel'),
  7416. showCancelButton: true
  7417. }).then(_ref => {
  7418. let {
  7419. value
  7420. } = _ref;
  7421. if (value) {
  7422. window.close();
  7423. }
  7424. });
  7425. }
  7426. return true;
  7427. } catch (error) {
  7428. throwError(error, 'Keyhub.checkLeftKey');
  7429. return false;
  7430. }
  7431. }
  7432. function Keyhub_checkLogin2() {
  7433. try {
  7434. if (!globalOptions.other.checkLogin) {
  7435. return true;
  7436. }
  7437. if ($('a[href*="/connect/steam"]').length > 0) {
  7438. window.open('/connect/steam', '_self');
  7439. }
  7440. return true;
  7441. } catch (error) {
  7442. throwError(error, 'Keyhub.checkLogin');
  7443. return false;
  7444. }
  7445. }
  7446. const website_Keyhub = Keyhub;
  7447. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7448. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7449. privateSet.add(obj);
  7450. }
  7451. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7452. if (privateCollection.has(obj)) {
  7453. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7454. }
  7455. }
  7456. function Givekey_defineProperty(obj, key, value) {
  7457. if (key in obj) {
  7458. Object.defineProperty(obj, key, {
  7459. value: value,
  7460. enumerable: true,
  7461. configurable: true,
  7462. writable: true
  7463. });
  7464. } else {
  7465. obj[key] = value;
  7466. }
  7467. return obj;
  7468. }
  7469. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7470. if (!privateSet.has(receiver)) {
  7471. throw new TypeError('attempted to get private field on non-instance');
  7472. }
  7473. return fn;
  7474. }
  7475. const Givekey_defaultTasks = {
  7476. steam: {
  7477. groupLinks: [],
  7478. wishlistLinks: [],
  7479. curatorLinks: [],
  7480. curatorLikeLinks: []
  7481. },
  7482. twitter: {
  7483. userLinks: []
  7484. },
  7485. vk: {
  7486. nameLinks: []
  7487. },
  7488. discord: {
  7489. serverLinks: []
  7490. }
  7491. };
  7492. var Givekey_verify = new WeakSet();
  7493. var Givekey_getGiveawayId = new WeakSet();
  7494. var Givekey_checkLeftKey = new WeakSet();
  7495. class Givekey extends website_Website {
  7496. constructor() {
  7497. super(...arguments);
  7498. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7499. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7500. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7501. Givekey_defineProperty(this, 'name', 'Givekey');
  7502. Givekey_defineProperty(this, 'tasks', []);
  7503. Givekey_defineProperty(this, 'socialTasks', {
  7504. ...Givekey_defaultTasks
  7505. });
  7506. Givekey_defineProperty(this, 'undoneTasks', {
  7507. ...Givekey_defaultTasks
  7508. });
  7509. Givekey_defineProperty(this, 'userId', void 0);
  7510. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7511. }
  7512. static test() {
  7513. return window.location.host === 'givekey.ru';
  7514. }
  7515. async after() {
  7516. try {
  7517. await new Promise(resolve => {
  7518. const checker = setInterval(() => {
  7519. if ($('#navbarDropdown').length > 0) {
  7520. clearInterval(checker);
  7521. resolve(true);
  7522. }
  7523. });
  7524. });
  7525. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7526. scripts_echoLog({
  7527. html: `<li><font class="warning">${i18n('checkLeftKeyFailed')}</font></li>`
  7528. });
  7529. }
  7530. } catch (error) {
  7531. throwError(error, 'Givekey.after');
  7532. return false;
  7533. }
  7534. }
  7535. init() {
  7536. try {
  7537. const logStatus = scripts_echoLog({
  7538. text: i18n('initing')
  7539. });
  7540. if ($('a[href*="/auth/steam"]').length > 0) {
  7541. window.open('/auth/steam', '_self');
  7542. logStatus.warning(i18n('needLogin'));
  7543. return false;
  7544. }
  7545. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7546. return false;
  7547. }
  7548. const userId = $('meta[name="user-id"]').attr('content');
  7549. if (!userId) {
  7550. logStatus.error(i18n('getFailed', i18n('userId')));
  7551. return false;
  7552. }
  7553. this.userId = userId;
  7554. this.initialized = true;
  7555. logStatus.success();
  7556. return true;
  7557. } catch (error) {
  7558. throwError(error, 'Givekey.init');
  7559. return false;
  7560. }
  7561. }
  7562. async classifyTask(action) {
  7563. try {
  7564. const logStatus = scripts_echoLog({
  7565. text: i18n('getTasksInfo')
  7566. });
  7567. if (action === 'undo') {
  7568. var _GM_getValue;
  7569. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || Givekey_defaultTasks;
  7570. }
  7571. const tasks = $('.card-body:has("button") .row');
  7572. for (const task of tasks) {
  7573. const taskEle = $(task);
  7574. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7575. if (isSuccess && action !== 'undo') {
  7576. continue;
  7577. }
  7578. const checkButton = taskEle.find('#task_check');
  7579. const taskId = checkButton.attr('data-id');
  7580. if (taskId) {
  7581. this.tasks.push(taskId);
  7582. }
  7583. if (action === 'verify') {
  7584. continue;
  7585. }
  7586. let href = taskEle.find('a').attr('href') || null;
  7587. const text = taskEle.find('a').text().trim();
  7588. const icon = taskEle.find('i');
  7589. if (!href || !text) {
  7590. continue;
  7591. }
  7592. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7593. href = await getRedirectLink(href);
  7594. }
  7595. if (!href) {
  7596. continue;
  7597. }
  7598. if (/^https?:\/\/vk\.com\//.test(href)) {
  7599. this.socialTasks.vk.nameLinks.push(href);
  7600. if (action === 'do' && !isSuccess) {
  7601. this.undoneTasks.vk.nameLinks.push(href);
  7602. }
  7603. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7604. this.socialTasks.steam.groupLinks.push(href);
  7605. if (action === 'do' && !isSuccess) {
  7606. this.undoneTasks.steam.groupLinks.push(href);
  7607. }
  7608. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7609. this.socialTasks.steam.wishlistLinks.push(href);
  7610. if (action === 'do' && !isSuccess) {
  7611. this.undoneTasks.steam.wishlistLinks.push(href);
  7612. }
  7613. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7614. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7615. this.socialTasks.steam.curatorLinks.push(href);
  7616. if (action === 'do' && !isSuccess) {
  7617. this.undoneTasks.steam.curatorLinks.push(href);
  7618. }
  7619. } else {
  7620. this.socialTasks.steam.curatorLikeLinks.push(href);
  7621. if (action === 'do' && !isSuccess) {
  7622. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7623. }
  7624. }
  7625. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7626. this.socialTasks.twitter.userLinks.push(href);
  7627. if (action === 'do' && !isSuccess) {
  7628. this.undoneTasks.twitter.userLinks.push(href);
  7629. }
  7630. } else if (icon.hasClass('fa-discord')) {
  7631. this.socialTasks.discord.serverLinks.push(href);
  7632. if (action === 'do' && !isSuccess) {
  7633. this.undoneTasks.discord.serverLinks.push(href);
  7634. }
  7635. } else {
  7636. scripts_echoLog({
  7637. html: `<li><font class="warning">${i18n('unKnownTaskType')}: ${text}(${href})</font></li>`
  7638. });
  7639. }
  7640. }
  7641. logStatus.success();
  7642. this.tasks = unique(this.tasks);
  7643. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7644. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7645. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7646. tasks: this.socialTasks,
  7647. time: new Date().getTime()
  7648. });
  7649. return true;
  7650. } catch (error) {
  7651. throwError(error, 'Givekey.classifyTask');
  7652. return false;
  7653. }
  7654. }
  7655. async verifyTask() {
  7656. try {
  7657. if (!this.initialized && !this.init()) {
  7658. return false;
  7659. }
  7660. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7661. return false;
  7662. }
  7663. scripts_echoLog({
  7664. html: `<li><font class="warning">${i18n('giveKeyNoticeBefore')}</font></li>`
  7665. });
  7666. const taskLength = this.tasks.length;
  7667. for (let i = 0; i < taskLength; i++) {
  7668. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7669. if (i < taskLength - 1) {
  7670. await delay(15e3);
  7671. }
  7672. }
  7673. scripts_echoLog({
  7674. html: `<li><font class="success">${i18n('allTasksComplete')}</font></li>`
  7675. });
  7676. scripts_echoLog({
  7677. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7678. });
  7679. return true;
  7680. } catch (error) {
  7681. throwError(error, 'Givekey.verifyTask');
  7682. return false;
  7683. }
  7684. }
  7685. }
  7686. async function Givekey_verify2(task) {
  7687. try {
  7688. const logStatus = scripts_echoLog({
  7689. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7690. });
  7691. return await new Promise(resolve => {
  7692. $.ajax({
  7693. url: 'https://givekey.ru/giveaway/task',
  7694. method: 'POST',
  7695. data: `id=${task}&user_id=${this.userId}`,
  7696. dataType: 'json',
  7697. headers: {
  7698. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7699. },
  7700. success: data => {
  7701. if (data.btn) {
  7702. $(`button[data-id=${this.userId}]`).html(data.btn);
  7703. }
  7704. if (data.status === 'ok') {
  7705. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7706. logStatus.success();
  7707. resolve(true);
  7708. } else if (data.status === 'end') {
  7709. logStatus.success();
  7710. scripts_echoLog({
  7711. html: `<li><font class="success">${data.key}</font></li>`
  7712. });
  7713. resolve(true);
  7714. } else {
  7715. logStatus.error(`Error:${data.msg}`);
  7716. resolve(false);
  7717. }
  7718. },
  7719. error: xhr => {
  7720. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7721. resolve(false);
  7722. }
  7723. });
  7724. });
  7725. } catch (error) {
  7726. throwError(error, 'Givekey.verify');
  7727. return false;
  7728. }
  7729. }
  7730. function Givekey_getGiveawayId2() {
  7731. try {
  7732. var _window$location$href;
  7733. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7734. if (giveawayId) {
  7735. this.giveawayId = giveawayId;
  7736. return true;
  7737. }
  7738. scripts_echoLog({
  7739. text: i18n('getFailed', 'GiveawayId')
  7740. });
  7741. return false;
  7742. } catch (error) {
  7743. throwError(error, 'Givekey.getGiveawayId');
  7744. return false;
  7745. }
  7746. }
  7747. async function Givekey_checkLeftKey2() {
  7748. try {
  7749. if (!globalOptions.other.checkLeftKey) {
  7750. return true;
  7751. }
  7752. if (!$('#keys_count').text()) {
  7753. await external_Swal_default().fire({
  7754. icon: 'warning',
  7755. title: i18n('notice'),
  7756. text: i18n('noKeysLeft'),
  7757. confirmButtonText: i18n('confirm'),
  7758. cancelButtonText: i18n('cancel'),
  7759. showCancelButton: true
  7760. }).then(_ref => {
  7761. let {
  7762. value
  7763. } = _ref;
  7764. if (value) {
  7765. window.close();
  7766. }
  7767. });
  7768. }
  7769. return true;
  7770. } catch (error) {
  7771. throwError(error, 'Givekey.checkLeftKey');
  7772. return false;
  7773. }
  7774. }
  7775. const website_Givekey = Givekey;
  7776. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7777. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7778. privateSet.add(obj);
  7779. }
  7780. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7781. if (privateCollection.has(obj)) {
  7782. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7783. }
  7784. }
  7785. function GiveeClub_defineProperty(obj, key, value) {
  7786. if (key in obj) {
  7787. Object.defineProperty(obj, key, {
  7788. value: value,
  7789. enumerable: true,
  7790. configurable: true,
  7791. writable: true
  7792. });
  7793. } else {
  7794. obj[key] = value;
  7795. }
  7796. return obj;
  7797. }
  7798. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7799. if (!privateSet.has(receiver)) {
  7800. throw new TypeError('attempted to get private field on non-instance');
  7801. }
  7802. return fn;
  7803. }
  7804. var GiveeClub_checkLogin = new WeakSet();
  7805. var GiveeClub_getGiveawayId = new WeakSet();
  7806. var GiveeClub_checkLeftKey = new WeakSet();
  7807. class GiveeClub extends GiveawaySu {
  7808. constructor() {
  7809. super(...arguments);
  7810. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7811. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7812. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7813. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7814. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7815. }
  7816. static test() {
  7817. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7818. }
  7819. async after() {
  7820. try {
  7821. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7822. scripts_echoLog({
  7823. html: `<li><font class="warning">${i18n('checkLoginFailed')}</font></li>`
  7824. });
  7825. }
  7826. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7827. scripts_echoLog({
  7828. html: `<li><font class="warning">${i18n('checkLeftKeyFailed')}</font></li>`
  7829. });
  7830. }
  7831. } catch (error) {
  7832. throwError(error, 'GiveeClub.after');
  7833. }
  7834. }
  7835. init() {
  7836. try {
  7837. const logStatus = scripts_echoLog({
  7838. text: i18n('initing')
  7839. });
  7840. if (!this.checkLogin()) {
  7841. logStatus.warning(i18n('needLogin'));
  7842. return false;
  7843. }
  7844. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7845. return false;
  7846. }
  7847. this.initialized = true;
  7848. logStatus.success();
  7849. return true;
  7850. } catch (error) {
  7851. throwError(error, 'GiveeClub.init');
  7852. return false;
  7853. }
  7854. }
  7855. async classifyTask(action) {
  7856. try {
  7857. const logStatus = scripts_echoLog({
  7858. text: i18n('getTasksInfo')
  7859. });
  7860. if (action === 'undo') {
  7861. var _GM_getValue;
  7862. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7863. return true;
  7864. }
  7865. const pro = [];
  7866. const tasks = $('.event-actions tr');
  7867. for (const task of tasks) {
  7868. pro.push(new Promise(resolve => {
  7869. const taskDes = $(task).find('.event-action-label a');
  7870. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7871. const taskName = taskDes.text().trim();
  7872. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7873. return resolve(true);
  7874. }
  7875. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7876. if (!taskLink) {
  7877. return resolve(false);
  7878. }
  7879. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7880. this.undoneTasks.steam.groupLinks.push(taskLink);
  7881. } else if (/like.*announcement/gi.test(taskName)) {
  7882. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7883. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7884. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7885. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7886. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7887. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7888. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7889. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7890. this.undoneTasks.steam.forumLinks.push(taskLink);
  7891. } else if (taskIcon.includes('discord')) {
  7892. this.undoneTasks.discord.serverLinks.push(taskLink);
  7893. } else if (taskIcon.includes('instagram')) {
  7894. this.undoneTasks.instagram.userLinks.push(taskLink);
  7895. } else if (taskIcon.includes('twitch')) {
  7896. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7897. } else if (taskIcon.includes('reddit')) {
  7898. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7899. } else if (/watch.*art/gim.test(taskName)) {
  7900. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7901. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7902. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7903. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7904. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7905. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7906. this.undoneTasks.vk.nameLinks.push(taskLink);
  7907. } else {
  7908. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7909. if (/follow.*button/gim.test(taskName)) {
  7910. this.undoneTasks.steam.followLinks.push(taskLink);
  7911. }
  7912. }
  7913. }
  7914. resolve(true);
  7915. }).catch(error => {
  7916. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7917. return false;
  7918. });
  7919. }));
  7920. }
  7921. await Promise.all(pro);
  7922. logStatus.success();
  7923. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7924. this.socialTasks = this.undoneTasks;
  7925. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7926. tasks: this.socialTasks,
  7927. time: new Date().getTime()
  7928. });
  7929. return true;
  7930. } catch (error) {
  7931. throwError(error, 'GiveeClub.classifyTask');
  7932. return false;
  7933. }
  7934. }
  7935. }
  7936. function GiveeClub_checkLogin2() {
  7937. try {
  7938. if (!globalOptions.other.checkLogin) {
  7939. return true;
  7940. }
  7941. if ($('a[href*="/account/auth"]').length > 0) {
  7942. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7943. }
  7944. return true;
  7945. } catch (error) {
  7946. throwError(error, 'GiveeClub.checkLogin');
  7947. return false;
  7948. }
  7949. }
  7950. function GiveeClub_getGiveawayId2() {
  7951. var _window$location$href;
  7952. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7953. if (giveawayId) {
  7954. this.giveawayId = giveawayId;
  7955. return true;
  7956. }
  7957. scripts_echoLog({
  7958. text: i18n('getFailed', 'GiveawayId')
  7959. });
  7960. return false;
  7961. }
  7962. async function GiveeClub_checkLeftKey2() {
  7963. try {
  7964. if (!globalOptions.other.checkLeftKey) {
  7965. return true;
  7966. }
  7967. if ($('.event-ended').length > 0) {
  7968. await external_Swal_default().fire({
  7969. icon: 'warning',
  7970. title: i18n('notice'),
  7971. text: i18n('giveawayEnded'),
  7972. confirmButtonText: i18n('confirm'),
  7973. cancelButtonText: i18n('cancel'),
  7974. showCancelButton: true
  7975. }).then(_ref => {
  7976. let {
  7977. value
  7978. } = _ref;
  7979. if (value) {
  7980. window.close();
  7981. }
  7982. });
  7983. }
  7984. return true;
  7985. } catch (error) {
  7986. throwError(error, 'Giveawaysu.checkLeftKey');
  7987. return false;
  7988. }
  7989. }
  7990. const website_GiveeClub = GiveeClub;
  7991. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  7992. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  7993. privateSet.add(obj);
  7994. }
  7995. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  7996. if (privateCollection.has(obj)) {
  7997. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7998. }
  7999. }
  8000. function OpiumPulses_defineProperty(obj, key, value) {
  8001. if (key in obj) {
  8002. Object.defineProperty(obj, key, {
  8003. value: value,
  8004. enumerable: true,
  8005. configurable: true,
  8006. writable: true
  8007. });
  8008. } else {
  8009. obj[key] = value;
  8010. }
  8011. return obj;
  8012. }
  8013. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8014. if (!privateSet.has(receiver)) {
  8015. throw new TypeError('attempted to get private field on non-instance');
  8016. }
  8017. return fn;
  8018. }
  8019. const defaultOptions = {
  8020. maxPoint: '99999999'
  8021. };
  8022. var _toggleTask = new WeakSet();
  8023. var OpiumPulses_checkLogin = new WeakSet();
  8024. class OpiumPulses {
  8025. constructor() {
  8026. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8027. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8028. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8029. OpiumPulses_defineProperty(this, 'options', {
  8030. ...defaultOptions,
  8031. ...GM_getValue('OpiumPulsesOptions')
  8032. });
  8033. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8034. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8035. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8036. }
  8037. static test() {
  8038. return window.location.host === 'www.opiumpulses.com';
  8039. }
  8040. async after() {
  8041. try {
  8042. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8043. scripts_echoLog({
  8044. html: `<li><font class="warning">${i18n('checkLoginFailed')}</font></li>`
  8045. });
  8046. }
  8047. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8048. } catch (error) {
  8049. throwError(error, 'OpiumPulses.after');
  8050. }
  8051. }
  8052. async doFreeTask() {
  8053. try {
  8054. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8055. } catch (error) {
  8056. throwError(error, 'OpiumPulses.doFreeTask');
  8057. }
  8058. }
  8059. async doPointTask() {
  8060. try {
  8061. var _$$text$match;
  8062. 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);
  8063. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8064. } catch (error) {
  8065. throwError(error, 'OpiumPulses.doPointTask');
  8066. }
  8067. }
  8068. init() {
  8069. return true;
  8070. }
  8071. classifyTask() {
  8072. return true;
  8073. }
  8074. }
  8075. async function _toggleTask2(type) {
  8076. try {
  8077. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8078. for (const item of items) {
  8079. var _$$find$text$match;
  8080. 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);
  8081. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8082. if (type === 'points' && needPoints > this.myPoints) {
  8083. scripts_echoLog({
  8084. html: `<li><font class="warning">${i18n('noPoints')}: ${name}</font></li>`
  8085. });
  8086. } else if (type === 'points' && !needPoints) {
  8087. scripts_echoLog({
  8088. html: `<li><font class="warning">${i18n('getNeedPointsFailed')}: ${name}</font></li>`
  8089. });
  8090. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8091. var _aElement$attr;
  8092. const logStatus = scripts_echoLog({
  8093. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8094. });
  8095. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8096. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8097. var _aElement$attr2, _aElement$attr2$match;
  8098. 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];
  8099. if (giveawayId) {
  8100. checkUser(giveawayId);
  8101. }
  8102. }
  8103. if (!aElement.attr('href')) {
  8104. logStatus.error('Error: No "href".');
  8105. continue;
  8106. }
  8107. const {
  8108. result,
  8109. statusText,
  8110. status,
  8111. data
  8112. } = await tools_httpRequest({
  8113. url: aElement.attr('href'),
  8114. method: 'GET'
  8115. });
  8116. if (result === 'Success') {
  8117. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8118. var _data$responseText$ma;
  8119. logStatus.success();
  8120. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8121. if (type === 'points' && points) {
  8122. this.myPoints = parseInt(points, 10);
  8123. }
  8124. } else {
  8125. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8126. }
  8127. } else {
  8128. logStatus.error(`${result}:${statusText}(${status})`);
  8129. }
  8130. }
  8131. }
  8132. scripts_echoLog({
  8133. text: '-----END-----'
  8134. });
  8135. } catch (error) {
  8136. throwError(error, 'OpiumPulses.toggleTask');
  8137. }
  8138. }
  8139. function OpiumPulses_checkLogin2() {
  8140. try {
  8141. if (!globalOptions.other.checkLogin) {
  8142. return true;
  8143. }
  8144. if ($('a[href*="/site/login"]').length > 1) {
  8145. window.open('/site/login', '_self');
  8146. }
  8147. return true;
  8148. } catch (error) {
  8149. throwError(error, 'OpiumPulses.checkLogin');
  8150. return false;
  8151. }
  8152. }
  8153. const website_OpiumPulses = OpiumPulses;
  8154. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8155. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8156. privateSet.add(obj);
  8157. }
  8158. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8159. if (privateCollection.has(obj)) {
  8160. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8161. }
  8162. }
  8163. function Keylol_defineProperty(obj, key, value) {
  8164. if (key in obj) {
  8165. Object.defineProperty(obj, key, {
  8166. value: value,
  8167. enumerable: true,
  8168. configurable: true,
  8169. writable: true
  8170. });
  8171. } else {
  8172. obj[key] = value;
  8173. }
  8174. return obj;
  8175. }
  8176. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8177. if (!privateSet.has(receiver)) {
  8178. throw new TypeError('attempted to get private field on non-instance');
  8179. }
  8180. return fn;
  8181. }
  8182. const Keylol_defaultTasks = {
  8183. steam: {
  8184. groupLinks: [],
  8185. wishlistLinks: [],
  8186. curatorLinks: [],
  8187. curatorLikeLinks: [],
  8188. followLinks: [],
  8189. forumLinks: [],
  8190. announcementLinks: [],
  8191. workshopVoteLinks: []
  8192. },
  8193. discord: {
  8194. serverLinks: []
  8195. },
  8196. instagram: {
  8197. userLinks: []
  8198. },
  8199. vk: {
  8200. nameLinks: []
  8201. },
  8202. twitch: {
  8203. channelLinks: []
  8204. },
  8205. reddit: {
  8206. redditLinks: []
  8207. },
  8208. twitter: {
  8209. userLinks: [],
  8210. retweetLinks: []
  8211. },
  8212. youtube: {
  8213. channelLinks: [],
  8214. likeLinks: []
  8215. }
  8216. };
  8217. var _addBtn = new WeakSet();
  8218. class Keylol extends website_Website {
  8219. constructor() {
  8220. super(...arguments);
  8221. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8222. Keylol_defineProperty(this, 'name', 'Keylol');
  8223. Keylol_defineProperty(this, 'socialTasks', {
  8224. ...Keylol_defaultTasks
  8225. });
  8226. Keylol_defineProperty(this, 'undoneTasks', {
  8227. ...Keylol_defaultTasks
  8228. });
  8229. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8230. }
  8231. static test() {
  8232. var _$$eq$attr;
  8233. 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'));
  8234. }
  8235. init() {
  8236. return true;
  8237. }
  8238. after() {
  8239. try {
  8240. const selecter = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8241. const mainPost = $(selecter);
  8242. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8243. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8244. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8245. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8246. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8247. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8248. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8249. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8250. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8251. if (discordLinks.length > 0) {
  8252. for (const discordLink of discordLinks) {
  8253. const link = $(discordLink).attr('href');
  8254. if (!link) {
  8255. continue;
  8256. }
  8257. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8258. }
  8259. }
  8260. if (redditLinks.length > 0) {
  8261. for (const redditLink of redditLinks) {
  8262. const link = $(redditLink).attr('href');
  8263. if (!link) {
  8264. continue;
  8265. }
  8266. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8267. }
  8268. }
  8269. if (insLinks.length > 0) {
  8270. for (const insLink of insLinks) {
  8271. const link = $(insLink).attr('href');
  8272. if (!link) {
  8273. continue;
  8274. }
  8275. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8276. }
  8277. }
  8278. if (twitterLinks.length > 0) {
  8279. for (const twitterLink of twitterLinks) {
  8280. const link = $(twitterLink).attr('href');
  8281. if (!link) {
  8282. continue;
  8283. }
  8284. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8285. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8286. } else {
  8287. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8288. }
  8289. }
  8290. }
  8291. if (twitchLinks.length > 0) {
  8292. for (const twitchLink of twitchLinks) {
  8293. const link = $(twitchLink).attr('href');
  8294. if (!link) {
  8295. continue;
  8296. }
  8297. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8298. }
  8299. }
  8300. if (vkLinks.length > 0) {
  8301. for (const vkLink of vkLinks) {
  8302. const link = $(vkLink).attr('href');
  8303. if (!link) {
  8304. continue;
  8305. }
  8306. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8307. }
  8308. }
  8309. if (steamStoreLinks.length > 0) {
  8310. for (const steamStoreLink of steamStoreLinks) {
  8311. const link = $(steamStoreLink).attr('href');
  8312. if (!link) {
  8313. continue;
  8314. }
  8315. if (/app\/[\d]+/.test(link)) {
  8316. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8317. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8318. } else if (/curator\/[\d]+/.test(link)) {
  8319. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8320. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8321. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8322. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8323. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8324. }
  8325. }
  8326. }
  8327. if (steamCommunityLinks.length > 0) {
  8328. for (const steamCommunityLink of steamCommunityLinks) {
  8329. const link = $(steamCommunityLink).attr('href');
  8330. if (!link) {
  8331. continue;
  8332. }
  8333. if (/groups\/.+/.test(link)) {
  8334. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8335. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8336. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8337. }
  8338. }
  8339. }
  8340. if (ytbLinks.length > 0) {
  8341. for (const ytbLink of ytbLinks) {
  8342. const link = $(ytbLink).attr('href');
  8343. if (!link) {
  8344. continue;
  8345. }
  8346. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8347. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8348. }
  8349. }
  8350. } catch (error) {
  8351. throwError(error, 'keylol.after');
  8352. }
  8353. }
  8354. classifyTask(action) {
  8355. try {
  8356. this.socialTasks = {
  8357. ...Keylol_defaultTasks
  8358. };
  8359. this.undoneTasks = {
  8360. ...Keylol_defaultTasks
  8361. };
  8362. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8363. for (const btn of selectedBtns) {
  8364. const button = $(btn);
  8365. const social = button.attr('data-social');
  8366. const type = button.attr('data-type');
  8367. const link = button.attr('data-link');
  8368. if (!(social && type && link)) {
  8369. continue;
  8370. }
  8371. if (action === 'do') {
  8372. this.undoneTasks[social][type].push(link);
  8373. }
  8374. if (action === 'undo') {
  8375. this.socialTasks[social][type].push(link);
  8376. }
  8377. }
  8378. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8379. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8380. return true;
  8381. } catch (error) {
  8382. throwError(error, 'Keylol.classifyTask');
  8383. return false;
  8384. }
  8385. }
  8386. selectAll() {
  8387. try {
  8388. $('.auto-task-keylol').attr('selected', 'selected');
  8389. } catch (error) {
  8390. throwError(error, 'Keylol.selectAll');
  8391. }
  8392. }
  8393. selectNone() {
  8394. try {
  8395. $('.auto-task-keylol').removeAttr('selected');
  8396. } catch (error) {
  8397. throwError(error, 'Keylol.selectNone');
  8398. }
  8399. }
  8400. invertSelect() {
  8401. try {
  8402. $('.auto-task-keylol').each((index, element) => {
  8403. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8404. });
  8405. } catch (error) {
  8406. throwError(error, 'Keylol.invertSelect');
  8407. }
  8408. }
  8409. }
  8410. function _addBtn2(before, social, linkType, link) {
  8411. try {
  8412. $(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>`);
  8413. } catch (error) {
  8414. throwError(error, 'keylol.addBtn');
  8415. }
  8416. }
  8417. const website_Keylol = Keylol;
  8418. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8419. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8420. privateSet.add(obj);
  8421. }
  8422. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8423. if (privateCollection.has(obj)) {
  8424. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8425. }
  8426. }
  8427. function Opquests_defineProperty(obj, key, value) {
  8428. if (key in obj) {
  8429. Object.defineProperty(obj, key, {
  8430. value: value,
  8431. enumerable: true,
  8432. configurable: true,
  8433. writable: true
  8434. });
  8435. } else {
  8436. obj[key] = value;
  8437. }
  8438. return obj;
  8439. }
  8440. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8441. if (!privateSet.has(receiver)) {
  8442. throw new TypeError('attempted to get private field on non-instance');
  8443. }
  8444. return fn;
  8445. }
  8446. const Opquests_defaultTasks = {
  8447. steam: {
  8448. groupLinks: [],
  8449. wishlistLinks: [],
  8450. followLinks: [],
  8451. curatorLikeLinks: []
  8452. }
  8453. };
  8454. var Opquests_getGiveawayId = new WeakSet();
  8455. var Opquests_checkLogin = new WeakSet();
  8456. class Opquests extends website_Website {
  8457. constructor() {
  8458. super(...arguments);
  8459. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8460. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8461. Opquests_defineProperty(this, 'name', 'Opquests');
  8462. Opquests_defineProperty(this, 'undoneTasks', {
  8463. ...Opquests_defaultTasks
  8464. });
  8465. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8466. }
  8467. static test() {
  8468. return window.location.host === 'opquests.com';
  8469. }
  8470. async after() {
  8471. try {
  8472. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8473. scripts_echoLog({
  8474. html: `<li><font class="warning">${i18n('checkLoginFailed')}</font></li>`
  8475. });
  8476. }
  8477. } catch (error) {
  8478. throwError(error, 'Opquests.after');
  8479. }
  8480. }
  8481. init() {
  8482. try {
  8483. const logStatus = scripts_echoLog({
  8484. text: i18n('initing')
  8485. });
  8486. if ($('a[href*="/auth/redirect"]').length > 0) {
  8487. window.open('/auth/redirect', '_self');
  8488. logStatus.warning(i18n('needLogin'));
  8489. return false;
  8490. }
  8491. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8492. return false;
  8493. }
  8494. this.initialized = true;
  8495. logStatus.success();
  8496. return true;
  8497. } catch (error) {
  8498. throwError(error, 'Opquests.init');
  8499. return false;
  8500. }
  8501. }
  8502. async classifyTask(action) {
  8503. try {
  8504. if (action === 'undo') {
  8505. scripts_echoLog({
  8506. text: i18n('cannotUndo')
  8507. });
  8508. return false;
  8509. }
  8510. const logStatus = scripts_echoLog({
  8511. text: i18n('getTasksInfo')
  8512. });
  8513. const tasks = $('.w-full:contains("Validate") .items-center');
  8514. for (const task of tasks) {
  8515. const link = $(task).find('a:contains("Open")').attr('href');
  8516. const taskDes = $(task).find('div').eq(1).text().trim();
  8517. if (!link) {
  8518. continue;
  8519. }
  8520. if (/steamcommunity\.com\/groups\//.test(link)) {
  8521. this.undoneTasks.steam.groupLinks.push(link);
  8522. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8523. if (/wishlist/gim.test(taskDes)) {
  8524. this.undoneTasks.steam.wishlistLinks.push(link);
  8525. } else if (/follow/gim.test(taskDes)) {
  8526. this.undoneTasks.steam.followLinks.push(link);
  8527. }
  8528. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8529. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8530. } else {
  8531. scripts_echoLog({
  8532. html: `<li><font class="warning">${i18n('unKnownTaskType', `${taskDes}(${link})`)}</font></li>`
  8533. });
  8534. }
  8535. }
  8536. logStatus.success();
  8537. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8538. return true;
  8539. } catch (error) {
  8540. throwError(error, 'Opquests.classifyTask');
  8541. return false;
  8542. }
  8543. }
  8544. }
  8545. function Opquests_getGiveawayId2() {
  8546. try {
  8547. var _window$location$href;
  8548. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8549. if (giveawayId) {
  8550. this.giveawayId = giveawayId;
  8551. return true;
  8552. }
  8553. scripts_echoLog({
  8554. html: `<li><font class="error">${i18n('getFailed', 'GiveawayId')}</font></li>`
  8555. });
  8556. return false;
  8557. } catch (error) {
  8558. throwError(error, 'Opquests.getGiveawayId');
  8559. return false;
  8560. }
  8561. }
  8562. function Opquests_checkLogin2() {
  8563. try {
  8564. if (!globalOptions.other.checkLogin) {
  8565. return true;
  8566. }
  8567. if ($('a[href*="/auth/redirect"]').length > 0) {
  8568. window.open('/auth/redirect', '_self');
  8569. }
  8570. return true;
  8571. } catch (error) {
  8572. throwError(error, 'Opquests.checkLogin');
  8573. return false;
  8574. }
  8575. }
  8576. const website_Opquests = Opquests;
  8577. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8578. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8579. privateSet.add(obj);
  8580. }
  8581. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8582. if (privateCollection.has(obj)) {
  8583. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8584. }
  8585. }
  8586. function Gleam_defineProperty(obj, key, value) {
  8587. if (key in obj) {
  8588. Object.defineProperty(obj, key, {
  8589. value: value,
  8590. enumerable: true,
  8591. configurable: true,
  8592. writable: true
  8593. });
  8594. } else {
  8595. obj[key] = value;
  8596. }
  8597. return obj;
  8598. }
  8599. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8600. if (!privateSet.has(receiver)) {
  8601. throw new TypeError('attempted to get private field on non-instance');
  8602. }
  8603. return fn;
  8604. }
  8605. const Gleam_defaultTasks = {
  8606. steam: {
  8607. groupLinks: [],
  8608. wishlistLinks: [],
  8609. followLinks: [],
  8610. curatorLinks: [],
  8611. curatorLikeLinks: []
  8612. },
  8613. twitter: {
  8614. userLinks: [],
  8615. retweetLinks: []
  8616. },
  8617. twitch: {
  8618. channelLinks: []
  8619. },
  8620. discord: {
  8621. serverLinks: []
  8622. },
  8623. youtube: {
  8624. channelLinks: []
  8625. },
  8626. extra: {
  8627. gleam: []
  8628. }
  8629. };
  8630. const Gleam_defaultOptions = {
  8631. vlootUsername: '',
  8632. gameroundUsername: ''
  8633. };
  8634. var _checkSync = new WeakSet();
  8635. var _doGleamTask = new WeakSet();
  8636. var Gleam_getGiveawayId = new WeakSet();
  8637. var _getGleamLink = new WeakSet();
  8638. var Gleam_checkLeftKey = new WeakSet();
  8639. class Gleam extends website_Website {
  8640. constructor() {
  8641. super(...arguments);
  8642. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8643. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8644. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8645. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8646. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8647. Gleam_defineProperty(this, 'name', 'Gleam');
  8648. Gleam_defineProperty(this, 'undoneTasks', {
  8649. ...Gleam_defaultTasks
  8650. });
  8651. Gleam_defineProperty(this, 'socialTasks', {
  8652. ...Gleam_defaultTasks
  8653. });
  8654. Gleam_defineProperty(this, 'options', {
  8655. ...Gleam_defaultOptions,
  8656. ...GM_getValue('GleamOptions')
  8657. });
  8658. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8659. }
  8660. static test() {
  8661. return window.location.host === 'gleam.io';
  8662. }
  8663. async after() {
  8664. try {
  8665. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8666. const checkComplete = setInterval(() => {
  8667. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8668. clearInterval(checkComplete);
  8669. window.close();
  8670. }
  8671. });
  8672. for (const task of $('.entry-content .entry-method')) {
  8673. const taskInfo = $(task).find('.user-links');
  8674. const expandInfo = $(task).find('.expandable');
  8675. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8676. if (aElements.length > 0) {
  8677. for (const element of aElements) {
  8678. const $element = $(element);
  8679. const href = $element.attr('href');
  8680. $element.removeAttr('href')[0].click();
  8681. $element.attr('href', href);
  8682. await delay(1e3);
  8683. }
  8684. }
  8685. taskInfo[0].click();
  8686. await delay(1e3);
  8687. }
  8688. scripts_echoLog({
  8689. html: `<li><font class="warning">${i18n('gleamTaskNotice')}</font></li>`
  8690. });
  8691. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8692. scripts_echoLog({
  8693. html: `<li><font class="warning">${i18n('checkLeftKeyFailed')}</font></li>`
  8694. });
  8695. }
  8696. } catch (error) {
  8697. throwError(error, 'Gleam.after');
  8698. return false;
  8699. }
  8700. }
  8701. init() {
  8702. try {
  8703. const logStatus = scripts_echoLog({
  8704. text: i18n('initing')
  8705. });
  8706. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  8707. return false;
  8708. }
  8709. this.initialized = true;
  8710. logStatus.success();
  8711. return true;
  8712. } catch (error) {
  8713. throwError(error, 'Gleam.init');
  8714. return false;
  8715. }
  8716. }
  8717. async classifyTask(action) {
  8718. try {
  8719. const logStatus = scripts_echoLog({
  8720. text: i18n('getTasksInfo')
  8721. });
  8722. if (action === 'undo') {
  8723. var _GM_getValue;
  8724. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  8725. ...Gleam_defaultTasks
  8726. };
  8727. }
  8728. const tasks = $('.entry-content .entry-method');
  8729. for (const task of tasks) {
  8730. var _socialIcon$attr;
  8731. const $task = $(task);
  8732. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8733. continue;
  8734. }
  8735. const socialIcon = $task.find('.icon-wrapper i');
  8736. const taskInfo = $task.find('.user-links');
  8737. const taskText = taskInfo.text().trim();
  8738. const expandInfo = $task.find('.expandable');
  8739. const aElements = expandInfo.find('a.btn');
  8740. if (aElements.length > 0) {
  8741. for (const element of aElements) {
  8742. const $element = $(element);
  8743. const href = $element.attr('href');
  8744. $element.removeAttr('href')[0].click();
  8745. $element.attr('href', href);
  8746. }
  8747. }
  8748. if (socialIcon.hasClass('fa-twitter')) {
  8749. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8750. if (!link) {
  8751. continue;
  8752. }
  8753. if (/follow/gi.test(taskText)) {
  8754. if (action === 'undo') {
  8755. this.socialTasks.twitter.userLinks.push(link);
  8756. }
  8757. if (action === 'do') {
  8758. this.undoneTasks.twitter.userLinks.push(link);
  8759. }
  8760. } else if (/retweet/gim.test(taskText)) {
  8761. if (action === 'undo') {
  8762. this.socialTasks.twitter.retweetLinks.push(link);
  8763. }
  8764. if (action === 'do') {
  8765. this.undoneTasks.twitter.retweetLinks.push(link);
  8766. }
  8767. }
  8768. } else if (socialIcon.hasClass('fa-twitch')) {
  8769. if (/follow/gim.test(taskText)) {
  8770. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8771. if (!link) {
  8772. continue;
  8773. }
  8774. if (action === 'undo') {
  8775. this.socialTasks.twitch.channelLinks.push(link);
  8776. }
  8777. if (action === 'do') {
  8778. this.undoneTasks.twitch.channelLinks.push(link);
  8779. }
  8780. }
  8781. } else if (socialIcon.hasClass('fa-discord')) {
  8782. if (/join/gim.test(taskText)) {
  8783. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8784. if (!link) {
  8785. var _$task$find$attr, _$task$find$attr$matc;
  8786. 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];
  8787. if (!ggLink) {
  8788. continue;
  8789. }
  8790. link = `https://discord.com/invite/${ggLink}`;
  8791. }
  8792. if (action === 'undo') {
  8793. this.socialTasks.discord.serverLinks.push(link);
  8794. }
  8795. if (action === 'do') {
  8796. this.undoneTasks.discord.serverLinks.push(link);
  8797. }
  8798. }
  8799. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8800. continue;
  8801. } else if (socialIcon.hasClass('fa-youtube')) {
  8802. if (/subscribe/gim.test(taskText)) {
  8803. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8804. if (!link) {
  8805. continue;
  8806. }
  8807. if (action === 'undo') {
  8808. this.socialTasks.youtube.channelLinks.push(link);
  8809. }
  8810. if (action === 'do') {
  8811. this.undoneTasks.youtube.channelLinks.push(link);
  8812. }
  8813. }
  8814. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8815. if (/join.*group/gi.test(taskText)) {
  8816. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8817. if (!link) {
  8818. continue;
  8819. }
  8820. if (action === 'undo') {
  8821. this.socialTasks.steam.groupLinks.push(link);
  8822. }
  8823. if (action === 'do') {
  8824. this.undoneTasks.steam.groupLinks.push(link);
  8825. }
  8826. } else if (/follow.*curator/gi.test(taskText)) {
  8827. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8828. if (!link) {
  8829. continue;
  8830. }
  8831. if (action === 'undo') {
  8832. this.socialTasks.steam.curatorLinks.push(link);
  8833. }
  8834. if (action === 'do') {
  8835. this.undoneTasks.steam.curatorLinks.push(link);
  8836. }
  8837. }
  8838. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  8839. expandInfo.find('input').val(this.options.vlootUsername);
  8840. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8841. expandInfo.find('input').val(this.options.gameroundUsername);
  8842. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  8843. if (action !== 'do') {
  8844. continue;
  8845. }
  8846. const link = aElements.attr('href');
  8847. if (!link) {
  8848. continue;
  8849. }
  8850. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  8851. if (!gleamLink) {
  8852. continue;
  8853. }
  8854. this.undoneTasks.extra.gleam.push(gleamLink);
  8855. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') && taskText.includes('Visit') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  8856. scripts_echoLog({
  8857. html: `<li><font class="warning">${i18n('unKnownTaskType')}: ${taskText}</font></li>`
  8858. });
  8859. }
  8860. }
  8861. logStatus.success();
  8862. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8863. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8864. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8865. tasks: this.socialTasks,
  8866. time: new Date().getTime()
  8867. });
  8868. return true;
  8869. } catch (error) {
  8870. throwError(error, 'Gleam.classifyTask');
  8871. return false;
  8872. }
  8873. }
  8874. async extraDoTask(_ref) {
  8875. let {
  8876. gleam
  8877. } = _ref;
  8878. try {
  8879. const pro = [];
  8880. for (const link of gleam) {
  8881. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  8882. }
  8883. return Promise.all(pro).then(() => true);
  8884. } catch (error) {
  8885. throwError(error, 'Gleam.extraDoTask');
  8886. return false;
  8887. }
  8888. }
  8889. async verifyTask() {
  8890. try {
  8891. scripts_echoLog({
  8892. text: `${i18n('verifyingTask')}...`
  8893. });
  8894. const tasks = $('.entry-content .entry-method');
  8895. for (const task of tasks) {
  8896. const $task = $(task);
  8897. if ($task.find('i.fa-question').length === 0) {
  8898. continue;
  8899. }
  8900. const taskInfo = $task.find('.user-links');
  8901. taskInfo[0].click();
  8902. await delay(500);
  8903. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8904. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  8905. for (const button of continueBtn) {
  8906. button.click();
  8907. await delay(500);
  8908. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8909. }
  8910. }
  8911. scripts_echoLog({
  8912. text: i18n('verifiedGleamTasks')
  8913. });
  8914. } catch (error) {
  8915. throwError(error, 'Gleam.verifyTask');
  8916. return false;
  8917. }
  8918. }
  8919. }
  8920. async function _checkSync2() {
  8921. try {
  8922. return await new Promise(resolve => {
  8923. const checker = setInterval(() => {
  8924. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  8925. clearInterval(checker);
  8926. resolve(true);
  8927. }
  8928. }, 500);
  8929. });
  8930. } catch (error) {
  8931. throwError(error, 'Gleam.checkSync');
  8932. return false;
  8933. }
  8934. }
  8935. async function _doGleamTask2(link) {
  8936. try {
  8937. const logStatus = scripts_echoLog({
  8938. text: i18n('doingGleamTask')
  8939. });
  8940. return await new Promise(resolve => {
  8941. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  8942. active: true,
  8943. insert: true,
  8944. setParent: true
  8945. }).onclose = () => {
  8946. logStatus.success();
  8947. resolve(true);
  8948. };
  8949. });
  8950. } catch (error) {
  8951. throwError(error, 'Gleam.doGleamTask');
  8952. return false;
  8953. }
  8954. }
  8955. function Gleam_getGiveawayId2() {
  8956. try {
  8957. const giveawayId = window.location.pathname;
  8958. if (giveawayId) {
  8959. this.giveawayId = giveawayId;
  8960. return true;
  8961. }
  8962. scripts_echoLog({
  8963. text: i18n('getFailed', 'GiveawayId')
  8964. });
  8965. return false;
  8966. } catch (error) {
  8967. throwError(error, 'Gleam.getGiveawayId');
  8968. return false;
  8969. }
  8970. }
  8971. async function _getGleamLink2(link) {
  8972. try {
  8973. const logStatus = scripts_echoLog({
  8974. text: i18n('gettingGleamLink')
  8975. });
  8976. const {
  8977. result,
  8978. statusText,
  8979. status,
  8980. data
  8981. } = await tools_httpRequest({
  8982. url: link,
  8983. method: 'GET'
  8984. });
  8985. if (result === 'Success') {
  8986. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  8987. var _data$responseText$ma;
  8988. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8989. if (gleamLink) {
  8990. logStatus.success();
  8991. return gleamLink;
  8992. }
  8993. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  8994. return false;
  8995. }
  8996. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8997. return false;
  8998. }
  8999. logStatus.error(`${result}:${statusText}(${status})`);
  9000. return false;
  9001. } catch (error) {
  9002. throwError(error, 'Gleam.getGleamLink');
  9003. return false;
  9004. }
  9005. }
  9006. async function Gleam_checkLeftKey2() {
  9007. try {
  9008. if (!globalOptions.other.checkLeftKey) {
  9009. return true;
  9010. }
  9011. if ($('.entry-content:visible').length === 0) {
  9012. await external_Swal_default().fire({
  9013. icon: 'warning',
  9014. title: i18n('notice'),
  9015. text: i18n('giveawayNotWork'),
  9016. confirmButtonText: i18n('confirm'),
  9017. cancelButtonText: i18n('cancel'),
  9018. showCancelButton: true
  9019. }).then(_ref2 => {
  9020. let {
  9021. value
  9022. } = _ref2;
  9023. if (value) {
  9024. window.close();
  9025. }
  9026. });
  9027. }
  9028. return true;
  9029. } catch (error) {
  9030. throwError(error, 'Gleam.checkLeftKey');
  9031. return false;
  9032. }
  9033. }
  9034. const website_Gleam = Gleam;
  9035. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9036. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9037. privateSet.add(obj);
  9038. }
  9039. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9040. if (privateCollection.has(obj)) {
  9041. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9042. }
  9043. }
  9044. function SweepWidget_defineProperty(obj, key, value) {
  9045. if (key in obj) {
  9046. Object.defineProperty(obj, key, {
  9047. value: value,
  9048. enumerable: true,
  9049. configurable: true,
  9050. writable: true
  9051. });
  9052. } else {
  9053. obj[key] = value;
  9054. }
  9055. return obj;
  9056. }
  9057. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9058. if (!privateSet.has(receiver)) {
  9059. throw new TypeError('attempted to get private field on non-instance');
  9060. }
  9061. return fn;
  9062. }
  9063. const SweepWidget_defaultOptions = {
  9064. username: '',
  9065. email: ''
  9066. };
  9067. var SweepWidget_checkLogin = new WeakSet();
  9068. var SweepWidget_getGiveawayId = new WeakSet();
  9069. var _checkEnter = new WeakSet();
  9070. var _checkFinish = new WeakSet();
  9071. class SweepWidget extends website_Website {
  9072. constructor() {
  9073. super(...arguments);
  9074. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9075. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9076. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9077. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9078. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9079. SweepWidget_defineProperty(this, 'options', {
  9080. ...SweepWidget_defaultOptions,
  9081. ...GM_getValue('SweepWidgetOptions')
  9082. });
  9083. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9084. }
  9085. static test() {
  9086. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9087. }
  9088. async after() {
  9089. try {
  9090. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9091. scripts_echoLog({
  9092. html: `<li><font class="warning">${i18n('checkLoginFailed')}</font></li>`
  9093. });
  9094. }
  9095. } catch (error) {
  9096. throwError(error, 'SweepWidget.after');
  9097. }
  9098. }
  9099. init() {
  9100. try {
  9101. const logStatus = scripts_echoLog({
  9102. text: i18n('initing')
  9103. });
  9104. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9105. logStatus.warning(i18n('needLogin'));
  9106. return false;
  9107. }
  9108. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9109. return false;
  9110. }
  9111. this.initialized = true;
  9112. logStatus.success();
  9113. return true;
  9114. } catch (error) {
  9115. throwError(error, 'SweepWidget.init');
  9116. return false;
  9117. }
  9118. }
  9119. classifyTask() {
  9120. return true;
  9121. }
  9122. async doTask() {
  9123. try {
  9124. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9125. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9126. $('input[name="sw__login_name"]').val(this.options.username);
  9127. }
  9128. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9129. $('input[name="sw__login_email"]').val(this.options.email);
  9130. }
  9131. if ($('#sw_login_button:visible').length > 0) {
  9132. $('#sw_login_button')[0].click();
  9133. }
  9134. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9135. return false;
  9136. }
  9137. }
  9138. const logStatus = scripts_echoLog({
  9139. text: i18n('SweepWidgetNotice')
  9140. });
  9141. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9142. for (const task of tasks) {
  9143. var _aElement$, _$task$find$removeAtt;
  9144. const $task = $(task);
  9145. if ($task.find('i.fa-check:visible').length > 0) {
  9146. continue;
  9147. }
  9148. const title = $task.find('.sw_text_inner');
  9149. title[0].click();
  9150. const aElement = $task.find('a.sw_link');
  9151. const link = aElement.attr('href');
  9152. aElement.attr('href', '#a').attr('target', '_self');
  9153. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9154. await delay(300);
  9155. aElement.attr('href', link).attr('target', '_blank');
  9156. $task.find('input[type="text"]').val('test');
  9157. const verifyBtn = $task.find('input.sw_verify');
  9158. if (verifyBtn.prop('disabled') === true) {
  9159. title[0].click();
  9160. await delay(300);
  9161. title[0].click();
  9162. await delay(300);
  9163. }
  9164. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9165. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9166. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9167. }
  9168. logStatus.success();
  9169. return true;
  9170. } catch (error) {
  9171. throwError(error, 'SweepWidget.doTask');
  9172. return false;
  9173. }
  9174. }
  9175. }
  9176. function SweepWidget_checkLogin2() {
  9177. try {
  9178. if ($('#twitter_login_button').length > 0) {
  9179. $('#twitter_login_button')[0].click();
  9180. }
  9181. return true;
  9182. } catch (error) {
  9183. throwError(error, 'SweepWidget.checkLogin');
  9184. return false;
  9185. }
  9186. }
  9187. function SweepWidget_getGiveawayId2() {
  9188. try {
  9189. var _window$location$href;
  9190. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9191. if (giveawayId) {
  9192. this.giveawayId = giveawayId;
  9193. return true;
  9194. }
  9195. scripts_echoLog({
  9196. text: i18n('getFailed', 'GiveawayId')
  9197. });
  9198. return false;
  9199. } catch (error) {
  9200. throwError(error, 'SweepWidget.getGiveawayId');
  9201. return false;
  9202. }
  9203. }
  9204. async function _checkEnter2() {
  9205. try {
  9206. return new Promise(resolve => {
  9207. const checker = setInterval(() => {
  9208. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9209. clearInterval(checker);
  9210. resolve(true);
  9211. }
  9212. });
  9213. });
  9214. } catch (error) {
  9215. throwError(error, 'SweepWidget.checkEnter');
  9216. return false;
  9217. }
  9218. }
  9219. async function _checkFinish2($task) {
  9220. try {
  9221. return new Promise(resolve => {
  9222. const checker = setInterval(() => {
  9223. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9224. clearInterval(checker);
  9225. resolve(true);
  9226. }
  9227. });
  9228. });
  9229. } catch (error) {
  9230. throwError(error, 'SweepWidget.checkFinish');
  9231. return false;
  9232. }
  9233. }
  9234. const website_SweepWidget = SweepWidget;
  9235. const defaultWhiteList = {
  9236. discord: {
  9237. servers: []
  9238. },
  9239. instagram: {
  9240. users: []
  9241. },
  9242. twitch: {
  9243. channels: []
  9244. },
  9245. twitter: {
  9246. users: [],
  9247. retweets: [],
  9248. likes: []
  9249. },
  9250. vk: {
  9251. names: []
  9252. },
  9253. youtube: {
  9254. channels: [],
  9255. likes: []
  9256. },
  9257. reddit: {
  9258. reddits: []
  9259. },
  9260. steam: {
  9261. groups: [],
  9262. wishlists: [],
  9263. follows: [],
  9264. forums: [],
  9265. workshops: [],
  9266. curators: [],
  9267. workshopVotes: [],
  9268. curatorLikes: [],
  9269. announcements: []
  9270. }
  9271. };
  9272. const link2id = async function(type) {
  9273. 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;
  9274. try {
  9275. const link = $('#socialLink').val();
  9276. let id = '';
  9277. switch (type) {
  9278. case 'discord.servers':
  9279. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9280. break;
  9281.  
  9282. case 'instagram.users':
  9283. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9284. break;
  9285.  
  9286. case 'twitch.channels':
  9287. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9288. break;
  9289.  
  9290. case 'twitter.users':
  9291. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9292. break;
  9293.  
  9294. case 'twitter.retweets':
  9295. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9296. break;
  9297.  
  9298. case 'vk.names':
  9299. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9300. break;
  9301.  
  9302. case 'youtube.channels':
  9303. 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) || '';
  9304. break;
  9305.  
  9306. case 'youtube.likes':
  9307. 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) || '';
  9308. break;
  9309.  
  9310. case 'reddit.reddits':
  9311. 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]) || '';
  9312. break;
  9313.  
  9314. case 'steam.groups':
  9315. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9316. break;
  9317.  
  9318. case 'steam.wishlists':
  9319. case 'steam.follows':
  9320. case 'steam.forums':
  9321. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9322. break;
  9323.  
  9324. case 'steam.workshops':
  9325. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9326. break;
  9327.  
  9328. case 'steam.curators':
  9329. {
  9330. if (link.includes('curator')) {
  9331. var _link$match12;
  9332. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9333. } else {
  9334. var _link$match13;
  9335. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9336. if (!param || param.length !== 2) {
  9337. break;
  9338. }
  9339. const steam = new social_Steam();
  9340. if (await steam.init()) {
  9341. id = await steam.getCuratorId(param[0], param[1]) || '';
  9342. }
  9343. }
  9344. }
  9345. break;
  9346. }
  9347. return id;
  9348. } catch (error) {
  9349. throwError(error, 'link2id');
  9350. return i18n('getFailed', 'id');
  9351. }
  9352. };
  9353. const disabledType = {
  9354. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9355. twitter: [ 'likes' ]
  9356. };
  9357. const whiteListOptions = function(showType) {
  9358. try {
  9359. const whiteList = {
  9360. ...defaultWhiteList,
  9361. ...GM_getValue('whiteList') || {}
  9362. };
  9363. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9364. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9365. for (const [ social, types ] of Object.entries(whiteList)) {
  9366. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9367. var _disabledType$social;
  9368. 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>`;
  9369. }).join('');
  9370. }
  9371. whiteListOptionsForm += '</tbody></table></form>';
  9372. if (showType === 'swal') {
  9373. external_Swal_default().fire({
  9374. title: i18n('whiteListOptions'),
  9375. html: whiteListOptionsForm,
  9376. showConfirmButton: false,
  9377. showCloseButton: true
  9378. });
  9379. } else {
  9380. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9381. }
  9382. $('.editWhiteList').on('click', function() {
  9383. var _whiteList$social;
  9384. const value = $(this).attr('data-value');
  9385. if (!value) {
  9386. return;
  9387. }
  9388. const [ social, type ] = value.split('.');
  9389. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9390. scripts_echoLog({
  9391. html: `<li><font class="warning">${i18n('whiteListNotFound', value)}</font></li>`
  9392. });
  9393. return;
  9394. }
  9395. external_Swal_default().fire({
  9396. title: i18n('changeWhiteListOption', value),
  9397. input: 'textarea',
  9398. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9399. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9400. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9401. inputValue: whiteList[social][type].join('\n'),
  9402. showConfirmButton: true,
  9403. confirmButtonText: i18n('save'),
  9404. showCancelButton: true,
  9405. cancelButtonText: i18n('close'),
  9406. showDenyButton: true,
  9407. denyButtonText: i18n('return')
  9408. }).then(_ref => {
  9409. let {
  9410. isDenied,
  9411. isConfirmed,
  9412. value
  9413. } = _ref;
  9414. if (isDenied) {
  9415. if (showType === 'swal') {
  9416. whiteListOptions(showType);
  9417. }
  9418. return;
  9419. } else if (isConfirmed) {
  9420. whiteList[social][type] = value.split('\n');
  9421. GM_setValue('whiteList', whiteList);
  9422. external_Swal_default().fire({
  9423. title: i18n('changeWhiteListSuccess'),
  9424. icon: 'success'
  9425. });
  9426. }
  9427. });
  9428. $('#link2id').on('click', async function() {
  9429. const type = $(this).attr('data-type');
  9430. $('#socialLink').val(await link2id(type));
  9431. });
  9432. });
  9433. } catch (error) {
  9434. throwError(error, 'whiteListOptions');
  9435. }
  9436. };
  9437. const whiteList = whiteListOptions;
  9438. const setGistData = async (token, gistId, fileName, content) => {
  9439. try {
  9440. const logStatus = scripts_echoLog({
  9441. text: i18n('settingData')
  9442. });
  9443. const contentData = JSON.stringify({
  9444. files: {
  9445. [fileName]: {
  9446. content: JSON.stringify(content)
  9447. }
  9448. }
  9449. });
  9450. const {
  9451. result,
  9452. statusText,
  9453. status,
  9454. data
  9455. } = await tools_httpRequest({
  9456. url: `https://api.github.com/gists/${gistId}`,
  9457. headers: {
  9458. Accept: 'application/vnd.github.v3+json',
  9459. Authorization: `token ${token}`
  9460. },
  9461. data: contentData,
  9462. responseType: 'json',
  9463. method: 'POST',
  9464. timeout: 3e4
  9465. });
  9466. if (result === 'Success') {
  9467. var _data$response$files, _data$response$files$;
  9468. 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)) {
  9469. logStatus.success();
  9470. return true;
  9471. }
  9472. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9473. return false;
  9474. }
  9475. logStatus.error(`${result}:${statusText}(${status})`);
  9476. return false;
  9477. } catch (error) {
  9478. throwError(error, 'setGistData');
  9479. return false;
  9480. }
  9481. };
  9482. const getGistData = async (token, gistId, fileName) => {
  9483. try {
  9484. const logStatus = scripts_echoLog({
  9485. text: i18n('gettingData')
  9486. });
  9487. const {
  9488. result,
  9489. statusText,
  9490. status,
  9491. data
  9492. } = await tools_httpRequest({
  9493. url: `https://api.github.com/gists/${gistId}`,
  9494. headers: {
  9495. Accept: 'application/vnd.github.v3+json',
  9496. Authorization: `token ${token}`
  9497. },
  9498. responseType: 'json',
  9499. method: 'GET',
  9500. timeout: 3e4
  9501. });
  9502. if (result === 'Success') {
  9503. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9504. var _data$response, _data$response$files2, _data$response$files3;
  9505. logStatus.success();
  9506. 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);
  9507. }
  9508. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9509. return false;
  9510. }
  9511. logStatus.error(`${result}:${statusText}(${status})`);
  9512. return false;
  9513. } catch (error) {
  9514. throwError(error, 'getGistData');
  9515. return false;
  9516. }
  9517. };
  9518. const syncOptions = () => {
  9519. try {
  9520. const {
  9521. TOKEN,
  9522. GIST_ID,
  9523. FILE_NAME,
  9524. SYNC_HISTORY
  9525. } = GM_getValue('gistOptions') || {
  9526. TOKEN: '',
  9527. GIST_ID: '',
  9528. FILE_NAME: '',
  9529. SYNC_HISTORY: true
  9530. };
  9531. external_Swal_default().fire({
  9532. title: i18n('gistOptions'),
  9533. 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;">
  9534. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9535. ${i18n('downloadFromGist')}</button></p>`,
  9536. focusConfirm: false,
  9537. showLoaderOnConfirm: true,
  9538. 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>`,
  9539. preConfirm: async () => {
  9540. const token = $('#github-token').val();
  9541. const gistId = $('#gist-id').val();
  9542. const fileName = $('#file-name').val();
  9543. const syncHistory = $('#sync-history').prop('checked');
  9544. GM_setValue('gistOptions', {
  9545. TOKEN: token,
  9546. GIST_ID: gistId,
  9547. FILE_NAME: fileName,
  9548. SYNC_HISTORY: syncHistory
  9549. });
  9550. return await getGistData(token, gistId, fileName);
  9551. },
  9552. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9553. confirmButtonText: i18n('saveAndTest'),
  9554. showCancelButton: true,
  9555. cancelButtonText: i18n('close')
  9556. }).then(_ref => {
  9557. let {
  9558. value
  9559. } = _ref;
  9560. if (value) {
  9561. external_Swal_default().fire({
  9562. icon: 'success',
  9563. title: i18n('testSuccess')
  9564. }).then(syncOptions);
  9565. } else if (value !== undefined) {
  9566. external_Swal_default().fire({
  9567. icon: 'error',
  9568. title: i18n('testFailed')
  9569. }).then(syncOptions);
  9570. }
  9571. });
  9572. $('#upload-data').on('click', async () => {
  9573. const {
  9574. TOKEN,
  9575. GIST_ID,
  9576. FILE_NAME
  9577. } = GM_getValue('gistOptions') || {};
  9578. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9579. return external_Swal_default().fire({
  9580. icon: 'error',
  9581. title: i18n('saveAndTestNotice')
  9582. }).then(syncOptions);
  9583. }
  9584. external_Swal_default().fire({
  9585. icon: 'info',
  9586. title: i18n('processingData')
  9587. });
  9588. const data = {};
  9589. const names = GM_listValues();
  9590. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9591. for (const name of names) {
  9592. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9593. continue;
  9594. }
  9595. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9596. continue;
  9597. }
  9598. data[name] = GM_getValue(name);
  9599. }
  9600. external_Swal_default().update({
  9601. icon: 'info',
  9602. title: i18n('updatingData')
  9603. });
  9604. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9605. external_Swal_default().fire({
  9606. icon: 'success',
  9607. title: i18n('syncDataSuccess')
  9608. });
  9609. } else {
  9610. external_Swal_default().fire({
  9611. icon: 'error',
  9612. title: i18n('syncDataFailed')
  9613. });
  9614. }
  9615. });
  9616. $('#download-data').on('click', async () => {
  9617. const {
  9618. TOKEN,
  9619. GIST_ID,
  9620. FILE_NAME
  9621. } = GM_getValue('gistOptions') || {};
  9622. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9623. return external_Swal_default().fire({
  9624. icon: 'error',
  9625. title: i18n('saveAndTestNotice')
  9626. }).then(syncOptions);
  9627. }
  9628. external_Swal_default().fire({
  9629. icon: 'info',
  9630. title: i18n('downloadingData')
  9631. });
  9632. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9633. if (!data) {
  9634. return external_Swal_default().fire({
  9635. icon: 'error',
  9636. title: i18n('checkedNoData')
  9637. }).then(syncOptions);
  9638. }
  9639. external_Swal_default().update({
  9640. icon: 'info',
  9641. title: i18n('savingData')
  9642. });
  9643. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9644. for (const [ name, value ] of Object.entries(data)) {
  9645. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9646. continue;
  9647. }
  9648. GM_setValue(name, value);
  9649. }
  9650. external_Swal_default().fire({
  9651. icon: 'success',
  9652. title: i18n('syncDataSuccess')
  9653. });
  9654. });
  9655. } catch (error) {
  9656. throwError(error, 'syncOptions');
  9657. }
  9658. };
  9659. const dataSync = syncOptions;
  9660. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9661. Setting_checkPrivateRedeclaration(obj, privateSet);
  9662. privateSet.add(obj);
  9663. }
  9664. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9665. if (privateCollection.has(obj)) {
  9666. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9667. }
  9668. }
  9669. function Setting_defineProperty(obj, key, value) {
  9670. if (key in obj) {
  9671. Object.defineProperty(obj, key, {
  9672. value: value,
  9673. enumerable: true,
  9674. configurable: true,
  9675. writable: true
  9676. });
  9677. } else {
  9678. obj[key] = value;
  9679. }
  9680. return obj;
  9681. }
  9682. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9683. if (!privateSet.has(receiver)) {
  9684. throw new TypeError('attempted to get private field on non-instance');
  9685. }
  9686. return fn;
  9687. }
  9688. var Setting_getId = new WeakSet();
  9689. var _environment = new WeakSet();
  9690. class Setting {
  9691. constructor() {
  9692. Setting_classPrivateMethodInitSpec(this, _environment);
  9693. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  9694. Setting_defineProperty(this, 'name', 'Setting');
  9695. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  9696. Setting_defineProperty(this, 'dataSync', dataSync);
  9697. }
  9698. tasksHistory() {
  9699. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9700. }
  9701. static test() {
  9702. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9703. }
  9704. before() {
  9705. $('body').html('').addClass('auto-task-options');
  9706. }
  9707. after() {
  9708. try {
  9709. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  9710. changeGlobalOptions('page');
  9711. whiteList('page');
  9712. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9713. $('#getTwitterUserId').on('click', () => {
  9714. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  9715. });
  9716. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9717. $('#getYoutubeChannelId').on('click', () => {
  9718. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  9719. });
  9720. $('input[name^="position"]').on('input', function() {
  9721. const type = $(this).attr('name').replace('position.', '');
  9722. const xLabel = 'rightleft';
  9723. const yLabel = 'topbottpm';
  9724. switch (type) {
  9725. case 'buttonSideX':
  9726. case 'buttonSideY':
  9727. case 'buttonDistance':
  9728. {
  9729. const distance = $('input[name="position.buttonDistance"]').val();
  9730. const sideX = $('input[name="position.buttonSideX"]').val();
  9731. const sideY = $('input[name="position.buttonSideY"]').val();
  9732. if (![ 'right', 'left' ].includes(sideX)) {
  9733. break;
  9734. }
  9735. if (![ 'top', 'bottom' ].includes(sideY)) {
  9736. break;
  9737. }
  9738. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9739. break;
  9740. }
  9741. const distanceArr = distance.split(',');
  9742. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9743. break;
  9744. }
  9745.  
  9746. case 'showButtonSideX':
  9747. case 'showButtonSideY':
  9748. case 'showButtonDistance':
  9749. {
  9750. const distance = $('input[name="position.showButtonDistance"]').val();
  9751. const sideX = $('input[name="position.showButtonSideX"]').val();
  9752. const sideY = $('input[name="position.showButtonSideY"]').val();
  9753. if (![ 'right', 'left' ].includes(sideX)) {
  9754. break;
  9755. }
  9756. if (![ 'top', 'bottom' ].includes(sideY)) {
  9757. break;
  9758. }
  9759. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9760. break;
  9761. }
  9762. const distanceArr = distance.split(',');
  9763. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9764. break;
  9765. }
  9766.  
  9767. case 'logSideX':
  9768. case 'logSideY':
  9769. case 'logDistance':
  9770. {
  9771. const distance = $('input[name="position.logDistance"]').val();
  9772. const sideX = $('input[name="position.logSideX"]').val();
  9773. const sideY = $('input[name="position.logSideY"]').val();
  9774. if (![ 'right', 'left' ].includes(sideX)) {
  9775. break;
  9776. }
  9777. if (![ 'top', 'bottom' ].includes(sideY)) {
  9778. break;
  9779. }
  9780. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9781. break;
  9782. }
  9783. const distanceArr = distance.split(',');
  9784. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9785. break;
  9786. }
  9787.  
  9788. default:
  9789. break;
  9790. }
  9791. });
  9792. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9793. let functionKey = '';
  9794. if (event.altKey) {
  9795. functionKey += 'alt + ';
  9796. } else if (event.ctrlKey) {
  9797. functionKey += 'ctrl + ';
  9798. } else if (event.shiftKey) {
  9799. functionKey += 'shift + ';
  9800. }
  9801. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9802. });
  9803. } catch (error) {
  9804. throwError(error, 'Setting.after');
  9805. }
  9806. }
  9807. saveGlobalOptions() {
  9808. saveData();
  9809. }
  9810. }
  9811. function Setting_getId2(social) {
  9812. try {
  9813. external_Swal_default().fire({
  9814. title: i18n('getId', i18n(social)),
  9815. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9816. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9817. showCancelButton: true,
  9818. cancelButtonText: i18n('close'),
  9819. showConfirmButton: false
  9820. });
  9821. $('#link2id').on('click', async function() {
  9822. const link = $('#socialLink').val();
  9823. if (!link) {
  9824. return;
  9825. }
  9826. const type = $(this).attr('data-type');
  9827. if (type === 'twitterUser') {
  9828. var _link$match;
  9829. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9830. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9831. } else if (type === 'youtubeChannel') {
  9832. var _link$match2, _await$getInfo, _await$getInfo$params;
  9833. 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;
  9834. $('#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) || '');
  9835. }
  9836. });
  9837. } catch (error) {
  9838. throwError(error, 'Setting.getId');
  9839. }
  9840. }
  9841. function _environment2() {
  9842. try {
  9843. const userAgent = (0, javascript_utils_umd_min.ua)();
  9844. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9845. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9846. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9847. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9848. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9849. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9850. </tbody></table></form>`;
  9851. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9852. } catch (error) {
  9853. throwError(error, 'Setting.environment');
  9854. }
  9855. }
  9856. const website_Setting = Setting;
  9857. const external_dayjs_namespaceObject = dayjs;
  9858. function History_classPrivateMethodInitSpec(obj, privateSet) {
  9859. History_checkPrivateRedeclaration(obj, privateSet);
  9860. privateSet.add(obj);
  9861. }
  9862. function History_checkPrivateRedeclaration(obj, privateCollection) {
  9863. if (privateCollection.has(obj)) {
  9864. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9865. }
  9866. }
  9867. function History_defineProperty(obj, key, value) {
  9868. if (key in obj) {
  9869. Object.defineProperty(obj, key, {
  9870. value: value,
  9871. enumerable: true,
  9872. configurable: true,
  9873. writable: true
  9874. });
  9875. } else {
  9876. obj[key] = value;
  9877. }
  9878. return obj;
  9879. }
  9880. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  9881. if (!privateSet.has(receiver)) {
  9882. throw new TypeError('attempted to get private field on non-instance');
  9883. }
  9884. return fn;
  9885. }
  9886. var _addItem = new WeakSet();
  9887. class History extends website_Keylol {
  9888. constructor() {
  9889. super(...arguments);
  9890. History_classPrivateMethodInitSpec(this, _addItem);
  9891. History_defineProperty(this, 'name', 'History');
  9892. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  9893. }
  9894. static test() {
  9895. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9896. }
  9897. before() {
  9898. try {
  9899. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  9900. const data = GM_listValues() || [];
  9901. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9902. for (const item of tasksHistory) {
  9903. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  9904. }
  9905. } catch (error) {
  9906. throwError(error, 'History.before');
  9907. }
  9908. }
  9909. clearHistory() {
  9910. try {
  9911. const data = GM_listValues() || [];
  9912. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9913. for (const item of tasksHistory) {
  9914. GM_deleteValue(item);
  9915. }
  9916. external_Swal_default().fire({
  9917. title: i18n('clearHistoryFinished'),
  9918. icon: 'success'
  9919. });
  9920. } catch (error) {
  9921. throwError(error, 'History.after');
  9922. }
  9923. }
  9924. }
  9925. function _addItem2(item) {
  9926. try {
  9927. const tasksData = GM_getValue(item);
  9928. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9929. return;
  9930. }
  9931. let html = '';
  9932. let title = '';
  9933. let link = '';
  9934. const [ website, id ] = item.split('-');
  9935. switch (website) {
  9936. case 'fawTasks':
  9937. title = `Freeanywhere[${id}]`;
  9938. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9939. break;
  9940.  
  9941. case 'gasTasks':
  9942. title = `Giveawaysu[${id}]`;
  9943. link = `https://giveaway.su/giveaway/view/${id}`;
  9944. break;
  9945.  
  9946. case 'gcTasks':
  9947. title = `GiveeClub[${id}]`;
  9948. link = `https://givee.club/event/${id}`;
  9949. break;
  9950.  
  9951. case 'gkTasks':
  9952. title = `Givekey[${id}]`;
  9953. link = `https://givekey.ru/giveaway/${id}`;
  9954. break;
  9955.  
  9956. case 'gleamTasks':
  9957. title = `Gleam[${id}]`;
  9958. link = `https://gleam.io${id}`;
  9959. break;
  9960.  
  9961. case 'khTasks':
  9962. title = `keyhub[${id}]`;
  9963. link = `https://key-hub.eu/giveaway/${id}`;
  9964. break;
  9965.  
  9966. case 'prysTasks':
  9967. title = `Prys[${id}]`;
  9968. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  9969. break;
  9970.  
  9971. default:
  9972. return;
  9973. }
  9974. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  9975. for (const [ type, tasks ] of Object.entries(types)) {
  9976. for (const task of tasks) {
  9977. 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>`;
  9978. }
  9979. }
  9980. }
  9981. $('.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>`);
  9982. $('span.delete-task').on('click', function() {
  9983. const itemName = $(this).attr('data-name');
  9984. if (itemName) {
  9985. GM_deleteValue(itemName);
  9986. external_Swal_default().fire({
  9987. title: i18n('clearTaskFinished'),
  9988. text: itemName,
  9989. icon: 'success'
  9990. });
  9991. } else {
  9992. external_Swal_default().fire({
  9993. title: i18n('clearTaskFailed'),
  9994. icon: 'error'
  9995. });
  9996. }
  9997. });
  9998. } catch (error) {
  9999. throwError(error, 'History.addItem');
  10000. }
  10001. }
  10002. const website_History = History;
  10003. 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 ];
  10004. const websiteOptions = function(website, options) {
  10005. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10006. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10007. for (const [ option, value ] of Object.entries(options)) {
  10008. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10009. }
  10010. websiteOptionsForm += '</tbody></table></form>';
  10011. external_Swal_default().fire({
  10012. title: i18n('websiteOptions'),
  10013. html: websiteOptionsForm,
  10014. showConfirmButton: true,
  10015. confirmButtonText: i18n('save'),
  10016. showCancelButton: true,
  10017. cancelButtonText: i18n('close')
  10018. }).then(_ref => {
  10019. let {
  10020. isConfirmed
  10021. } = _ref;
  10022. if (isConfirmed) {
  10023. $('#websiteOptionsForm').serializeArray().map(value => {
  10024. options[value.name] = value.value;
  10025. return value;
  10026. });
  10027. GM_setValue(`${website}Options`, options);
  10028. external_Swal_default().fire({
  10029. title: i18n('changeWebsiteOptionsSuccess'),
  10030. icon: 'success'
  10031. });
  10032. }
  10033. });
  10034. };
  10035. const options = websiteOptions;
  10036. const external_keyboardJS_namespaceObject = keyboardJS;
  10037. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10038. const checkUpdate = async (source, auto) => {
  10039. try {
  10040. const checkUrl = source === 'github' ? 'https://raw.githubusercontent.com/HCLonely/auto-task-v4/main/package.json' : 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/package.json';
  10041. const {
  10042. result,
  10043. statusText,
  10044. status,
  10045. data
  10046. } = await tools_httpRequest({
  10047. url: checkUrl,
  10048. responseType: 'json',
  10049. method: 'GET',
  10050. timeout: 3e4
  10051. });
  10052. if (result === 'Success') {
  10053. var _data$response;
  10054. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10055. return data.response.version;
  10056. }
  10057. if (!auto) {
  10058. scripts_echoLog({
  10059. html: `<li><font class="error">${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]</font></li>`
  10060. });
  10061. }
  10062. return false;
  10063. }
  10064. if (!auto) {
  10065. scripts_echoLog({
  10066. html: `<li><font class="error">${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]</font></li>`
  10067. });
  10068. }
  10069. return false;
  10070. } catch (error) {
  10071. throwError(error, 'checkUpdate');
  10072. return false;
  10073. }
  10074. };
  10075. const updateChecker = async () => {
  10076. try {
  10077. const currentVersion = GM_info.script.version;
  10078. const updateSource = globalOptions.other.autoUpdateSource || 'auto';
  10079. const githubUpdateLink = `https://github.com/HCLonely/auto-task-new/raw/main/dist/${GM_info.script.name}.user.js`;
  10080. const jsdelivrUpdateLink = `https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/dist/${GM_info.script.name}.user.js`;
  10081. let version;
  10082. let updateLink = '';
  10083. if (updateSource === 'github') {
  10084. version = await checkUpdate('github', false) || currentVersion;
  10085. updateLink = githubUpdateLink;
  10086. } else if (updateSource === 'jsdelivr') {
  10087. version = await checkUpdate('jsdelivr', false) || currentVersion;
  10088. updateLink = jsdelivrUpdateLink;
  10089. } else {
  10090. const githubVersion = await checkUpdate('github', true);
  10091. if (githubVersion) {
  10092. version = githubVersion;
  10093. updateLink = githubUpdateLink;
  10094. } else {
  10095. const jsdelivrVersion = await checkUpdate('jsdelivr', true);
  10096. if (jsdelivrVersion) {
  10097. version = jsdelivrVersion;
  10098. updateLink = jsdelivrUpdateLink;
  10099. } else {
  10100. version = currentVersion;
  10101. scripts_echoLog({
  10102. html: `<li><font class="error">${i18n('checkUpdateFailed')}</font></li>`
  10103. });
  10104. }
  10105. }
  10106. }
  10107. if (version !== currentVersion) {
  10108. scripts_echoLog({
  10109. html: `<li><font class="warning">${i18n('newVersionNotice', version, updateLink)}</font></li>`
  10110. });
  10111. }
  10112. } catch (error) {
  10113. throwError(error, 'updateChecker');
  10114. }
  10115. };
  10116. const scripts_updateChecker = updateChecker;
  10117. if (window.location.hostname === 'discord.com') {
  10118. var _window$localStorage, _window$localStorage$;
  10119. 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, '');
  10120. GM_setValue('discordAuth', {
  10121. auth: discordAuth
  10122. });
  10123. if (discordAuth && window.location.hash === '#auth') {
  10124. window.close();
  10125. external_Swal_default().fire('', i18n('closePageNotice'));
  10126. }
  10127. }
  10128. const loadScript = async () => {
  10129. var _website, _website2, _website3, _website4, _website5, _website6;
  10130. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10131. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10132. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10133. if (isLogin) {
  10134. var _commonOptions, _commonOptions$header;
  10135. GM_setValue('twitchAuth', {
  10136. authToken: authToken,
  10137. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10138. });
  10139. window.close();
  10140. external_Swal_default().fire('', i18n('closePageNotice'));
  10141. } else {
  10142. external_Swal_default().fire('', i18n('needLogin'));
  10143. }
  10144. }
  10145. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10146. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10147. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10148. if (isLogin && ct0) {
  10149. GM_setValue('twitterAuth', {
  10150. ct0: ct0
  10151. });
  10152. window.close();
  10153. external_Swal_default().fire('', i18n('closePageNotice'));
  10154. } else {
  10155. external_Swal_default().fire('', i18n('needLogin'));
  10156. }
  10157. }
  10158. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10159. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10160. if (PAPISID) {
  10161. GM_setValue('youtubeAuth', {
  10162. PAPISID: PAPISID
  10163. });
  10164. window.close();
  10165. external_Swal_default().fire('', i18n('closePageNotice'));
  10166. } else {
  10167. external_Swal_default().fire('', i18n('needLogin'));
  10168. }
  10169. }
  10170. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10171. const betaButton = $('#redesign-beta-optin-btn');
  10172. if (betaButton.length > 0) {
  10173. GM_setValue('redditAuth', '#auth');
  10174. return betaButton[0].click();
  10175. }
  10176. GM_setValue('redditAuth', null);
  10177. window.close();
  10178. external_Swal_default().fire('', i18n('closePageNotice'));
  10179. }
  10180. let website;
  10181. for (const Website of Websites) {
  10182. if (Website.test()) {
  10183. website = new Website();
  10184. break;
  10185. }
  10186. }
  10187. if (!website) {
  10188. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10189. return;
  10190. }
  10191. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10192. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10193. }
  10194. $('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>`);
  10195. $('div.show-button-div').on('click', () => {
  10196. $('#auto-task-buttons').show();
  10197. $('div.show-button-div').hide();
  10198. });
  10199. const toggleLog = () => {
  10200. const $this = $('#toggle-log');
  10201. const status = $this.attr('data-status');
  10202. if (status === 'show') {
  10203. $('#auto-task-info').hide();
  10204. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10205. } else {
  10206. $('#auto-task-info').show();
  10207. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10208. }
  10209. };
  10210. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10211. if (website.doTask) {
  10212. website.doTask();
  10213. }
  10214. });
  10215. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10216. if (website.undoTask) {
  10217. website.doTask();
  10218. }
  10219. });
  10220. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10221. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10222. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10223. }
  10224. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10225. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10226. for (const button of website.buttons) {
  10227. if (website[button]) {
  10228. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10229. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10230. website[button]();
  10231. });
  10232. $('#auto-task-buttons').append(btnElement);
  10233. }
  10234. }
  10235. }
  10236. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10237. ${i18n('hideButton')}</a></p>`);
  10238. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10239. $('#auto-task-buttons').hide();
  10240. $('div.show-button-div').show();
  10241. });
  10242. 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'}">
  10243. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10244. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10245. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10246. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10247. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10248. options(website.name, website.options);
  10249. });
  10250. }
  10251. if (website.name !== 'Setting') {
  10252. GM_registerMenuCommand(i18n('whiteList'), () => {
  10253. whiteList('swal');
  10254. });
  10255. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10256. changeGlobalOptions('swal');
  10257. });
  10258. GM_registerMenuCommand(i18n('tasksHistory'), () => {
  10259. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10260. });
  10261. GM_registerMenuCommand(i18n('syncData'), dataSync);
  10262. GM_registerMenuCommand(i18n('settingPage'), () => {
  10263. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10264. });
  10265. }
  10266. GM_addStyle(auto_task.Z);
  10267. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10268. if (!GM_getValue('notice')) {
  10269. var _echoLog$font;
  10270. external_Swal_default().fire({
  10271. title: i18n('swalNotice'),
  10272. icon: 'warning'
  10273. }).then(() => {
  10274. window.open(i18n('noticeLink'), '_blank');
  10275. GM_setValue('notice', new Date().getTime());
  10276. });
  10277. (_echoLog$font = scripts_echoLog({
  10278. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10279. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10280. GM_setValue('notice', new Date().getTime());
  10281. });
  10282. }
  10283. scripts_updateChecker();
  10284. };
  10285. if (window.location.hostname === 'opquests.com') {
  10286. loadScript();
  10287. } else {
  10288. $(loadScript);
  10289. }
  10290. }();
  10291. })();