Auto Download for Beamng

This just Auto Download the clicked mod for beamng mods

  1. // ==UserScript==
  2. // @name Auto Download for Beamng
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description This just Auto Download the clicked mod for beamng mods
  6. // @author You
  7. // @match *://modshost.net/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @name:da,Hej verden name:fi
  11. // @name:da,Hej verden Hei maailma
  12. // @description:fi,Hei maailma description:eo
  13. // @description:fi,Hei maailma Saluton Mondo
  14.  
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18. //YT: https://www.youtube.com/channel/UCOA8lE9-0XnEIdHqjfQUz1A
  19. function j() {
  20. const t = ["nJy0nwvQA1LqDG", "W7pdP2BdKmoFW4Xzk8kHWQBdGCkKla", "mJi2nZyYmfLjtuXADq", "WQm1WQOSW7tdNeldUCkgW6/cLbPL", "W4z1WQvPl8klW7RdV8ks", "ntK3nKv4t2Ddwq", "mZK1nZqYtLzhCKzO", "WP1wWRlcSSkmWPeF", "jbxdRIjkmSkN", "otCWnJm4yNvsquzI", "nJuZnda3n1jlvhrfDG", "W7rFW5fcW7tdKetcNCow", "n0TIz1rRCa", "mtGYtwrZvhz3", "mJuYtvzSzMff", "WOqGW6FcMCo4W6HJ", "W7jBW5D8W7xdL3tcTCoj"];
  21. return (j = function() {
  22. return t
  23. })()
  24. }
  25.  
  26. function p(t, n) {
  27. const e = j();
  28. return p = function(n, o) {
  29. let r = e[n -= 473];
  30. if (void 0 === p.UftcuH) {
  31. const n = function(t, n) {
  32. let e, o, r = [],
  33. i = 0,
  34. c = "";
  35. for (t = function(t) {
  36. let n = "",
  37. e = "";
  38. for (let e, o, r = 0, i = 0; o = t.charAt(i++); ~o && (e = r % 4 ? 64 * e + o : o, r++ % 4) ? n += String.fromCharCode(255 & e >> (-2 * r & 6)) : 0) o = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(o);
  39. for (let t = 0, o = n.length; t < o; t++) e += "%" + ("00" + n.charCodeAt(t).toString(16)).slice(-2);
  40. return decodeURIComponent(e)
  41. }(t), o = 0; o < 256; o++) r[o] = o;
  42. for (o = 0; o < 256; o++) i = (i + r[o] + n.charCodeAt(o % n.length)) % 256, e = r[o], r[o] = r[i], r[i] = e;
  43. o = 0, i = 0;
  44. for (let n = 0; n < t.length; n++) o = (o + 1) % 256, i = (i + r[o]) % 256, e = r[o], r[o] = r[i], r[i] = e, c += String.fromCharCode(t.charCodeAt(n) ^ r[(r[o] + r[i]) % 256]);
  45. return c
  46. };
  47. p.IAwaEp = n, t = arguments, p.UftcuH = !0
  48. }
  49. const i = n + e[0],
  50. c = t[i];
  51. return c ? r = c : (void 0 === p.gTpaHi && (p.gTpaHi = !0), r = p.IAwaEp(r, o), t[i] = r), r
  52. }, p(t, n)
  53. }
  54.  
  55. function W(t, n) {
  56. const e = j();
  57. return W = function(n, o) {
  58. let r = e[n -= 473];
  59. if (void 0 === W.SgwCHP) {
  60. W.oaeBCj = function(t) {
  61. let n = "",
  62. e = "";
  63. for (let e, o, r = 0, i = 0; o = t.charAt(i++); ~o && (e = r % 4 ? 64 * e + o : o, r++ % 4) ? n += String.fromCharCode(255 & e >> (-2 * r & 6)) : 0) o = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(o);
  64. for (let t = 0, o = n.length; t < o; t++) e += "%" + ("00" + n.charCodeAt(t).toString(16)).slice(-2);
  65. return decodeURIComponent(e)
  66. }, t = arguments, W.SgwCHP = !0
  67. }
  68. const i = n + e[0],
  69. c = t[i];
  70. return c ? r = c : (r = W.oaeBCj(r), t[i] = r), r
  71. }, W(t, n)
  72. }(function(t, n) {
  73. const e = 485,
  74. o = 478,
  75. r = "BxcM",
  76. i = 479,
  77. c = "Mnx3",
  78. u = "qa#H",
  79. s = 481,
  80. a = "^*HF",
  81. f = W,
  82. l = W,
  83. d = W,
  84. m = p,
  85. h = p,
  86. w = j();
  87. for (;;) try {
  88. if (122286 === -parseInt(m(477, "wEMw")) / 1 * (parseInt(f(475)) / 2) + -parseInt(l(e)) / 3 + -parseInt(m(o, r)) / 4 * (-parseInt(l(i)) / 5) + parseInt(l(488)) / 6 * (-parseInt(m(487, c)) / 7) + parseInt(l(484)) / 8 * (-parseInt(h(483, u)) / 9) + -parseInt(d(s)) / 10 + parseInt(m(482, a)) / 11) break;
  89. w.push(w.shift())
  90. } catch (t) {
  91. w.push(w.shift())
  92. }
  93. })(), query = function(t, n) {
  94. const e = {
  95. vefWs: function(t, n) {
  96. return t != n
  97. },
  98. BeAdY: "undefined",
  99. QywoT: function(t, n) {
  100. return t(n)
  101. },
  102. rVyxk: function(t, n) {
  103. return t(n)
  104. }
  105. };
  106. try {
  107. let o = e.vefWs(typeof $, e.BeAdY) ? $ : document.querySelectorAll;
  108. return n ? [...document.querySelectorAll(t)].filter((t => !(null === el.offsetParent)))[0] : (t => Object.keys(t).length ? t : null)(e.QywoT(o, t) ? o(t).length ? e.QywoT(o, t)[0] : e.rVyxk(o, t) : null)
  109. } catch {}
  110. }, async function() {
  111. "use strict";
  112. const t = {
  113. njhQw: "Notification permission granted.",
  114. gJeNO: function(t, n) {
  115. return t !== n
  116. },
  117. sUQdZ: "hIAKj",
  118. OJxeu: function(t, n) {
  119. return t === n
  120. },
  121. wMMJA: "prompt",
  122. BNjvn: "QKsGG",
  123. NWqDj: "Error checking notification permission:",
  124. dKvDd: function(t, n) {
  125. return t(n)
  126. },
  127. Awyyu: function(t, n) {
  128. return t - n
  129. },
  130. EpmVl: "Timeout waiting for selector",
  131. zmYLD: function(t, n) {
  132. return t(n)
  133. },
  134. UYEHp: function(t, n) {
  135. return t === n
  136. },
  137. CfSqq: "CsCPf",
  138. QJOta: "TEwqh",
  139. jcpgH: "Notification permission denied.",
  140. uSYCv: "OrgAV",
  141. Gfvlu: function(t) {
  142. return t()
  143. },
  144. jBrfy: "data-attach-id",
  145. xJqCA: function(t, n) {
  146. return t(n)
  147. },
  148. jzZjo: "Got link:",
  149. sisjO: function(t, n) {
  150. return t(n)
  151. },
  152. ikpms: "download",
  153. fttfH: "#dl_btn",
  154. pXBSm: function(t, n) {
  155. return t == n
  156. },
  157. KUkqL: "beamng",
  158. UIpey: "cars",
  159. LoFSU: "maps",
  160. aBQPw: function(t, n) {
  161. return t == n
  162. }
  163. };
  164. var o = t => new Promise((n => setTimeout(n, t)));
  165. async function r() {
  166. try {
  167. if (t.gJeNO("hIAKj", t.sUQdZ)) o.log(t.njhQw);
  168. else {
  169. const n = await navigator.permissions.query({
  170. name: "notifications"
  171. });
  172. t.OJxeu(n.state, "granted") ? console.log("Notification permission granted.") : n.state === t.wMMJA ? console.log("Notification permission is pending. You might need to request it.") : console.log("Notification permission denied.")
  173. }
  174. } catch (e) {
  175. t.gJeNO(t.BNjvn, t.BNjvn) ? i(c.querySelector(n)) : console.error(t.NWqDj, e)
  176. }
  177. }
  178. async function i(n, c = 3e4) {
  179. const u = {
  180. AaMsS: function(n, e) {
  181. return t.dKvDd(n, e)
  182. },
  183. JKEdR: function(n, e) {
  184. return t.Awyyu(n, e)
  185. },
  186. tentr: t.EpmVl,
  187. BQYCP: function(n, e) {
  188. return t.zmYLD(n, e)
  189. },
  190. YVwBD: function(n, e) {
  191. return t.UYEHp(n, e)
  192. },
  193. oTIYF: t.CfSqq,
  194. qhzfo: "soXru",
  195. FDqZa: function(t, n) {
  196. return t(n)
  197. },
  198. wxfOE: function(n, e) {
  199. return t.gJeNO(n, e)
  200. },
  201. izVOq: t.QJOta,
  202. Mduvf: function(n, e) {
  203. return t.dKvDd(n, e)
  204. },
  205. nJtCp: t.jcpgH,
  206. YHHyo: t.uSYCv,
  207. lustg: function(n) {
  208. return t.Gfvlu(n)
  209. }
  210. };
  211. return await new Promise(((t, s) => {
  212. const a = {
  213. HMQyw: function(t, n) {
  214. return u.AaMsS(t, n)
  215. },
  216. xdhdC: u.nJtCp
  217. };
  218. if (u.YVwBD(u.YHHyo, u.YHHyo)) {
  219. let f = performance.now();
  220.  
  221. function l() {
  222. const o = {
  223. MuFKU: function(t, n) {
  224. return u.AaMsS(t, n)
  225. },
  226. DOKXK: function(t, n) {
  227. return t >= n
  228. },
  229. YVfBO: function(t, n) {
  230. return u.JKEdR(t, n)
  231. },
  232. piMzL: u.tentr
  233. };
  234. document.querySelector(n) ? u.BQYCP(t, document.querySelector(n)) : u.JKEdR(performance.now(), f) >= c ? u.YVwBD(u.oTIYF, u.qhzfo) ? f.querySelector(l) ? o.MuFKU(q, N.querySelector(k)) : o.DOKXK(o.YVfBO(e.now(), C), I) ? o.MuFKU(P, new R(o.piMzL)) : o.MuFKU(m, M) : u.FDqZa(s, new Error(u.tentr)) : u.wxfOE(u.izVOq, u.izVOq) ? a.HMQyw(r, i) : u.Mduvf(requestAnimationFrame, l)
  235. }
  236. u.lustg(l)
  237. } else o.log(a.xdhdC)
  238. }))
  239. }
  240. let c = location.pathname.split("/");
  241. c[1] == t.ikpms ? (await r(), await t.dKvDd(i, t.fttfH).then((n => {
  242. let e = n.getAttribute(t.jBrfy);
  243. console.log("Got link:"), t.xJqCA(open, e), opener ? t.Gfvlu(close) : history.back()
  244. })), await i("#external-button").then((async n => {
  245. n.getAttribute("data-attach-id");
  246. console.log(t.jzZjo), n.click(), await t.sisjO(o, 200), opener ? close() : history.back()
  247. })), name.length && close()) : t.pXBSm(c[1], t.KUkqL) && [t.UIpey, t.LoFSU].includes(c[2]) && t.aBQPw(history.length, 1) && (await t.sisjO(i, "#downloads").then((t => t.querySelector(".mh-local-btn") && open(t.querySelector(".mh-local-btn").href, "yes"))), t.Gfvlu(close))
  248. }().catch((t => (close(), console.warn(t))));