在您安装前,Greasy Fork 希望您知道此脚本包含可能不受欢迎的功能,也许会帮助脚本作者获利,而不能给你带来任何收益。
这个脚本会在你访问的网站插入广告。
Delta - agario 的扩展,带有缩放、小地图、辅助功能和广告拦截器
目前为
// ==UserScript== // @name 'Delta - 999999 in 1 // @name:ru 'Delta - 999999 в 1 // @name:uk 'Delta - 999999 в 1 // @name:ja 'デルタ - 999999 イン 1 // @name:es 'Delta - 999999 en 1 // @name:zh-CN 'Delta - 999999 合 1 // @name:de 'Delta - 999999 in 1 // @name:ar 'دلتا - 999999 في 1 // @description Delta - Agario extension, with zoom, minimap, helpers, adblocker // @description:es Delta - extensión para Agario con zoom, minimapa, ayudas y bloqueador de anuncios // @description:ru Delta — расширение для Agario с зумом, миникартой, помощниками и блокировщиком рекламы // @description:zh-CN Delta - agario 的扩展,带有缩放、小地图、辅助功能和广告拦截器 // @description:uk Delta — розширення для Agario із зумом, мінікартою, помічниками та блокувальником реклами // @description:tr Delta - Agario için yakınlaştırma, mini harita, yardımcılar ve reklam engelleyici uzantısı // @description:de Delta – Erweiterung für Agario mit Zoom, Minikarte, Helfern und Werbeblocker // @description:ja Delta - Agario のズーム、ミニマップ、ヘルパー、広告ブロッカー付き拡張機能 // @description:pl Delta - rozszerzenie do Agario z powiększeniem, minimapą, pomocnikami i blokadą reklam // @description:fr Delta - extension pour Agario avec zoom, mini-carte, assistants et bloqueur de publicité // @description:ar دلتا - إضافة لـ Agario مع مانع إعلانات // @version 7.9 // @namespace delta.agar // @author neo // @icon https://deltav4.gitlab.io/favicon.ico // @match *://*.agar.io/ // @run-at document-start // @grant GM.xmlHttpRequest // @grant GM.registerMenuCommand // @grant window.close // @grant unsafeWindow // @license MPL-2.0 // @antifeature ads // @supportURL https://discord.gg/HHmyKW6 // @require https://cdnjs.cloudflare.com/ajax/libs/preact/10.21.0/preact.umd.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/preact/10.21.0/hooks.umd.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/preact/10.21.0/compat.umd.min.js // @require https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4 // ==/UserScript== /* GREASYFORK VERSION Sorry, Delta is no longer available for GreasyFork users. Right now there is a lite version of Delta en: If this user script does not start, write me a discord ru: Если данное расширение не запускается, напишите мне в дискорд https://discord.gg/HHmyKW6 */ (function (window) { /******/ // runtime can't be in strict mode because a global variable is assign and maybe created. /******/ var __webpack_modules__ = ({ /***/ 32: /***/ ((module) => { "use strict"; module.exports = preact; /***/ }), /***/ 93: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ camelCaseToWords: () => (/* binding */ camelCaseToWords), /* harmony export */ find_node: () => (/* binding */ find_node), /* harmony export */ overrideMethod: () => (/* binding */ overrideMethod), /* harmony export */ overridePrototype: () => (/* binding */ overridePrototype), /* harmony export */ updateCssString: () => (/* binding */ updateCssString) /* harmony export */ }); /* unused harmony export setCssVariable */ function find_node(where = window['agarApp'].home, cond) { const results = []; const find_static = (where = window['agarApp'].home, cond) => { function each_children(child, depth) { depth += 1; child.forEach(ch => { if (cond(ch, depth)) results.push(ch); ch.children && each_children(ch.children, depth); }); } each_children(where, -1); return results; }; function each_children(child, depth) { var _a, _b, _c, _d, _e, _f, _g; depth += 1; if (cond(child, depth)) results.push(child); child._staticTrees && find_static(child._staticTrees, cond); // console.log(depth, 'TAG:', child, child.$vnode?.tag) (_a = child.$children) === null || _a === void 0 ? void 0 : _a.forEach(ch => { each_children(ch, depth); }); (_b = child.children) === null || _b === void 0 ? void 0 : _b.forEach(ch => { each_children(ch, depth); }); (_d = (_c = child._vnode) === null || _c === void 0 ? void 0 : _c.children) === null || _d === void 0 ? void 0 : _d.forEach(ch => { each_children(ch, depth); }); (_g = (_f = (_e = child._vnode) === null || _e === void 0 ? void 0 : _e.componentOptions) === null || _f === void 0 ? void 0 : _f.children) === null || _g === void 0 ? void 0 : _g.forEach(ch => { each_children(ch, depth); }); } each_children(where, -1); return results; } /** @example overrideMethod(ctx, 'drawImage', (originalMethod, args) => { return originalMethod.apply(ctx, args); }) */ function overrideMethod(obj, methodName, getMethod) { const originalMethod = obj[methodName]; obj[methodName] = function () { return getMethod(originalMethod, arguments); }; } function overridePrototype(obj, methodName, getMethod) { const originalMethod = obj[methodName]; return obj[methodName] = getMethod(originalMethod); } const updateCssString = (() => { const records = {}; return (name, css) => { if (!records[name]) { const style = document.createElement('style'); style.setAttribute('data-css-name', name); document.head.appendChild(style); records[name] = style; } records[name].textContent = css; }; })(); function setCssVariable(_line, name, value, dimension) { const root = document.body; if (dimension) value += dimension; if (value === 0) { value = 'none'; } root.style.setProperty(`--${name}`, String(value)); } function camelCaseToWords(s) { const result = s.replace(/([A-Z])/g, ' $1'); return result.charAt(0).toUpperCase() + result.slice(1); } /***/ }), /***/ 314: /***/ ((module, __unused_webpack___webpack_exports__, __webpack_require__) => { "use strict"; // EXTERNAL MODULE: ../Shared/src/utils/Eventify.ts var Eventify = __webpack_require__(742); ;// ./js/utils/storage.ts var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _Storage_namespace; class Storage { constructor() { _Storage_namespace.set(this, 'v6'); } set(key, object, namespace = __classPrivateFieldGet(this, _Storage_namespace, "f"), middleware = d => d) { localStorage.setItem(namespace + key, middleware(JSON.stringify(object))); } get(key, namespace = __classPrivateFieldGet(this, _Storage_namespace, "f"), middleware = d => d) { let obj = {}; const rawData = localStorage.getItem(namespace + key); if (typeof rawData === 'string') { try { obj = JSON.parse(middleware(rawData)); } catch (e) { console.error(e); } } return obj; } clear(key, namespace = __classPrivateFieldGet(this, _Storage_namespace, "f")) { return localStorage.removeItem(namespace + key); } } _Storage_namespace = new WeakMap(); const storage = new Storage(); // EXTERNAL MODULE: ./js/Lite/utils.ts var utils = __webpack_require__(93); ;// ./js/Lite/agario-patches.ts function coreInitPatch() { (0,utils.overrideMethod)(window['core'], 'setFpsCap', originalMethod => { return originalMethod(-1); }); } function coreUiPatch() { document.querySelector('#title').innerHTML = 'Delta'; } function coreAdsPatch() { var _a, _b, _c, _d, _e; // Ads delete (_a = (0,utils.find_node)(undefined, child => { var _a; return (_a = child.$vnode) === null || _a === void 0 ? void 0 : _a.tag.includes('-ads'); })[0]) === null || _a === void 0 ? void 0 : _a.$destroy(); (_b = (0,utils.find_node)(undefined, child => { var _a; return (_a = child.$vnode) === null || _a === void 0 ? void 0 : _a.tag.includes('-promo'); })[0]) === null || _b === void 0 ? void 0 : _b.$destroy(); (0,utils.find_node)(undefined, child => { var _a, _b; return (_b = (_a = child.elm) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.includes('agar-io'); }).forEach(child => { var _a; (_a = child.elm.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(child.elm); }); (0,utils.find_node)(undefined, child => child.playVideoAd).forEach(elem => { elem.getVideoTimestamp = () => Date.now(); }); { const vnode = (_c = (0,utils.find_node)(undefined, child => Object.getPrototypeOf(child).hasOwnProperty('hasBottomAd'))) === null || _c === void 0 ? void 0 : _c[0]; if (vnode) { Object.defineProperties(vnode, { fastEntry: { get: () => true } }); } } // Youtube, FB buttons { const vnode = (0,utils.find_node)(undefined, child => { var _a; if (((_a = child === null || child === void 0 ? void 0 : child.elm) === null || _a === void 0 ? void 0 : _a.id) == 'socialButtons') return true; })[0]; if (vnode) { vnode.elm.parentElement.removeChild(vnode.elm); } } // Skin floating badge { const bubble = (0,utils.find_node)(undefined, child => { var _a, _b; return (_b = (_a = child.data) === null || _a === void 0 ? void 0 : _a.staticClass) === null || _b === void 0 ? void 0 : _b.includes('bubble'); })[0]; (_d = bubble === null || bubble === void 0 ? void 0 : bubble.elm) === null || _d === void 0 ? void 0 : _d.parentElement.removeChild(bubble === null || bubble === void 0 ? void 0 : bubble.elm); } { const vnode = (_e = (0,utils.find_node)(undefined, child => Object.getPrototypeOf(child).hasOwnProperty('hasBottomAd'))) === null || _e === void 0 ? void 0 : _e[0]; if (vnode) { ['hasBottomAd', 'hasSideAds'].map(prop => { vnode._computedWatchers[prop]['getter'] = () => false; }); Object.defineProperties(vnode, { hasBottomAd: { get: () => false }, // hasSideAds: {get:()=> false}, // hasTopAd: {get:()=> false}, // showSideBanners: {get:()=> false}, // showBottomBanners: {get:()=> false}, fastEntry: { get: () => true } }); } } document.documentElement.style.setProperty(`--bottom-banner-height`, '0px'); let agarapp = window['agarApp']; Object.defineProperty(window, 'agarApp', { get() { return agarapp; }, set(value) { agarapp = value; onAgarApp(); } }); function onAgarApp() { var _a, _b, _c; var _d; (_a = (_d = window['agarApp']).ads) !== null && _a !== void 0 ? _a : _d.ads = {}; Object.assign(window['agarApp'].ads, { requestAds() {}, requestAd() {}, refreshAd() {}, destroyAd() {}, adSlots() {}, enableTargetedAds() {}, disableTargetedAds() {}, isTargeted() {}, supersonicAds: { BrandConnectReadyEvent() {}, BrandConnectDoneEvent() {}, BrandConnectOpenEvent() {}, BrandConnectCloseEvent() {}, BrandConnectCompletedEvent() {}, hasEngagement() { return false; } } }); if ((_b = window['agarApp']) === null || _b === void 0 ? void 0 : _b.main) ['sendEndSession', 'initDataDog', 'sendAnalyticsInitEvent', 'onGoliathReady', 'onGoliathUnload', 'initAnalytics', 'initGuestAnalytics', 'sendAnalyticsInitEvent', 'initBrowserId'].forEach(prop => { window['agarApp'].main[prop] = () => {}; }); if ((_c = window['agarApp']) === null || _c === void 0 ? void 0 : _c.MCSDK) ['sendMatchEvent'].forEach(prop => window['agarApp'].MCSDK[prop] = () => {}); } try { onAgarApp(); } catch (e) {} } function fixNoServers() { let AgarioEndpoints = null; class HookXMLHttpRequest extends window.XMLHttpRequest { constructor() { super(); } open(method, _url, async, username, password) { const url = new URL(_url, location.href); if (url.pathname.endsWith('/info')) { this.addEventListener('load', () => { const regions = JSON.parse(this.responseText); AgarioEndpoints = regions; }); } if (url.pathname.endsWith('/findServerWithFriends')) { console.log('Hooked XMLHttpRequest:', method, url); this.addEventListener('load', e => { const endpoints = JSON.parse(this.responseText); if (endpoints.status == 'no_servers') { e.stopPropagation(); e.stopImmediatePropagation(); ['responseText', 'response'].forEach(prop => { Object.defineProperty(this, prop, { value: JSON.stringify({ endpoints: { http: 'web-arenas-live-v25-0.agario.miniclippt.com/us-east-1/3-80-219-193', https: 'web-arenas-live-v25-0.agario.miniclippt.com/us-east-1/3-80-219-193' }, status: 'ok', count: 0 }) }); }); this.dispatchEvent(new ProgressEvent('load', e)); } }); } super.open(method, url, async, username, password); } } window.XMLHttpRequest = HookXMLHttpRequest; } // EXTERNAL MODULE: external "preact" var external_preact_ = __webpack_require__(32); // EXTERNAL MODULE: ./node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js var jsxRuntime_module = __webpack_require__(557); ;// ./js/utils/preact-portal.tsx class Portal extends external_preact_.Component { constructor() { super(...arguments); this.isMounted = false; } componentDidUpdate(props) { for (const i in props) { if (props[i] !== this.props[i]) { return setTimeout(() => this.renderLayer()); } } } componentDidMount() { this.isMounted = true; this.renderLayer = this.renderLayer.bind(this); this.renderLayer(); } componentWillUnmount() { this.renderLayer(false); this.isMounted = false; if (this.remote && this.remote.parentNode) this.remote.parentNode.removeChild(this.remote); } findNode(node) { return typeof node === 'string' ? document.querySelector(node) : node; } renderLayer(show = true) { if (!this.isMounted) return; // clean up old node if moving bases: if (this.props.into !== this.intoPointer) { this.intoPointer = this.props.into; if (this.into && this.remote) { // @ts-ignore this.remote = (0,external_preact_.render)((0,jsxRuntime_module.jsx)(PortalProxy, {}), createRootFragment(this.into, this.remote)); } this.into = this.findNode(this.props.into); } // @ts-ignore this.remote = (0,external_preact_.render)((0,jsxRuntime_module.jsx)(PortalProxy, { context: this.$state, children: show && this.props.children ? [this.props.children] : null }), createRootFragment(this.into, this.remote)); } render() { return null; } } class PortalProxy extends external_preact_.Component { getChildContext() { return this.props.context; } render({ children } = this.props) { return children && children[0] || null; } } /** * A Preact 11+ implementation of the `replaceNode` parameter from Preact 10. * * This creates a "Persistent Fragment" (a fake DOM element) containing one or more * DOM nodes, which can then be passed as the `parent` argument to Preact's `render()` method. */ function createRootFragment(parent, replaceNode) { if (replaceNode) { replaceNode = Array.isArray(replaceNode) ? replaceNode : [replaceNode]; } else { replaceNode = [parent]; parent = parent.parentNode; } const s = replaceNode[replaceNode.length - 1].nextSibling; const rootFragment = { nodeType: 1, parentNode: parent, firstChild: replaceNode[0], childNodes: replaceNode, insertBefore: (c, r) => { parent.insertBefore(c, r || s); return c; }, appendChild: c => { parent.insertBefore(c, s); return c; }, removeChild: function (c) { parent.removeChild(c); return c; } }; parent.__k = rootFragment; return rootFragment; } // EXTERNAL MODULE: ./js/Lite/componetns/Contexts.ts var Contexts = __webpack_require__(621); // EXTERNAL MODULE: ./js/Lite/componetns/Menu.tsx + 4 modules var Menu = __webpack_require__(647); // EXTERNAL MODULE: external "preactHooks" var external_preactHooks_ = __webpack_require__(632); ;// external "preactCompat" const external_preactCompat_namespaceObject = preactCompat; ;// ./js/Lite/componetns/Minimap.tsx function Minimap() { const app = (0,external_preactHooks_.useContext)(Contexts.AppContext); const $canvas = (0,external_preactCompat_namespaceObject.useRef)(null); const $sectors = (0,external_preactCompat_namespaceObject.useRef)(null); (0,external_preactHooks_.useLayoutEffect)(() => { const ctx = $canvas.current.getContext('2d'); const sectors = $sectors.current.querySelectorAll('.sector'); let sectorIndex = -1; let rafId = requestAnimationFrame(render); (0,utils.updateCssString)('minimap-styles', minimapStyles); function render() { const sectorId = app.world.drawMinimap(ctx, $canvas.current); setSector(sectorId); rafId = requestAnimationFrame(render); } function setSector(index) { if (index === sectorIndex || index < 0) return; index = Math.min(index, sectors.length - 1); sectorIndex !== -1 && sectors[sectorIndex].classList.remove('active'); sectors[index].classList.add('active'); sectorIndex = index; } return () => { cancelAnimationFrame(rafId); }; }, []); return (0,jsxRuntime_module.jsxs)("div", { id: "xevo-minimap", style: { zIndex: 1000 }, children: [(0,jsxRuntime_module.jsxs)("div", { class: "background", ref: $sectors, children: [(0,jsxRuntime_module.jsx)("div", { class: "sector", children: "A1" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "A2" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "A3" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "A4" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "A5" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "B1" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "B2" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "B3" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "B4" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "B5" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "C1" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "C2" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "C3" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "C4" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "C5" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "D1" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "D2" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "D3" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "D4" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "D5" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "E1" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "E2" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "E3" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "E4" }), (0,jsxRuntime_module.jsx)("div", { class: "sector", children: "E5" })] }), (0,jsxRuntime_module.jsx)("canvas", { id: "minimap", width: "200", height: "200", ref: $canvas })] }); } const minimapStyles = ` :root { --bottom-banner-height: 0px !important; } #minimap { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; } #xevo-minimap { position: fixed; bottom: 15px; right: 15px; width: 200px; height: 200px; border: 2px solid rgba(255, 255, 255, 0.3); border-radius: 10px; overflow: hidden; background-color: rgba(20, 20, 20, 0.75); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); } #xevo-minimap .background { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); width: 100%; height: 100%; } #xevo-minimap .sector { display: flex; justify-content: center; align-items: center; color: #ddd; font-size: 12px; border: 1px solid rgba(255, 255, 255, 0.2); transition: background-color 0.3s ease, transform 0.2s ease; } #xevo-minimap .sector.active { background-color: rgba(0, 191, 255, 0.3); border: 1px solid #00bfff; } `; ;// ./js/Lite/componetns/UI.tsx function initLiteui(app) { const liteui = document.createElement('div'); liteui.style = 'display:flex; flex-direction:column; overflow:hidden;'; document.getElementById('instructions').insertAdjacentElement('afterend', liteui); (0,external_preact_.render)((0,jsxRuntime_module.jsx)(jsxRuntime_module.Fragment, { children: (0,jsxRuntime_module.jsx)(Portal, { into: liteui, children: (0,jsxRuntime_module.jsx)(jsxRuntime_module.Fragment, { children: (0,jsxRuntime_module.jsxs)("div", { "data-portal": true, className: "w-full", style: "overflow: hidden;display: flex;height: 100%;flex-direction: column;", children: [(0,jsxRuntime_module.jsx)(Contexts.AppContext.Provider, { value: app, children: (0,jsxRuntime_module.jsx)(Menu.MenuButtons, {}) }), (0,jsxRuntime_module.jsx)(Contexts.AppContext.Provider, { value: app, children: (0,jsxRuntime_module.jsx)(Menu.Menu, {}) })] }) }) }) }), document.body); const minimapElem = document.createElement('div'); (0,external_preact_.render)((0,jsxRuntime_module.jsx)(Contexts.AppContext.Provider, { value: app, children: (0,jsxRuntime_module.jsx)(Minimap, {}) }), minimapElem); document.body.insertAdjacentElement('afterbegin', minimapElem); const observer = new window.MutationObserver(mtRecs => { for (const mtRec of mtRecs) { const elem = mtRec.target; if (elem.style.display !== 'none') { elem.style.display = 'flex'; elem.style.display = 'flex-direction:column'; } } }); observer.observe(window.document.querySelector('#mainPanel'), { attributeFilter: ['style'] }); } const styles = ` #title { margin-top: 0 !important; } #mainui-play { height: 595px; } #mainPanel { display: flex ; flex-direction: column; height: 100%; } #socialLoginContainer{ position: initial !important; } #instructions{ position: initial !important; display: none !important; overflow: hidden !important; flex-direction: column !important; margin: 0 !important; } .play-container { display: flex; height: 100%; padding: 0 !important; } #play { top: initial !important; } #nick{ position: initial !important; left: initial !important; top: initial !important; float: initial !important; } #skinButton { position: relative !important; display: block; left: initial !important; width: 46px; height: 46px; } #playnick { position: initial !important; display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center } #socialLoginContainer { top: initial !important; margin: 4px 20px 0px 20px !important; } .guest{ display: flex; flex-direction: column; align-items: center; } .menu-addon { gap: 4px; display: flex; flex-direction: column; align-items: center; } .menu-button { color: #fff; background-color: #54c800; border-color: #54c800; height: 34px; font-size: 20px; line-height: 1.5; padding: 0 0.5rem; } .menu-button:hover { filter: brightness(0.7) contrast(1); } .input-addon { width: 100%; height: 28px; } .circle.green { position: absolute !important; } .sprite-main { background-image: url(/mc/atlas/main_shop.png) !important; } #settingsButton { left:5px; position: absolute !important; } .circle { display: flex; justify-content: center; } .agario-panel { margin: 0 auto; } `; // EXTERNAL MODULE: ./js/Lite/settings.ts + 4 modules var settings = __webpack_require__(423); ;// ./js/Lite/utils/env.ts function makeGLobal(name, value) { window[name] = value; return value; } ;// ./js/Lite/utils/Sampler.ts class Sampler { constructor() { this.samplerIndex = 0; this.sampler = new Float32Array(30).fill(0); this.averagePerSecond = 0; this.renderedFrames = 0; this.average = 0; this.now = 0; } step() { const now = Date.now(); const elapsed = now - this.now; this.now = now; const delta = elapsed / 1000; const perSecond = 1 / delta; let average = 0; let howmuchSamples = 0; this.sampler[this.samplerIndex] = Math.round(perSecond); this.samplerIndex = (this.samplerIndex + 1) % this.sampler.length; for (let i = 0; i < Math.min(this.sampler.length, this.renderedFrames); i++) { average += this.sampler[i]; howmuchSamples++; } average = Math.round(average / howmuchSamples); this.average = average; if (this.renderedFrames <= this.sampler.length) this.renderedFrames++; } } ;// ./js/Lite/utils/wasmPatcher.ts function applyPatch(u8, operations, anyFail) { let result = u8; for (const { pattern, payload, type } of operations) { const index = findPattern(result, pattern); if (index === -1) { console.warn(`Pattern not found: ${pattern.map(b => b.toString(16)).join(' ')}`); anyFail(); continue; } let patchIndex = index; if (type === 'insertAfter') patchIndex = index + pattern.length;else if (type === 'insertBefore') patchIndex = index;else if (type === 'replaceAfter') { patchIndex = index + pattern.length; const sliceBefore = result.slice(0, patchIndex); const sliceAfter = result.slice(patchIndex + payload.length); result = concatUint8Arrays([sliceBefore, new Uint8Array(payload), sliceAfter]); continue; } else if (type === 'replaceBefore') { patchIndex = index - payload.length; if (patchIndex < 0) throw new Error('replaceBefore would underflow the buffer'); const sliceBefore = result.slice(0, patchIndex); const sliceAfter = result.slice(index); result = concatUint8Arrays([sliceBefore, new Uint8Array(payload), sliceAfter]); continue; } // Default insert const sliceBefore = result.slice(0, patchIndex); const sliceAfter = result.slice(patchIndex); result = concatUint8Arrays([sliceBefore, new Uint8Array(payload), sliceAfter]); } return result; } function findPattern(buffer, pattern) { for (let i = 0; i <= buffer.length - pattern.length; i++) { let match = true; for (let j = 0; j < pattern.length; j++) { if (buffer[i + j] !== pattern[j]) { match = false; break; } } if (match) return i; } return -1; } function concatUint8Arrays(arrays) { const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0); const result = new Uint8Array(totalLength); let offset = 0; for (const arr of arrays) { result.set(arr, offset); offset += arr.length; } return result; } ;// ./js/Lite/World.ts class World { constructor(app) { this.xorBuffer = (buffer, key) => { const dataView = new DataView(buffer); for (let i = 0; i < dataView.byteLength; i++) { dataView.setUint8(i, dataView.getUint8(i) ^ key >>> i % 4 * 8 & 255); } return buffer; }; this.overWriteWS = _target => { const target = _target; setTimeout(() => { target._onopen = target.onopen; target._onmessage = target.onmessage; target.onopen = e => { this.reset(); target._onopen(e); }; target.onmessage = message => { target._onmessage(message); let offset = 0; let msg = message.data; if (this.decryptionKey) msg = this.xorBuffer(msg, this.decryptionKey ^ 31122); const view = new DataView(msg); const opcode = view.getUint8(offset++); switch (opcode) { case 17: const playerX = view.getFloat32(offset, true); offset += 4; const playerY = view.getFloat32(offset, true); offset += 4; this.targetX = this.receiveX(playerX); this.targetY = this.receiveY(playerY); break; case 32: this.myCellIds.push(view.getUint32(offset, true)); break; case 69: this.ghostCells(view, offset); break; case 241: this.decryptionKey = view.getUint32(offset, true); break; case 255: this.handleMessages(this.uncompressMessage(new Uint8Array(view.buffer.slice(5)), new Uint8Array(view.getUint32(offset, true)))); break; } }; }, 0); }; this.websocketHooked = false; this.reset(); this.app = app; } reset() { this.minimap = []; this.offsetX = 0; this.offsetY = 0; this.borderX = 0; this.borderY = 0; this.targetX = 0; this.targetY = 0; this.myCellIds = []; this.decryptionKey = 0; this.mapOffsetFixed = false; this.mapShiftX = 0; this.mapShiftY = 0; this.mapOffsetX = 0; this.mapOffsetY = 0; this.mapMinX = 0; this.mapMinY = 0; this.mapMaxX = 0; this.mapMaxY = 0; this.mapMidX = 0; this.mapMidY = 0; this.mapSizeH = 0; this.mapSizeV = 0; this.mapShrinkW = 0; this.mapShrinkH = 0; this.viewX = 0; this.viewY = 0; this.mirrorV = false; this.mirrorH = false; } uncompressMessage(input, output) { for (let i = 0, j = 0; i < input.length;) { const byte = input[i++]; let literalsLength = byte >> 4; if (literalsLength > 0) { let length = literalsLength + 240; while (length === 255) { length = input[i++]; literalsLength += length; } const end = i + literalsLength; while (i < end) output[j++] = input[i++]; if (i === input.length) return output; } const offset = input[i++] | input[i++] << 8; if (offset === 0 || offset > j) return -(i - 2); let matchLength = byte & 15; let length = matchLength + 240; while (length === 255) { length = input[i++]; matchLength += length; } let pos = j - offset; const end = j + matchLength + 4; while (j < end) output[j++] = output[pos++]; } return output; } handleMessages(message) { let offset = 0; const view = new DataView(message.buffer); const opcode = view.getUint8(offset++); switch (opcode) { case 16: { const eatRecordLength = view.getUint16(offset, true); offset += 2; for (let i = 0; i < eatRecordLength; i++) offset += 8; while (true) { const id = view.getUint32(offset, true); offset += 4; if (id === 0) break; const targetX = this.receiveX(view.getInt32(offset, true)); offset += 4; const targetY = this.receiveY(view.getInt32(offset, true)); offset += 4; offset += 2; const flags = view.getUint8(offset++); const extendedFlags = flags & 128 ? view.getUint8(offset++) : 0; if (flags & 2) offset += 3; if (flags & 4) while (view.getInt8(offset++) !== 0) { /* intentionally left empty */ } if (flags & 8) while (view.getInt8(offset++) !== 0) { /* intentionally left empty */ } if (extendedFlags & 4) offset += 4; if (this.myCellIds.indexOf(id) !== -1) { this.targetX = targetX; this.targetY = targetY; } } const removeLength = view.getUint16(offset, true); offset += 2; for (let i = 0; i < removeLength; i++) { const removedID = view.getUint32(offset, true); offset += 4; if (this.myCellIds.includes(removedID)) this.myCellIds = this.myCellIds.filter(id => id != removedID); } } break; case 64: const minx = view.getFloat64(offset, true); offset += 8; const miny = view.getFloat64(offset, true); offset += 8; const maxx = view.getFloat64(offset, true); offset += 8; const maxy = view.getFloat64(offset, true); if (!this.mapOffsetFixed) { this.offsetX = (minx + maxx) / 2; this.offsetY = (miny + maxy) / 2; this.borderX = maxx - minx; this.borderY = maxy - miny; this.setMapOffset(minx, miny, maxx, maxy); this.mapOffsetFixed = true; } break; } } setMapOffset(left, top, right, bottom) { const isAgario = true; if (right - left > 14000 && bottom - top > 14000 || !isAgario) { if (this.mapOffsetFixed) return; if (isAgario) { const side = 14142; this.mapShrinkW = side / (right - left); this.mapShrinkH = side / (bottom - top); left = this.shrinkX(left); top = this.shrinkY(top); right = this.shrinkX(right); bottom = this.shrinkY(bottom); } this.mapShiftY = 0; this.mapShiftX = 0; const prX = -(right - left) * 0.5; const prY = -(bottom - top) * 0.5; const diffX = prX - left; const diffY = prY - top; this.mapShiftX = -diffX; this.mapShiftY = -diffY; left = this.shiftX(left); top = this.shiftY(top); right = this.shiftX(right); bottom = this.shiftY(bottom); this.mapOffsetX = (right - left) * 0.5 - right; this.mapOffsetY = (bottom - top) * 0.5 - bottom; this.mapMinX = left; this.mapMinY = top; this.mapMaxX = right; this.mapMaxY = bottom; this.mapMidX = (this.mapMaxX + this.mapMinX) * 0.5; this.mapMidY = (this.mapMaxY + this.mapMinY) * 0.5; this.mapSizeH = this.mapMaxX - this.mapMinX; this.mapSizeV = this.mapMaxY - this.mapMinY; if (!this.mapOffsetFixed) { this.viewX = (right + left) * 0.5; this.viewY = (bottom + top) * 0.5; } this.mapOffsetFixed = true; } else {} } ghostCells(view, offset) { this.minimap = []; let x = 0, y = 0, mass = 0; const length = view.getUint16(offset, true); offset += 2; for (let i = 0; i < length; i++) { x = this.receiveX(view.getInt32(offset, true)); offset += 4; y = this.receiveY(view.getInt32(offset, true)); offset += 4; mass = view.getUint32(offset, true); offset += 5; this.minimap.push({ x: x, y: y, size: ~~Math.sqrt(100 * mass), mass: mass }); } } unshrinkX(x) { return x / this.mapShrinkW; } unshrinkY(y) { return y / this.mapShrinkH; } shrinkX(x) { return x * this.mapShrinkW; } shrinkY(y) { return y * this.mapShrinkH; } unshiftX(x) { return x - -this.mapShiftX; } unshiftY(y) { return y - -this.mapShiftY; } shiftX(x) { return x - this.mapShiftX; } shiftY(y) { return y - this.mapShiftY; } invflipX(x) { return this.mirrorH ? x : this.mapMaxX - (x - this.mapMinX); } invflipY(y) { return this.mirrorV ? y : this.mapMaxY - (y - this.mapMinY); } flipX(x) { return !this.mirrorH ? x : this.mapMaxX - (x - this.mapMinX); } flipY(y) { return !this.mirrorV ? y : this.mapMaxY - (y - this.mapMinY); } receiveX(x) { x = this.shrinkX(x); x = this.shiftX(x); x = this.flipX(x); return x; } receiveY(y) { y = this.shrinkY(y); y = this.shiftY(y); y = this.flipY(y); return y; } serverX(x) { x = this.flipX(x); x = this.unshiftX(x); x = this.unshrinkX(x); return x; } serverY(y) { y = this.flipY(y); y = this.unshiftY(y); y = this.unshrinkY(y); return y; } drawMinimap(ctx, canvas, clear = true) { function safe(number) { return number == 0 ? 1 : number; } if (clear) ctx.clearRect(0, 0, canvas.width, canvas.height); this.minimap.forEach(cell => { const x = safe(cell.x + this.borderX / 2) / this.borderX * canvas.width; const y = safe(cell.y + this.borderY / 2) / this.borderY * canvas.height; const size = cell.size / this.borderX * canvas.width + 1; ctx.fillStyle = '#ffd700'; ctx.beginPath(); ctx.arc(x, y, size, 0, Math.PI * 2); ctx.fill(); }); const playerX = safe(this.targetX + this.borderX / 2) / this.borderX * canvas.width; const playerY = safe(this.targetY + this.borderY / 2) / this.borderY * canvas.height; ctx.fillStyle = '#00bfff'; ctx.beginPath(); ctx.arc(playerX, playerY, 5, 0, Math.PI * 2); ctx.fill(); const sectorSizeX = canvas.width / 5; const sectorSizeY = canvas.height / 5; const sectorCol = Math.floor(playerX / sectorSizeX); const sectorRow = Math.floor(playerY / sectorSizeY); const activeSectorIndex = sectorRow * 5 + sectorCol; return Number.isFinite(activeSectorIndex) ? activeSectorIndex : -1; } initialize() { if (this.websocketHooked) return console.error('Error: WebSocket already hooked'); this.websocketHooked = true; // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; class WS extends window.WebSocket { constructor(url, protocols) { const errorStack = new Error().stack; const isAgar = /wasm:\/\//.test(errorStack); super(url, protocols); if (isAgar) self.overWriteWS(this); } } WS.injectedOnce = false; window.WebSocket = WS; } } ;// ./js/Lite/App.ts var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; class App { display_vue() { return (0,utils.find_node)(window['agarApp'].home, (child, depth) => { var _a; console.log(child, (_a = child === null || child === void 0 ? void 0 : child.$vnode) === null || _a === void 0 ? void 0 : _a.tag); return true; }); } constructor() { this.sampler = new Sampler(); this.performance_now = 0; // for speedhack this.timer_mp = 1; // time multiplier this.waitForSpawn = false; // respawn ways this.zoom_speed = 0.8; // zoom speed core this.sector = 5; this.zoomvalue = 0.3; this.stopmovement = false; this.mouse = { x: 0, y: 0 }; this.camera = { x: 0, y: 0 }; this.state = (0,Eventify.EventObject)({ play: false, pause: false, ws: '' }); this.memory = (0,Eventify.EventObject)({ skinUrl: '' }); this.mainui = null; this.emsc = null; // emscripten module this.observerPatcher = e => { window['app'] = this; const app = 'window.app'; window['applyPatch'] = applyPatch; const replacements = { registerSkin: [[/("\s?registerSkin\s?"\s?:\s?function\s?\(\s?(.+?)\s?,\s?(.+?)\s?,\s?(.+?)\s?,\s?(.+?)\s?,\s?(.+?)\s?\)\s?\{\s?)/i, `$1${app}.onRegisterSkin($2,$3,$4,$5,$6);`]], onConnect: [[/(;..?\s?\.\s?onopen\s?=\s?function\s?\(\s?\)\s?\{\s?)/i, `$1${app}.onConnect(this.url, this);`]], mobileData: [[/(\s?if\s?\(\s?window\s?\[\s?"\s?MC\s?"\s?]\s?&&\s?window\s?\[\s?"\s?MC\s?"\s?]\s?\[\s?"\s?onMobileData\s?"\s?]\s?\)\s?window\s?\[\s?"\s?MC\s?"\s?]\s?\[\s?"\s?onMobileData\s?"\s?]\s?\(\s?(.+?)\s?\))/i, `$2=${app}.onPacket($2);$1`]], 'Emscripten hook': [[/(\w+)\W+instantiateWasm/, `(${app}.onEmscripten($1)), $&`]], 'Mouse hook': [[/("\s?setTarget\s?"\s?:\s?function\s?\(\s?(.+?)\s?,\s?(.+?)\s?\)\s?\{\s?)/i, `$1$2=${app}.onMouseX($2);$3=${app}.onMouseY($3);`]], 'Player Zoom': [[/("\s?playerZoom\s?"\s?:\s?function\s?\(\s?(.+?)\s?\)\s?\{\s?)/i, `$1$2=${app}.onPlayerZoom($2);`]], 'WebSocket onclose': [[/(;..?\s?\.\s?onclose\s?=\s?function\s?\(\s?\)\s?\{\s?)/i, `$1${app}.onDisconnect(this);`]], 'WebSocket onerror': [[/(;..?\s?\.\s?onerror\s?=\s?function\s?\(\s?\)\s?\{\s?)/i, `$1${app}.onDisconnect(this);`]], 'Binary Patch': [[/(instantiate\(\s?)([^,]+)/, `$1${app}.patchWasm($2)`]], something: [[/([a-z]{6}\s?[a-z|A-Z]{16}\s?\(\s?([a-z]{6})\s?,\s?[a-z|A-Z]{10}\s?,\s?[a-z|A-Z]{7}\s?,\s?[a-zA-Z]{8}\s?\)\s?\{\s?)/i, '$1$2=true;']] }; for (const [name, array] of Object.entries(replacements)) { let current = 0; for (const [regexp, replacer] of array) { if (regexp.test(e)) { e = e.replace(regexp, replacer); current++; } else { console.log(`[Not Found - ${current}]: `, name); } } } return e; }; this.calls = []; this.world = new World(this); const storageName = 'lite_settings'; settings.settings.import(Object.assign(Object.assign({}, settings.settings.export()), storage.get(storageName))); settings.settings.on('*', _ => { storage.set(storageName, settings.settings.export()); }); Object.assign(this.memory, storage.get('memory')); this.memory.on('*', () => { console.log('nick', this.memory); storage.set('memory', this.memory); }); // this.memory.on('skinUrl', () => { // // @ts-ignore // if (this.memory.skinUrl) // try { // window['core'].registerSkin( // document.getElementById('nick').value, // null, // this.memory.skinUrl, // 2, // null // ); // } catch (e) {} // })(); this.initObserver().then(() => { this.world.initialize(); this.waitCore().then(() => { this.handleCoreInit(); }); }); (0,utils.overrideMethod)(window.console, 'log', function (o, args) { var _a, _b; if ((_b = (_a = args[0]).startsWith) === null || _b === void 0 ? void 0 : _b.call(_a, ' ,,,,,')) return window.console.log = o; return o.apply(this, args); }); } loadAndPatchCore(url, resolve) { return __awaiter(this, void 0, void 0, function* () { try { const request = new XMLHttpRequest(); request.open('GET', url, false); request.onload = () => { const patchedText = this.observerPatcher(request.responseText); const blob = new Blob([patchedText], { type: 'text/javascript' }); const blobURL = URL.createObjectURL(blob); const script = document.createElement('script'); script.id = 'agario.core.js'; script.src = blobURL; script.onload = () => { URL.revokeObjectURL(blobURL); resolve(); }; document.body.appendChild(script); }; request.send(); } catch (error) { console.error('[ERROR] Failed to load and patch core:', error); } }); } initObserver() { const deferred = (0,Eventify.deferrify)(); const observer = new window.MutationObserver(mtRecs => { var _a; for (const mtRec of mtRecs) { for (let i = 0; i < mtRec.addedNodes.length; i++) { const elem = mtRec.addedNodes[i]; const [t] = elem.src && elem.src.match(/agario\.core\.js.+/i) || []; if (t) { observer.disconnect(); elem.remove(); (_a = elem.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(elem); this.loadAndPatchCore(t, deferred.resolve); } } } }); observer.observe(document, { childList: true, subtree: true }); return deferred.promise; } patchWasm(u) { let anyFail = false; const patchedUint8Array = applyPatch(new Uint8Array(u), [{ pattern: [0x45, 0x0d, 0x00, 0x20, 0x02, 0x10, 0x0f, 0x20, 0x01, 0x20, 0x02, 0x10, 0x1e, 0x21, 0x01], payload: [0x20, 0x00, 0x28, 0x02, 0x1c, 0x45, 0x04, 0x40, 0x0f, 0x0b], type: 'insertAfter' }, { pattern: [0x81, 0x03, 0x84, 0x03, 0x10, 0x87, 0x03, 0x86, 0x03, 0x85, 0x03, 0x0a], payload: [203], type: 'replaceAfter' }, { pattern: [0x00, 0x20, 0x00, 0x20, 0x04, 0x37, 0x03, 0x08, 0x20, 0x03, 0x41, 0x10, 0x6a, 0x24, 0x00, 0x0b], payload: [138], type: 'replaceAfter' }, { pattern: [0x01, 0x2d, 0x00, 0x07, 0x20, 0x02, 0x41, 0x1b, 0x6c, 0x41, 0x01, 0x6a, 0x73, 0x3a, 0x00, 0x07, 0x20, 0x1f, 0xbf, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], payload: [0, 0], type: 'replaceAfter' }], () => anyFail = true); if (anyFail) return u; return patchedUint8Array.buffer; } waitCore() { return __awaiter(this, void 0, void 0, function* () { const deferred = (0,Eventify.deferrify)(); addEventListener('core_init_complete', () => { var _a; if (!window['core']) { // backup event if ((_a = window['MC']) === null || _a === void 0 ? void 0 : _a['onAgarioCoreLoaded']) { const old_loaded = window['MC']['onAgarioCoreLoaded']; window['MC']['onAgarioCoreLoaded'] = function () { deferred.resolve(); window['MC']['onAgarioCoreLoaded'] = old_loaded; return old_loaded.apply(this, arguments); }; return; } // deadline mode Object.defineProperty(window, 'core', { get: () => window['_core'], set: value => (window['_core'] = value, deferred.resolve()) }); return; } deferred.resolve(); }); addEventListener('event_regions_update', () => __awaiter(this, void 0, void 0, function* () {})); // let rafRequest: any = null; // function watchVue() { // rafRequest = requestAnimationFrame(() => { // if (window['agarApp']) cancelAnimationFrame(rafRequest); // coreAdsPatch(); // }); // } // watchVue(); // addEventListener('free_coins_timer', async (e) => { // console.log('coins ready', e['detail'] == 0); // window['agarApp'].API.getFreeCoins(); // }); // Object.defineProperty(window, 'mcReady', { // get: () => () => {}, // set: () => {} // }); return deferred.promise; }); } handleCoreInit() { coreInitPatch(); coreAdsPatch(); fixNoServers(); coreUiPatch(); this.init(); this.onCoreInit(); (0,utils.updateCssString)('main', styles); initLiteui(this); } modifyScore(sourceString) { if (!this.state.play) sourceString = ''; return `${sourceString}`; } init() { const modifyScore = this.modifyScore.bind(this); const onPlayerSpawn = this.onPlayerSpawn.bind(this); const onPlayerDeath = this.onPlayerDeath.bind(this); // timelord.activate(); // this.performance_now = window.performance['_now'](); // const updateRealTime = (realTime_ms: number) => { // const dt = realTime_ms - this.performance_now; // timelord.stepTime(dt * (settings.proxy.AnimationDelay / 100), dt * this.timer_mp); // this.performance_now = realTime_ms; // window['_requestAnimationFrame'](updateRealTime); // }; // updateRealTime(this.performance_now); (0,utils.overridePrototype)(CanvasRenderingContext2D.prototype, 'fillText', o => { return function () { if (arguments[0].includes('Scor')) { arguments[0] = modifyScore(arguments[0]); } else if (arguments[0].startsWith('Leaderboard')) { arguments[0] = settings.settings.proxy.LeaderboardTitle; } return o.apply(this, arguments); }; }); (0,utils.overridePrototype)(CanvasRenderingContext2D.prototype, 'measureText', o => { return function () { if (arguments[0].includes('Scor')) { arguments[0] = modifyScore(arguments[0]); } return o.apply(this, arguments); }; }); (0,utils.overrideMethod)(window['MC'], 'onPlayerSpawn', function (o, args) { o.apply(this, args); onPlayerSpawn(...args); }); (0,utils.overrideMethod)(window['MC'], 'onPlayerDeath', function (o, args) { o.apply(this, args); onPlayerDeath(...args); }); } onEmscripten(Module) { var _a, _b; this.emsc = Module; makeGLobal('emsc', Module); console.log('emsc', Module); const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); const world = this.world; function numberIsInRange(value, min, max) { return value >= min && value <= max; } // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; const traceCalls = ['clearRect', 'drawImage', 'fillText', 'strokeText', 'fillRect', 'strokeRect', // 'beginPath', 'moveTo', // 'lineTo', // 'arc', 'scale', 'save', 'restore', 'translate', 'transform', 'setTransform']; let gotScale = false; let callNumber = -1; traceCalls.forEach(method => { // @ts-ignore (0,utils.overrideMethod)(ctx, method, function (o, args) { callNumber++; // self.calls.push(method); // if (callNumber === 3) console.log('scale', ...args); // if (callNumber === 2) { // console.log('translate', ...args); // } // if (numberIsInRange(callNumber - 1, 1, 7)) function () {}; // Off grid const cmd = o.apply(ctx, args); return cmd; }); }); (0,utils.overrideMethod)(ctx, 'scale', function (o, args) { if (!gotScale) { gotScale = true; self.zoomvalue = args[0]; } const cmd = o.apply(ctx, args); return cmd; }); // if (callNumber == 9) console.log('canvas', args[0], args[1]); // if (callNumber == 11) console.log('cam', args[0], args[1]); (0,utils.overrideMethod)(ctx, 'drawImage', function (o, args) { let dx = 0, dy = 0, dw = 0, dh = 0; if (args.length == 9) { dx = args[5]; dy = args[6]; dw = args[7]; dh = args[8]; } else if (args.length == 3) { dx = args[1]; dy = args[2]; } const cmd = o.apply(ctx, args); // ctx.font = '50px Arial'; // ctx.fillStyle = 'black'; // ctx.fillText('drawImage', dx, dy); return cmd; }); /*** Camera hook ***/ let translateCall = -1; (0,utils.overrideMethod)(ctx, 'translate', function (o, args) { translateCall++; if (translateCall == 2) { self.camera.x = args[0]; self.camera.y = args[1]; self.drawBackground(ctx, world, o); } return o.apply(ctx, args); }); /*** Before render ***/ (_a = Module['preMainLoop']) !== null && _a !== void 0 ? _a : Module['preMainLoop'] = () => {}; (0,utils.overrideMethod)(Module, 'preMainLoop', (o, args) => { this.calls = []; o.apply(this, args); }); /*** After render ***/ (_b = Module['postMainLoop']) !== null && _b !== void 0 ? _b : Module['postMainLoop'] = () => {}; (0,utils.overrideMethod)(Module, 'postMainLoop', (o, args) => { this.sampler.step(); callNumber = -1; translateCall = -1; gotScale = false; this.drawHud(ctx); o.apply(this, args); }); } onRegisterSkin() { // console.log('register skin', arguments); } onMouseX(x) { if (this.state.pause) return window.innerWidth / 2; this.syncMouse(x, undefined); return x; } onMouseY(y) { if (this.state.pause) return window.innerHeight / 2; this.syncMouse(undefined, y); return y; } onCoreInit() { settings.settings.on('AcidMode', v => { window['core'].setAcid(v); })(settings.settings.proxy.AcidMode); } get menuShow() { if (!this.mainui) this.mainui = (0,utils.find_node)(window['agarApp'].home, child => { var _a, _b; return (_b = (_a = child.$vnode) === null || _a === void 0 ? void 0 : _a.tag) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('mainui'); })[0]; if (!this.mainui) return false; return this.mainui.menuShow; } onConnect(url) { console.log('Connected', url); this.state.ws = url; //onconnect if (this.waitForSpawn) { window['MC'].playGame(); this.waitForSpawn = false; } // window['core'].setFadeout(false); // window['core'].setFadeout = () => {}; this.disableMenuBackground(); } disableMenuBackground() { this.emsc._ac_special_on(); window['core'].setFpsCap(-1); window['core'].setFadeout(false); requestAnimationFrame(() => { window['core'].setFadeout(true); }); this.emsc._ac_spectate(); } spetate() { var _a; (_a = (0,utils.find_node)(undefined, child => child === null || child === void 0 ? void 0 : child.spectate)[0]) === null || _a === void 0 ? void 0 : _a.spectate(); } connect(url) { window['core'].disableIntegrityChecks(!url.includes('miniclippt')); if (window['raga'] && url.indexOf('raga') > -1) { window['raga'].isSwitchingGameMode = true; window['raga'].gameMode = 'ragaffa-16x'; } window['core'].connect(url); // window['core'].disconnect() // window['MC'].reconnect(true) } respawn() { if (this.state.play) { this.connect(this.state.ws); this.waitForSpawn = true; } else { window['core'].setFadeout(false); window['core'].sendSpectate(); window['MC'].playGame(); setTimeout(() => { // MC.playGame() // window['agarApp'].home.$children[0].$children[0].spectate() // window['agarApp'].home.$children[0].$children[0].play() // window['agarApp'].home.$children[0].onHideMainMenu() // window['agarApp'].home.$children[0].onGameStart() }, 200); } } onPlayerSpawn(...args) { this.state.play = true; this.reset(); } onPlayerDeath(...args) { (0,utils.find_node)(undefined, child => { if (child.fastEntry !== undefined) return true;else return false; }).forEach(child => { !child.fastEntry && Object.defineProperty(child, 'fastEntry', { get: () => true, set: x => x }); }); window['core'].setFadeout(true); const setInterval = window['_setInterval'] || window.setInterval; const clearInterval = window['_clearInterval'] || window.clearInterval; const setTimeout = window['_setTimeout'] || window.setTimeout; const clearTimeout = window['_clearTimeout'] || window.clearTimeout; this.state.play = false; this.reset(); if (!window['agarApp'].home.$children[0].$children[0].showMenu && settings.settings.proxy.AutoRespawn) { this.respawn(); return true; } else { const prev = this.timer_mp; this.timer_mp = 10000; setTimeout(() => this.timer_mp = prev, 800); } // window.setTimeout(MC.showNickDialog, 500); } onPacket(packet) { return packet; } reset() { this.stopmovement = false; this.world.myCellIds = []; } dumpMem() { const blob = new Blob([this['emsc'].buffer]); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'dump.bin'; a.click(); URL.revokeObjectURL(a.href); } onDisconnect(obj) { console.log('disconnected', obj); } onPlayerZoom(zoom) { this.zoomvalue = zoom; return zoom; } syncCamera(x, y) { this.camera.x = x; this.camera.y = y; } syncMouse(x, y) { if (x !== undefined) this.mouse.x = x - this.world.mapOffsetX; if (y !== undefined) this.mouse.y = y - this.world.mapOffsetY; } renderLoop() {} drawBackground(ctx, world, translate = ctx['translate']) { const offsetX = this.camera.x + this.world.offsetX; const offsetY = this.camera.y + this.world.offsetY; const initialAlpha = ctx.globalAlpha; translate(offsetX, offsetY); /*** Map Border ****/ if (settings.settings.proxy.MapBorder) { ctx.globalAlpha = 0.2; ctx.lineWidth = 20; ctx.fillStyle = 'green'; ctx.strokeRect(this.world.mapMinX, this.world.mapMinY, this.world.mapSizeH, this.world.mapSizeV); ctx.globalAlpha = initialAlpha; } const parselw = this.world.mapSizeH / this.sector; const parselh = this.world.mapSizeV / this.sector; /*** Map Sectors ****/ if (settings.settings.proxy.MapSectors) { ctx.beginPath(); ctx.lineWidth = 10; ctx.strokeStyle = 'green'; ctx.globalAlpha = 0.2; for (let zi = 1; zi < this.sector; zi++) { ctx.moveTo(this.world.mapMinX, this.world.mapMinY + parselw * zi); ctx.lineTo(this.world.mapMaxX, this.world.mapMinY + parselw * zi); ctx.moveTo(this.world.mapMinX + parselh * zi, this.world.mapMinY); ctx.lineTo(this.world.mapMinX + parselh * zi, this.world.mapMaxY); } ctx.stroke(); ctx.closePath(); ctx.globalAlpha = initialAlpha; } /*** Sector Label ****/ if (settings.settings.proxy.MapSectorLabels) { ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.font = parselw / 2.8 + 'px Segoe Print'; ctx.globalAlpha = 0.2; ctx.fillStyle = 'green'; const bucw = parselw / 2, buch = parselh / 2; for (let sat = 0; sat < this.sector; sat++) { const label = String.fromCharCode(65 + sat); for (let sut = 0; sut < this.sector; sut++) { ctx.fillText(label + (sut + 1), this.world.mapMinX + parselw * sut + bucw, this.world.mapMinY + parselh * sat + buch); } } ctx.globalAlpha = initialAlpha; } /*** C3 sign ****/ ctx.textBaseline = 'middle'; ctx.textAlign = 'center'; ctx.font = '380px Segoe Print'; ctx.globalAlpha = 0.5; ctx.fillStyle = '#808080'; ctx.fillText('Delta', 0, 0); ctx.globalAlpha = initialAlpha; translate(-offsetX, -offsetY); // ctx.fillStyle = 'rgba(0, 0, 0, 0.3)'; // ctx.scale(1 / this.zoomvalue, 1 / this.zoomvalue); // ctx.fillRect(0, 0 + ctx.canvas.height / 2 - 150, 200, 100); // ctx.scale(this.zoomvalue, this.zoomvalue); return; /*** Mini Map ****/ if (false) {} } drawHud(ctx) { ctx.fillStyle = 'rgba(0, 0, 0, 0.3)'; ctx.fillRect(0, 0, 0, 0); } } ;// ./js/Lite/Tampermonkey.ts function registerMenuCommands() { const links = [{ name: '\uD83D\uDF02 Adverisement: Play cell games on Delt.io', url: 'https://delt.io' }, { name: '\uD83D\uDDAD Contact: Delta Discord', url: 'https://bit.ly/3RXQXQd' }]; try { links.forEach(link => GM.registerMenuCommand(link.name, () => window.location.href = link.url)); } catch (e) {} } function registerCheckUpdates() { GM.registerMenuCommand(`Version: ${GM.info.script.version} - Check for updates`, checkUpdates); } function checkUpdates() { const url = GM.info.scriptUpdateURL; if (!url) return alert('⛔ Error:\nNo update URL found!'); const version2int = (x = '0') => x.split('.').reduce((n, c, i, a) => n + parseInt(c) * Math.pow(100, a.length - i - 1), 0); const req = new Promise(r => GM.xmlHttpRequest({ method: 'GET', url: url, onload: r })); req.then(res => { const matches = /\/\/\s*@version\s*(\S+)/im.exec(res.responseText); if (!matches) return alert('⛔ Error:\nNo version found!'); const remoteVersion = version2int(matches[1]); const localVersion = version2int(GM.info.script.version); if (remoteVersion > localVersion) { const msg = `🔔 New version available: ${matches[1]}\n\nDo you want to update?`; if (confirm(msg)) { const installer = window.open(url, '_blank'); const i = setInterval(() => { if (!installer.closed) return; clearInterval(i); location.reload(); }, 100); } } else { alert('👍 You are using the latest version!'); } }).catch(e => { console.error(e); alert('⛔ Error: Cant fetch update info!\n' + e); }); } function isGM() { return typeof GM !== 'undefined' && GM; } ;// ./js/Lite/utils/dev.ts function enableVueDevtools() { (0,utils.overrideMethod)(window.Object, 'defineProperty', (originalMethod, args) => { if (args[1] === 'config') { const orig_getter = args[2].get; args[2].get = function () { const vueConfig = orig_getter(); vueConfig.devtools = true; vueConfig.productionTip = true; return () => vueConfig; }; window.Object.defineProperty = originalMethod; } return originalMethod.apply(window.Object, args); }); } function enableFastCanvasView() { Object.defineProperty(window.HTMLCanvasElement.prototype, 'aaa', { get() { this.toBlob(blob => { const blobUrl = URL.createObjectURL(blob); createPopupWin(blobUrl, 'Canvas', 800, 600); }); return 1; } }); } function createPopupWin(pageURL, pageTitle, popupWinWidth, popupWinHeight) { const left = (screen.width - popupWinWidth) / 2; const top = (screen.height - popupWinHeight) / 4; return window.open(pageURL, pageTitle, 'resizable=yes, width=' + popupWinWidth + ', height=' + popupWinHeight + ', top=' + top + ', left=' + left); } ;// ./js/Lite/index.ts /* module decorator */ module = __webpack_require__.hmd(module); enableVueDevtools(); enableFastCanvasView(); const app = new App(); makeGLobal('app', app); makeGLobal('find_node', utils.find_node); if (isGM()) { registerMenuCommands(); registerCheckUpdates(); } if (module === null || module === void 0 ? void 0 : module['hot']) { module['hot'].accept(); // module['hot'].accept('./componetns/liteui', () => { // console.log('Evaulation initLiteui(app);'); // initLiteui(app); // }); module['hot'].addDisposeHandler(function () { console.log('module.hot.addDisposeHandler', ...arguments); }); module['hot'].addStatusHandler(function () { console.log('module.hot.addStatusHandler', ...arguments); }); } /***/ }), /***/ 423: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { settings: () => (/* binding */ settings) }); // EXTERNAL MODULE: ../Shared/src/utils/Eventify.ts var Eventify = __webpack_require__(742); ;// ./js/utils/FontManager.ts // class FontInstance { // constructor(defaultFont = 'normal normal 500 25px Ubuntu') { // this.fontStyle = 'normal'; // this.fontVariant = 'normal'; // this.fontWeight = '500'; // this.fontSize = '25px'; // this.lineHeight = 'normal'; // this.fontFamily = 'Ubuntu'; // this.value = defaultFont; // this.def = this.value; // } // get value() { // const fontSize_lineHeight = this.fontSize + '/' + this.lineHeight; // return `${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${fontSize_lineHeight} ${this.fontFamily}`; // } // set value(cssFontString) { // this.setter(cssFontString); // } // /** // * @param {string} cssFontString // */ // setter(cssFontString) { // FontManager.el.setAttribute('style', 'font: ' + cssFontString); // this.fontStyle = FontManager.el.style.fontStyle; // this.fontVariant = FontManager.el.style.fontVariant; // this.fontWeight = FontManager.el.style.fontWeight; // this.fontSize = FontManager.el.style.fontSize; // this.lineHeight = FontManager.el.style.lineHeight; // this.fontFamily = FontManager.el.style.fontFamily; // } // /*JSON.stringify driver*/ // toJSON() { // return this.value; // } // toString() { // return this.value; // } // toSelectboxFormat() { // return this.fontWeight + ' 25px ' + this.fontFamily; // } // load(text, timeout) { // return new Promise((resolve, reject) => { // const fontFamily = this.fontFamily.replace(/"/g, ''); // if (fontManager.possibleFonts[fontFamily] && fontManager.possibleFonts[fontFamily].isSystemFont) { // return resolve(); // } // // @ts-ignore // new FontFaceObserver(fontFamily.replace(/"/g, ''), { // weight: this.fontWeight // }) // .load(text, timeout) // .then(resolve, reject); // }); // } // } class FontManager { constructor() { this.possibleFonts = { Ubuntu: { fontWeights: { 700: 'bold', 500: '' } }, Roboto: { fontWeights: { 700: 'bold', 500: '' } }, Oswald: { fontWeights: { 700: 'bold', 500: '' } }, // 'Noto Sans': {fontWeights:{'400':'','700':'bold',}}, 'Titillium Web': { fontWeights: { 400: '' } }, 'Exo 2': { fontWeights: { 400: '', 600: 'semi-bold' } }, Play: { fontWeights: { 400: '', 700: 'bold' } }, 'Press Start 2P': { fontWeights: { 500: '' } }, Pacifico: { fontWeights: { 500: '' } }, 'VCR OSD Mono': { fontWeights: { 500: '' } } }; this.h = null; this.d = document.createElement('DIV'); this.s = document.createElement('SPAN'); this.defaultWidth = 0; this.defaultHeight = 0; this.d.appendChild(this.s); this.d.style.fontFamily = 'sans'; this.s.style.fontFamily = 'sans'; this.s.style.fontSize = '72px'; this.s.innerHTML = 'mmmmmmmmmmlil'; document.addEventListener('DOMContentLoaded', () => { this.h = document.getElementsByTagName('BODY')[0]; this.h.appendChild(this.d); this.defaultWidth = this.s.offsetWidth; this.defaultHeight = this.s.offsetHeight; this.h.removeChild(this.d); }); // var a = ["cursive", "monospace", "serif", "sans-serif", "fantasy", "default", "Arial", "Arial Black", "Arial Narrow", "Arial Rounded MT Bold", "Book Antiqua", "Bookman Old Style", "Bradley Hand ITC", "Bodoni MT", "Calibri", "Century", "Century Gothic", "Casual", "Comic Sans MS", "Consolas", "Copperplate Gothic Bold", "Courier", "Courier New", "English Text MT", "Felix Titling", "Futura", "Garamond", "Geneva", "Georgia", "Gentium", "Haettenschweiler", "Helvetica", "Impact", "Jokerman", "King", "Kootenay", "Latha", "Liberation Serif", "Lucida Console", "Lalit", "Lucida Grande", "Magneto", "Mistral", "Modena", "Monotype Corsiva", "MV Boli", "OCR A Extended", "Onyx", "Palatino Linotype", "Papyrus", "Parchment", "Pericles", "Playbill", "Segoe Print", "Shruti", "Tahoma", "TeX", "Times", "Times New Roman", "Trebuchet MS", "Verdana", "Verona","Arial","Arial Black","Verdana","Tahoma","Trebuchet MS","Impact","Times New Roman","Didot","Georgia","American Typewriter","Andalé Mono","Courier","Lucida Console","Monaco","Bradley Hand","Brush Script MT","Luminari","Comic Sans MS","Arial","Arial Black","Bahnschrift","Bahnschrift Condensed","Bahnschrift Light","Bahnschrift Light Condensed","Bahnschrift Light SemiCondensed","Bahnschrift SemiBold","Bahnschrift SemiBold Condensed","Bahnschrift SemiBold SemiConden","Bahnschrift SemiCondensed","Bahnschrift SemiLight","Bahnschrift SemiLight Condensed","Bahnschrift SemiLight SemiConde","Bodoni Bd BT","Bodoni Bk BT","Calibri","Calibri Light","Cambria","Cambria Math","Candara","Candara Light","CentSchbkCyrill BT","Century725 Cn BT","Century751 BT","Century751 No2 BT","Century751 SeBd BT","Clarendon Blk BT","Clarendon BT","Clarendon Lt BT","Comic Sans MS","Consolas","Constantia","Corbel","Corbel Light","Courier New","DeVinne Txt BT","Ebrima","Embassy BT","EngraversGothic BT","Exotc350 Bd BT","Exotc350 DmBd BT","Franklin Gothic Medium","Freehand521 BT","Futura Bk BT","Futura Md BT","Gabriola","Gadugi","Geometr212 BkCn BT","Geometr415 Blk BT","Geometr706 BlkCn BT","Georgia","GeoSlab703 Md BT","GeoSlab703 MdCn BT","HoloLens MDL2 Assets","Humanst521 BT","Humanst521 Lt BT","Humnst777 Blk BT","Humnst777 BlkCn BT","Humnst777 BT","Humnst777 Cn BT","Humnst777 Lt BT","Impact","Ink Free","Javanese Text","Kaufmann BT","Kindly Rewind","Leelawadee UI","Leelawadee UI Semilight","Lucida Console","Lucida Sans Unicode","Malgun Gothic","Malgun Gothic Semilight","Marlett","Microsoft Himalaya","Microsoft JhengHei","Microsoft JhengHei Light","Microsoft JhengHei UI","Microsoft JhengHei UI Light","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Sans Serif","Microsoft Tai Le","Microsoft YaHei","Microsoft YaHei Light","Microsoft YaHei UI","Microsoft YaHei UI Light","Microsoft Yi Baiti","MingLiU-ExtB","MingLiU_HKSCS-ExtB","Mongolian Baiti","MS Gothic","MS PGothic","MS UI Gothic","MV Boli","Myanmar Text","News701 BT","News706 BT","NewsGoth BT","NewsGoth Lt BT","Nirmala UI","Nirmala UI Semilight","Nokia Pure Headline","Nokia Pure Headline Extra Bold","Nokia Pure Headline Light","Nokia Pure Headline Ultra Light","Nokia Pure Symbols","Nokia Pure Text","Nokia Pure Text Light","Nokia Standard Multiscript","NSimSun","OCR-A BT","OCR-B 10 BT","Open Sans","Open Sans Semibold","Palatino Linotype","PMingLiU-ExtB","Schadow BT","Segoe MDL2 Assets","Segoe Print","Segoe Pro","Segoe Pro Black","Segoe Pro Cond","Segoe Pro Display","Segoe Pro Display Light","Segoe Pro Display Semibold","Segoe Pro Display SemiLight","Segoe Pro Light","Segoe Pro Semibold","Segoe Pro SemiLight","Segoe Script","Segoe UI","Segoe UI Black","Segoe UI Emoji","Segoe UI Historic","Segoe UI Light","Segoe UI Semibold","Segoe UI Semilight","Segoe UI Symbol","SimSun","SimSun-ExtB","Sitka Banner","Sitka Display","Sitka Heading","Sitka Small","Sitka Subheading","Sitka Text","Square721 BT","Square721 Cn BT","Swis721 Blk BT","Swis721 BlkCn BT","Swis721 BT","Swis721 Cn BT","Swis721 Hv BT","Swis721 Lt BT","Swis721 LtEx BT","Swis721 WGL4 BT","Sylfaen","Symbol","Tahoma","TeamViewer15","Times New Roman","Trebuchet MS","TypoUpright BT","Ubuntu","Ubuntu Light","VCR OSD Mono [RUS by Daymarius]","Verdana","Webdings","Wingdings","Yu Gothic","Yu Gothic Light","Yu Gothic Medium","Yu Gothic UI","Yu Gothic UI Light","Yu Gothic UI Semibold","Yu Gothic UI Semilight"]; // for (var i = 0; i < a.length; ++i) { // var b = this.test(a[i]); // if (b.found) { // this.possibleFonts[b.name] = {} // this.possibleFonts[b.name].isSystemFont = true // this.possibleFonts[b.name].fontWeights = {'700':'bold','500':''} // } // } } test(fontFamily) { this.h.appendChild(this.d); const b = {}; b.name = this.s.style.fontFamily = fontFamily; b.width = this.s.offsetWidth; b.height = this.s.offsetHeight; this.h.removeChild(this.d); fontFamily = fontFamily.toLowerCase(); if (fontFamily == 'serif') { b.found = true; } else { b.found = b.width != this.defaultWidth || b.height != this.defaultHeight; } return b; } } FontManager.el = document.createElement('span'); const fontManager = new FontManager(); ;// ./js/utils/microColor.ts var _a; class MicroColor { constructor(red = 255, green = 255, blue = 255, alpha = 255) { this.r = red; this.g = green; this.b = blue; this.a = alpha; this.vector = new Float32Array(4); this.bytes = new Uint8Array(4); this.dataview = new DataView(this.bytes.buffer); this.string = '#000000'; this.int = 0; this.inta = 0; this.updVector(); this.updString(); this.updInt(); } updVector() { this.vector[0] = this.r / 255; this.vector[1] = this.g / 255; this.vector[2] = this.b / 255; this.vector[3] = this.a / 255; this.bytes[0] = this.r; this.bytes[1] = this.g; this.bytes[2] = this.b; this.bytes[3] = this.a; this.float = this.dataview.getFloat32(0, true); this.u32 = this.r | this.g << 8 | this.b << 16 | this.a << 24; // for (let i = 0; i < 4; i++) { // this.u32 |= this.bytes[i] << (8 * i); // } } updString() { this.string = this.toRgb(true); } updInt() { this.int = this.getInt(); this.inta = this.getInta(); } cloneFrom(t) { this.r = t.r; this.g = t.g; this.b = t.b; this.a = t.a; this.updVector(); this.updString(); return this; } fromHSL(h, s, l, a = 255) { s /= 100; l /= 100; const c = (1 - Math.abs(2 * l - 1)) * s; const x = c * (1 - Math.abs(h / 60 % 2 - 1)); const m = l - c / 2; let r = 0; let g = 0; let b = 0; if (0 <= h && h < 60) { r = c, g = x, b = 0; } else if (60 <= h && h < 120) { r = x, g = c, b = 0; } else if (120 <= h && h < 180) { r = 0, g = c, b = x; } else if (180 <= h && h < 240) { r = 0, g = x, b = c; } else if (240 <= h && h < 300) { r = x, g = 0, b = c; } else if (300 <= h && h < 360) { r = c, g = 0, b = x; } // Having obtained RGB, convert channels to hex this.r = Math.round((r + m) * 255); this.g = Math.round((g + m) * 255); this.b = Math.round((b + m) * 255); this.a = a; return this; } fromRGB(r, g, b, a = 255) { this.r = r; this.g = g; this.b = b; this.a = a; this.updVector(); this.updString(); return this; } // fromINTA(int: number, alpha = 255) { // const a = (int >> 24) & alpha; // return this.fromINT(color); // } fromINT(int, reorder) { this.a = (4278190080 & int) >>> 24; // 1 старший, слева this.r = (16711680 & int) >>> 16; this.g = (65280 & int) >>> 8; this.b = (255 & int) >>> 0; // 4 старший, слева if (reorder) Object.assign(this, { r: this.a, g: this.r, b: this.g, a: this.b }); this.updVector(); this.updString(); return this; } fromHex(hex) { const len = hex.length; if (!hex || len !== 7 && len !== 9) return this; let i = hex.length === 9 ? 32 : 24; const n = parseInt(hex.slice(1), 16); const r = n >> (i -= 8) & 255; const g = n >> (i -= 8) & 255; const b = n >> (i -= 8) & 255; const a = i ? n >> i - 8 & 255 : 255; return this.fromRGB(r, g, b, a); } get getNormalFromSecure() { return _a.rgbToInt(Math.ceil(this.r / 0.9), Math.ceil(this.g / 0.9), Math.ceil(this.b / 0.9)); } toRgb(useAlpha) { return useAlpha ? `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a / 255})` : `rgb(${this.r}, ${this.g}, ${this.b})`; } getHEXA() { let r = this.r.toString(16); let g = this.g.toString(16); let b = this.b.toString(16); let a = this.a.toString(16); if (r.length == 1) r = '0' + r; if (g.length == 1) g = '0' + g; if (b.length == 1) b = '0' + b; if (a.length == 1) a = '0' + a; return '#' + r + g + b + a; } getFloat() { const bits = this.a << 24 | this.b << 16 | this.g << 8 | this.r; return _a.pack(bits & 0xfeffffff); } getHEX() { return '#' + (16777216 | this.getInt()).toString(16).substring(1); } getInt() { return this.r << 16 | this.g << 8 | this.b; } getIntaShader(alpha) { return this.r | this.g << 8 | this.b << 16 | (alpha < 0 ? this.a : alpha) << 24; } getIntShader() { return this.r | this.g << 8 | this.b << 16; } getInta() { return this.a << 24 | this.r << 16 | this.g << 8 | this.b; } getSecureHex() { return _a.colorIntToHex(_a.rgbToInt(~~(this.r * 0.9), ~~(this.g * 0.9), ~~(this.b * 0.9))); } static rgbToInt(r, g, b) { return r << 16 | g << 8 | b; } static colorIntToHex(int) { let s = int.toString(16); for (; s.length < 6;) { s = '0' + s; } return '#' + s; } static inta2shader(int) { const a = (0xff000000 & int) >>> 24; const r = (0xff0000 & int) >>> 16; const g = (0xff00 & int) >>> 8; const b = (0xff & int) >>> 0; return r | g << 8 | b << 16 | a << 24; } toHEX8() { return `#${(16777216 | this.getInt()).toString(16).substring(1)}${this.a.toString(16).padStart(2, '0')}`; } static pack(i) { _a.int32[0] = i; return _a.float32[0]; } static unpack(f) { _a.float32[0] = f; return _a.int32[0]; } static darkenColor(color, percent) { const num = typeof color == 'string' ? parseInt(color, 16) : color, amt = Math.round(2.55 * percent), R = (num >> 16) + amt, B = (num >> 8 & 0x00ff) + amt, G = (num & 0x0000ff) + amt; return 255 << 24 | R << 16 | G << 8 | B; } static brighten(int, amount = 10) { const a = (4278190080 & int) >>> 24; // 1 старший, слева let r = (16711680 & int) >>> 16; let g = (65280 & int) >>> 8; let b = (255 & int) >>> 0; // 4 старший, слева r = Math.max(0, Math.min(255, r - Math.round(255 * -(amount / 100)))); g = Math.max(0, Math.min(255, g - Math.round(255 * -(amount / 100)))); b = Math.max(0, Math.min(255, b - Math.round(255 * -(amount / 100)))); return a << 24 | r << 16 | g << 8 | b; } static multiplyAlpha(int, alpha) { return ((int >>> 24) * alpha & 0xff) << 24 | int & 0x00ffffff; } } _a = MicroColor; (() => { _a.int8 = new Int8Array(4); _a.int32 = new Int32Array(_a.int8.buffer, 0, 1); _a.float32 = new Float32Array(_a.int8.buffer, 0, 1); })(); MicroColor.temp = new _a(); MicroColor.isValidHex = hex => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex); MicroColor.getChunksFromString = (st, chunkSize) => st.match(new RegExp(`.{${chunkSize}}`, 'g')); MicroColor.convertHexUnitTo256 = hexStr => parseInt(hexStr.repeat(2 / hexStr.length), 16); MicroColor.getAlphafloat = (a, alpha) => { if (typeof a !== 'undefined') { return a / 255; } if (typeof alpha != 'number' || alpha < 0 || alpha > 1) { return 1; } return alpha; }; MicroColor.hexToRGBA = hex => { if (!_a.isValidHex(hex)) { throw new Error('Invalid HEX'); } const chunkSize = Math.floor((hex.length - 1) / 3); const hexArr = _a.getChunksFromString(hex.slice(1), chunkSize); return hexArr.map(_a.convertHexUnitTo256); }; /* harmony default export */ const microColor = (MicroColor); ;// ./js/utils/microColorUtils.ts let canvas; let ctx; function parseColorToInta(input) { if (!canvas) { canvas = document.createElement('canvas'); canvas.width = canvas.height = 1; ctx = canvas.getContext('2d'); } if (!ctx) return 0; ctx.clearRect(0, 0, 1, 1); // обязательно очистить // Попробуем задать цвет try { ctx.fillStyle = input; } catch (_a) { return 0; } ctx.fillRect(0, 0, 1, 1); const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data; return a << 24 | r << 16 | g << 8 | b; } ;// ./js/Settngs.ts // eslint-disable-next-line @typescript-eslint/no-explicit-any class BasicSetting { constructor({ path = 'DEFAULT', name = '' }) { this.exportable = true; this.type = 'NONE'; this._value = null; this.default = null; this.path = path; this.name = name; } get value() { return this._value; } set value(data) { this._value = data; } setter(data) { this.value = data; } get export() { return this.value; } } class Color extends BasicSetting { constructor({ value = '#FF00FFFF', useAlpha = false, useCss = false, path }) { super({ path }); this.microcolor = new microColor(); this.string = '#FFFFFF'; // hex or rgba this.type = 'COL'; this.value = 0; // this.hexa = '#FF00FF66' // 8-Digit hex // this.vector = new Float32Array(4) // this.rgba = new Uint8Array(4) this.alpha = useAlpha; this.default = value; this.useCss = useCss; this.setter(value); } get export() { return this.microcolor.toHEX8(); } toJSON() { return this.export; } setter(string_or_number) { let inta = 0; if (typeof string_or_number === 'string') { if (string_or_number[0] == '#' && (string_or_number.length == 7 || string_or_number.length == 9)) { inta = microColor.temp.fromHex(string_or_number).getInta(); } else { inta = parseColorToInta(string_or_number); } } else { inta = string_or_number; } this.microcolor.fromINT(inta); this.value = inta; this.string = this.alpha ? this.microcolor.fromINT(inta).toRgb(this.alpha) : this.microcolor.fromINT(inta).getHEX(); } } class Select extends BasicSetting { constructor({ name, options = {}, value, path }) { super({ name, path }); this.type = 'SEL'; this.options = options; this.value = value; this.default = value; this.setter(value); } get export() { return this.value; } toJSON() { return this.export; } setter(data) { let isError = true; for (const [, value] of Object.entries(this.options)) { if (value === data) { isError = false; } } if (isError) { console.error('Select: Invalid value ', data, ', fallback to default', this, this.default); this.value = this.default; return; } this.value = data; } } class Slider extends BasicSetting { constructor({ name, min, max, step, value, useCss = false, dim = '', unit = '', path }) { var _a; super({ name, path }); this.type = 'SLD'; this.min = min; this.max = max; this.step = step; this.value = value; this.default = value; this.useCss = useCss; this.dim = dim; this.unit = unit; this.precision = ((_a = step.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.length) || 0; this.setter(value); } get export() { return this.value; } toJSON() { return this.export; } setter(data) { if (typeof data !== 'number' || typeof data == 'undefined') data = this.default; this.value = data; } } class Option extends BasicSetting { constructor({ name, value, path }) { super({ name, path }); this.type = 'OPT'; this.value = value; this.default = value; this.setter(value); } get export() { return this.value; } toJSON() { return this.export; } setter(data) { this.value = data; } } class Input extends BasicSetting { constructor({ name, value, csshook = s => s, path, useCss = false, options = {} }) { super({ name, path }); this.type = 'INP'; this.value = value; this.default = value; this.csshook = csshook; this.useCss = useCss; this.options = options; this.setter(value); } get export() { return this.value; } toJSON() { return this.export; } setter(data) { if (typeof data !== 'string' || typeof data == 'undefined') data = this.default; this.value = String(data); } cssValue() { return this.csshook ? this.csshook(this.value) : this.value; } } class Font extends BasicSetting { constructor({ value = 'normal normal 500 25px Ubuntu', path = '' }) { super({ path }); this.fontStyle = 'normal'; this.fontVariant = 'normal'; this.fontWeight = '500'; this.fontSize = '25px'; this.lineHeight = 'normal'; this.fontFamily = 'Ubuntu'; this.type = 'FONT'; this.default = this.value; this.setter(value); } get value() { const fontSize_lineHeight = this.fontSize + '/' + this.lineHeight; return `${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${fontSize_lineHeight} ${this.fontFamily}`; } set value(cssFontString) { this.setter(cssFontString); } get export() { return this.value; } setter(cssFontString) { var _a; if (typeof cssFontString === 'undefined' || cssFontString === null) cssFontString = this.default; if (typeof cssFontString === 'string' && cssFontString[0] == ' ') cssFontString = this.default; (_a = Font.el) !== null && _a !== void 0 ? _a : Font.el = Font.getElem(); Font.el.style.font = cssFontString; this.fontStyle = Font.el.style.fontStyle; this.fontVariant = Font.el.style.fontVariant; this.fontWeight = Font.el.style.fontWeight; this.fontSize = Font.el.style.fontSize; this.lineHeight = Font.el.style.lineHeight; this.fontFamily = Font.el.style.fontFamily; } toJSON() { return this.export; } toSelectboxFormat() { return this.fontWeight + ' 25px ' + this.fontFamily; } load(text, timeout) { return new Promise((resolve, reject) => { const fontFamily = this.fontFamily.replace(/"/g, ''); if (fontManager.possibleFonts[fontFamily] && fontManager.possibleFonts[fontFamily].isSystemFont) { return resolve(); } const fonts = Array.from(document.fonts).filter(font => font.family === fontFamily && font.weight === this.fontWeight); Promise.all(fonts.map(font => font.load())).then(() => resolve()); // @ts-ignore new FontFaceObserver(fontFamily.replace(/"/g, ''), { weight: this.fontWeight }).load(text, timeout).then(resolve, reject); }); } } Font.getElem = () => { var _a; const el = document.createElement('span'); (_a = document.body) === null || _a === void 0 ? void 0 : _a.appendChild(el); el.style.zIndex = '-9999'; el.style.position = 'absolute'; el.style.top = '-100px'; return el; }; Font.el = null; class Cursor extends Input { constructor({ value = '', cursors = [], path = '' }) { super(arguments[0]); this.type = 'CUR'; this.value = value; this.cursors = cursors; } } class Settings extends Eventify.Eventify { constructor(descriptions) { super(); this.raw = descriptions; const self = this; this.proxy = new Proxy(this.raw, { set: (target, prop, newValue) => { const previous = target[prop].value; self.emit('before*', prop, newValue); // before set target[prop].setter(newValue); try { newValue !== previous && self.emit.call(this, prop, newValue, previous); // on set newValue !== previous && self.emit('*', prop, newValue, previous); // on any } catch (message) { console.error(message); } return true; }, get(target, prop) { return target[prop].value; } }); } import(object) { if (!object) return; for (const option in this.raw) { if (this.raw.hasOwnProperty(option) && object.hasOwnProperty(option)) { this.proxy[option] = object[option]; } } } export() { const export_data = {}; for (const option in this.raw) { export_data[option] = this.raw[option].export; } return export_data; } restore() { for (const opt in this.raw) { const option = opt; if (this.raw.hasOwnProperty(option)) { this.proxy[option] = this.raw[option].default; } } } } ;// ./js/Lite/settings.ts var Group1; (function (Group1) { Group1["s_game"] = "gameplayGroup"; })(Group1 || (Group1 = {})); const settingsDescriptions = { // AnimationDelay: new Slider({ path: Group1.s_game, value: 100, min: 1, max: 300, step: 10, unit: 'x' }), // AutoZoom: new Option({ path: Group1.s_game, value: false }), // Minimap: new Option({ path: Group1.s_game, value: true }), // ZoomOut: new Option({ path: Group1.s_game, value: false }), AutoRespawn: new Option({ path: Group1.s_game, value: false }), AcidMode: new Option({ path: Group1.s_game, value: false }), LeaderboardTitle: new Input({ path: Group1.s_game, value: 'Delta' }), // border: new Color({ path: Group1.s_game, value: 0x1affa3ff }), // sector: new Color({ path: Group1.s_game, value: 0x1affa3ff }), MapBorder: new Option({ path: Group1.s_game, value: true }), MapSectors: new Option({ path: Group1.s_game, value: true }), MapSectorLabels: new Option({ path: Group1.s_game, value: true }) // label: new Color({ path: Group1.s_game, value: 0x1affa3ff }), // miniblob: new Color({ path: Group1.s_game, value: 0x0000ffff }), // transparent_cells: new Slider({ path: Group1.s_game, value: 1, min: 0.1, max: 1, step: 0.1 }) }; const settings = new Settings(settingsDescriptions); /***/ }), /***/ 557: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Fragment: () => (/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.Fragment), /* harmony export */ jsx: () => (/* binding */ u), /* harmony export */ jsxs: () => (/* binding */ u) /* harmony export */ }); /* unused harmony exports jsxAttr, jsxDEV, jsxEscape, jsxTemplate */ /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32); /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(preact__WEBPACK_IMPORTED_MODULE_0__); var t = /["&<]/; function n(r) { if (0 === r.length || !1 === t.test(r)) return r; for (var e = 0, n = 0, o = "", f = ""; n < r.length; n++) { switch (r.charCodeAt(n)) { case 34: f = """; break; case 38: f = "&"; break; case 60: f = "<"; break; default: continue; } n !== e && (o += r.slice(e, n)), o += f, e = n + 1; } return n !== e && (o += r.slice(e, n)), o; } var o = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, f = 0, i = Array.isArray; function u(e, t, n, o, i, u) { t || (t = {}); var a, c, p = t; if ("ref" in p) for (c in p = {}, t) "ref" == c ? a = t[c] : p[c] = t[c]; var l = { type: e, props: p, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f, __i: -1, __u: 0, __source: i, __self: u }; if ("function" == typeof e && (a = e.defaultProps)) for (c in a) void 0 === p[c] && (p[c] = a[c]); return preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode && preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode(l), l; } function a(r) { var t = u(e, { tpl: r, exprs: [].slice.call(arguments, 1) }); return t.key = t.__v, t; } var c = {}, p = /[A-Z]/g; function l(e, t) { if (r.attr) { var f = r.attr(e, t); if ("string" == typeof f) return f; } if ("ref" === e || "key" === e) return ""; if ("style" === e && "object" == typeof t) { var i = ""; for (var u in t) { var a = t[u]; if (null != a && "" !== a) { var l = "-" == u[0] ? u : c[u] || (c[u] = u.replace(p, "-$&").toLowerCase()), s = ";"; "number" != typeof a || l.startsWith("--") || o.test(l) || (s = "px;"), i = i + l + ":" + a + s; } } return e + '="' + i + '"'; } return null == t || !1 === t || "function" == typeof t || "object" == typeof t ? "" : !0 === t ? e : e + '="' + n(t) + '"'; } function s(r) { if (null == r || "boolean" == typeof r || "function" == typeof r) return null; if ("object" == typeof r) { if (void 0 === r.constructor) return r; if (i(r)) { for (var e = 0; e < r.length; e++) r[e] = s(r[e]); return r; } } return n("" + r); } /***/ }), /***/ 621: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ AppContext: () => (/* binding */ AppContext) /* harmony export */ }); /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32); /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(preact__WEBPACK_IMPORTED_MODULE_0__); const AppContext = (0,preact__WEBPACK_IMPORTED_MODULE_0__.createContext)(null); /***/ }), /***/ 632: /***/ ((module) => { "use strict"; module.exports = preactHooks; /***/ }), /***/ 647: /***/ ((module, __webpack_exports__, __webpack_require__) => { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Menu: () => (/* binding */ Menu), MenuButtons: () => (/* binding */ MenuButtons) }); // EXTERNAL MODULE: external "preactHooks" var external_preactHooks_ = __webpack_require__(632); // EXTERNAL MODULE: ./js/Lite/settings.ts + 4 modules var settings = __webpack_require__(423); // EXTERNAL MODULE: ./js/Lite/componetns/Contexts.ts var Contexts = __webpack_require__(621); // EXTERNAL MODULE: ./js/Lite/utils.ts var utils = __webpack_require__(93); // EXTERNAL MODULE: ../Shared/src/utils/Eventify.ts var Eventify = __webpack_require__(742); ;// ./js/utils/minmax.ts function vh(v) { const h = window.innerHeight; //Math.max(window.innerHeight, document.documentElement.clientHeight || 0); return v * h / 100; } function vw(v) { const w = window.innerWidth; //Math.max(window.innerWidth, document.documentElement.clientWidth || 0); return v * w / 100; } function vmin(v) { return Math.min(vh(v), vw(v)); } function vmax(v) { return Math.max(vh(v), vw(v)); } function gcd(a = window.innerWidth, b = window.innerHeight) { return b == 0 ? a : gcd(b, a % b); } ;// ./js/Lite/componetns/hooks.tsx const scaling = (0,Eventify.EventObject)({ uiScale: 1 }); function calcScale() { const gc = gcd(); let sizeOfMap = 1; const { w, h } = { w: 4, h: 3 }; if (gc * window.innerWidth / (gc * window.innerHeight) > w / h) { sizeOfMap = vh(27) / 200; } else { sizeOfMap = h * vw(27) / w / 200; } scaling.uiScale = Math.min(1, sizeOfMap); } window.addEventListener('resize', calcScale); calcScale(); function useEventify(effect, deps) { const eventify = (0,external_preactHooks_.useMemo)(() => new Eventify.Eventify(), []); (0,external_preactHooks_.useEffect)(() => { const destroy = effect(eventify); return () => { if (destroy) destroy(); eventify.unlisten(); }; }, deps); } // EXTERNAL MODULE: ./node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js var jsxRuntime_module = __webpack_require__(557); ;// ./js/Lite/componetns/Inputs.tsx function keepValue(a) { const e = a; if (e.keyCode === 27) { e.target.blur(); e.preventDefault(); } } function UiOption({ target, name }) { const [value, updateValue] = (0,external_preactHooks_.useState)(target.raw[name].value); // @ts-ignore useEventify(e => e.listenTo(target, name, () => updateValue(target.raw[name].value))(), [name]); return (0,jsxRuntime_module.jsx)(UiOptionMarkup // @ts-ignore , { name: (0,utils.camelCaseToWords)(target.raw[name].name || name), value: value, onValue: value => { updateValue(value); target.proxy[name] = value; } }); } function UiOptionMarkup({ name, value, onValue }) { return (0,jsxRuntime_module.jsxs)("label", { className: "flex p-1 text-left gap-2", children: [(0,jsxRuntime_module.jsx)("div", { className: "grow", children: name }), (0,jsxRuntime_module.jsx)("div", { className: "", children: (0,jsxRuntime_module.jsxs)("label", { className: "switch", children: [(0,jsxRuntime_module.jsx)("input", { name: Math.random().toString(), className: "", onChange: e => onValue(e.target['checked']), checked: value, defaultChecked: value, type: "checkbox" }), (0,jsxRuntime_module.jsx)("div", { className: "slider round", "data-on": 'ui_on', "data-off": 'ui_off' })] }) })] }); } function UiSlider({ target, name }) { const helperRef = (0,external_preactHooks_.useRef)(); const unit = target.raw[name].unit || ''; function updateValue(value) { helperRef.current.innerText = String(value.toFixed(target.raw[name].precision)) + unit; } useEventify(e => { // @ts-ignore e.listenTo(target, name, () => updateValue(target.raw[name].value))(); return () => e.unlisten(); }, [name]); return (0,jsxRuntime_module.jsx)(SliderRender // @ts-ignore , { name: (0,utils.camelCaseToWords)(name), value: target.raw[name].value, data: target.raw[name], onValue: value => { target.proxy[name] = value; updateValue(value); }, helperRef: helperRef }); } function SliderRender({ name, value, data, onValue, helperRef }) { const rangeRef = (0,external_preactHooks_.useRef)(); return (0,jsxRuntime_module.jsxs)("label", { class: "flex p-1 text-left gap-2", children: [(0,jsxRuntime_module.jsx)("div", { class: "grow", children: name }), (0,jsxRuntime_module.jsx)("div", { ref: helperRef, class: "helper" }), (0,jsxRuntime_module.jsx)("div", { class: "text-left", children: (0,jsxRuntime_module.jsx)("input", { name: Math.random().toString(), ref: rangeRef, class: "", type: "range", onInput: e => onValue(Number(e.target['value'])), min: data.min, max: data.max, step: data.step, value: value, defaultValue: value.toString() }) })] }); } function UiSelectbox({ target, name }) { const [value, updateValue] = (0,external_preactHooks_.useState)(target.raw[name].value); useEventify(e => { const handleStatusChange = () => updateValue(target.raw[name].value); // @ts-ignore e.listenTo(target, name, handleStatusChange); handleStatusChange(); return () => e.unlisten(); }, [name]); return (0,jsxRuntime_module.jsx)(SelectboxRender, { name: (0,utils.camelCaseToWords)(name.toString()), value: value, data: target.raw[name].options, onValue: value => { // updateValue(value) target.proxy[name] = value; } }); } function SelectboxRender({ name, value, data, onValue }) { return (0,jsxRuntime_module.jsxs)("div", { className: "flex p-1 text-left gap-2", children: [(0,jsxRuntime_module.jsx)("div", { className: "grow", children: name }), (0,jsxRuntime_module.jsx)("div", { className: "", children: (0,jsxRuntime_module.jsx)("select", { name: Math.random().toString(), className: "selectbox", value: value, onChange: e => onValue(isNaN(e.target.value) ? e.target.value : Number(e.target.value)), children: Object.entries(data).map(([name, value]) => (0,jsxRuntime_module.jsx)("option", { value: value, children: (0,utils.camelCaseToWords)(name) })) }) })] }); } function UiInputbox({ target, name }) { var _a; function onValue(value) { // const { target, name } = this.props; target.proxy[name] = value; } const [value, updateValue] = (0,external_preactHooks_.useState)(target.raw[name].value); useEventify(e => { const handleStatusChange = () => updateValue(target.raw[name].value); // @ts-ignore e.listenTo(target, name, handleStatusChange); handleStatusChange(); return () => e.unlisten(); }, [name]); const display_name = (0,utils.camelCaseToWords)(name); return (0,jsxRuntime_module.jsxs)("div", { class: "flex p-1 text-left gap-2", children: [(0,jsxRuntime_module.jsx)("div", { class: "grow", children: display_name }), (0,jsxRuntime_module.jsxs)("div", { class: "flex grow", style: { width: '30%' }, children: [(0,jsxRuntime_module.jsx)("input", { name: Math.random().toString(), class: "input", type: "search", inputMode: "text", autocomplete: "off", style: "width: 100%;", placeholder: name.toString(), onKeyDown: keepValue, onInput: e => onValue(e.target['value']), value: value, defaultValue: value }), true ? (0,jsxRuntime_module.jsxs)("select", { name: 'select-' + Math.random(), class: "w-4", onChange: _e => { const e = _e; e.target.value != undefined && onValue(e.target.value); e.target.value = ''; e.target.blur(); }, style: "", children: [(0,jsxRuntime_module.jsx)("option", { value: "" }), typeof target.raw[name].default !== 'undefined' && (0,jsxRuntime_module.jsx)("option", { value: target.raw[name].default, children: "Default" }), (_a = Object.entries(target.raw[name].options)) === null || _a === void 0 ? void 0 : _a.map(([key, val]) => (0,jsxRuntime_module.jsx)("option", { value: val, children: key }))] }) : 0] })] }); } ;// ./js/Lite/componetns/SettingsList.tsx function SettingsList({ array, target }) { // @ts-ignore const result = array.map(([optName, setting]) => { const type = setting.type; // @ts-ignore if (type == 'OPT') return (0,jsxRuntime_module.jsx)(UiOption, { target: target, name: optName }); // @ts-ignore if (type == 'SLD') return (0,jsxRuntime_module.jsx)(UiSlider, { target: target, name: optName }); // @ts-ignore if (type == 'SEL') return (0,jsxRuntime_module.jsx)(UiSelectbox, { target: target, name: optName }); // @ts-ignore if (type == 'INP') return (0,jsxRuntime_module.jsx)(UiInputbox, { target: target, name: optName }); // @ts-ignore if (type == 'COL') return (0,jsxRuntime_module.jsx)(UiColorbox, { target: target, name: optName }); }); return result; } ;// ./js/Lite/componetns/Menu.tsx /* module decorator */ module = __webpack_require__.hmd(module); var _a; function MenuButtons() { const app = (0,external_preactHooks_.useContext)(Contexts.AppContext); const inputRef = (0,external_preactHooks_.useRef)(); useEventify(e => { e.listenTo(app.state, 'ws', () => { inputRef.current.value = app.state.ws; })(); }, []); return (0,jsxRuntime_module.jsxs)("div", { class: 'menu-addon', style: { marginTop: '4px', display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [(0,jsxRuntime_module.jsx)("button", { style: { width: '242px' }, type: "submit", class: "btn menu-button ", onClick: () => app.spetate(), children: "Spectate" }), (0,jsxRuntime_module.jsxs)("div", { style: { display: 'flex', gap: '4px', paddingTop: '4px' }, children: [(0,jsxRuntime_module.jsx)("input", { class: "input-addon", placeholder: "server", ref: inputRef }), (0,jsxRuntime_module.jsx)("button", { type: "submit", class: "btn menu-button", onClick: () => app.connect(inputRef.current.value), children: "Connect" })] })] }); } const Menu = () => { return (0,jsxRuntime_module.jsx)("div", { style: { overflowY: 'scroll' }, onWheel: e => e.stopPropagation(), children: (0,jsxRuntime_module.jsx)("div", { className: "mx-2", children: (0,jsxRuntime_module.jsx)(SettingsList, { array: Object.entries(settings.settings.raw), target: settings.settings }) }) }); }; (_a = module === null || module === void 0 ? void 0 : module['hot']) === null || _a === void 0 ? void 0 : _a.accept(); /***/ }), /***/ 742: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ EventObject: () => (/* binding */ EventObject), /* harmony export */ Eventify: () => (/* binding */ Eventify), /* harmony export */ deferrify: () => (/* binding */ deferrify) /* harmony export */ }); /* unused harmony exports EventMixin, eventify, Promised, sleep */ // https://stackoverflow.com/questions/50071115/typescript-promise-rejection-type //https://github.com/microsoft/TypeScript/issues/24122 function EventMixin(Base) { class EventifyBase extends Base { /* Stores events */ events = {}; /* Stores delegated events */ // ev: Array<[EventifyBase, EventName<EventMap>, LISTENER]> = []; ev = []; blockRemovingListeners = false; on(...rest) { if (rest.length < 2) throw new Error('Eventify.on() need at least 2 arguments'); const length = rest.length; const listener = rest[length - 1]; for (let i = 0; length - 1 > i; i++) { const event = rest[i]; if (typeof this.events[event] !== 'object') { this.events[event] = []; } this.events[event].push(listener); } return listener; } removeListener(event, listener) { if (typeof this.events[event] === 'object') { const idx = this.events[event].indexOf(listener); if (idx > -1) { this.events[event].splice(idx, 1); } if (this.events[event].length === 0) { delete this.events[event]; } } } emit(event, ...rest) { // this.blockRemovingListeners = true; if (typeof this.events[event] === 'object') { const listeners = this.events[event].slice(); for (const listener of listeners) { listener.apply(this, rest); } } // this.blockRemovingListeners = false; } once(event, listener) { const once_listener = (...args) => { this.removeListener(event, once_listener); listener.apply(this, args); }; this.on(event, once_listener); return once_listener; } waitTimeout(event, timeout, abortController) { const ret = this.waitfor(event, (_, rejector) => { const timeoutId = setTimeout(() => { const error = new Error(`Waiting "${event.toString()}" Timeout`); error.cause = 'timeout'; rejector(error); }, timeout); if (abortController) { function abort() { clearTimeout(timeoutId); const error = new Error(`Waiting "${event.toString()}" Aborted`); error.cause = 'aborted'; rejector(error); } if (abortController.signal.aborted) { abort(); } else { abortController.signal.addEventListener('abort', abort, { once: true }); } } return () => { clearTimeout(timeoutId); }; }); return ret; } waitfor(event, reject_callback) { return new Promise((_resolve, _reject) => { let destroyCallbackCalled = false; const removeListener = () => { this.removeListener(event, resolver); this.removeListener(event, rejector); if (destroyCallbackCalled) return; destroyCallbackCalled = true; destroyRejectCallback(); }; function resolver(v) { _resolve(v); removeListener(); } function rejector(e) { _reject(e); removeListener(); } // @ts-ignore const destroyRejectCallback = reject_callback(resolver, rejector); // eslint-disable-next-line @typescript-eslint/no-explicit-any const self = this; self.listenSelf(event, resolver); self.listenSelf(event, rejector); }); } delegateTo(target, ...rest) { if (arguments.length < 3) throw new Error('Eventify.delegateTo() need at least 3 arguments'); const length = rest.length, listener = rest[length - 1]; for (let i = 0; length - 1 > i; i++) { const event = rest[i]; if (typeof target.events[event] !== 'object') { target.events[event] = []; } const _target = target; target.ev.push({ delegated: this, event: event, listener: listener }); this.on(event, listener); } return listener; } listenTo(target, ...rest) { return target.delegateTo(this, ...rest); } listenSelf(...rest) { return this.listenTo(this, ...rest); } /** * Removes delegated events */ unlisten() { const before = this.ev.slice(); for (let i = 0; before.length > i; i++) { const target = before[i].delegated; const eventName = before[i].event; const listener = before[i].listener; target.removeListener(eventName, listener); const idx = this.ev.indexOf(before[i]); if (idx > -1) this.ev.splice(idx, 1); } if (this.ev.length > 0) { console.error('We have error in unlisten()', before, this.ev); } } } return EventifyBase; } class Eventify extends EventMixin(class {}) {} /* LIB : EVENTIFY ANY OBJECT */ const props = ['on', 'removeListener', 'emit', 'once', 'listenTo', 'delegateTo', 'listenSelf', 'unlisten', 'ev', 'events', 'waitfor', 'waitTimeout']; const eventify = function (object) { const EVENTIFY = new Eventify(); props.forEach(key => { Object.defineProperty(object, key, { value: EVENTIFY[key], enumerable: false, writable: false }); }); return object; }; function EventObject(object) { // = instead extends const _Eventify = eventify(object); const eventObject = new Proxy(object, { set(target, prop, val) { const prev = object[prop]; const curr = val; // @ts-ignore _Eventify.emit('before*', prop, val); //@ts-ignore object[prop] = val; try { // @ts-ignore _Eventify.emit(prop, val, prev); if (prev !== curr) { // @ts-ignore _Eventify.emit('change:*', prop, val); // @ts-ignore _Eventify.emit('change:' + String(prop), val, prev); } // @ts-ignore _Eventify.emit('*', prop, val, prev); } catch (message) { console.error(message); } return true; } }); Object.defineProperty(eventObject, 'raw', { get() { return object; } }); return eventObject; // return eventObject as EventObjectReturnType<OBJ>; } function deferrify(params) { let resolve = null; let reject = null; const promise = new Promise((resolveFunc, rejectFunc) => { resolve = resolveFunc; reject = rejectFunc; if (params?.signal instanceof Promise) { params.signal.catch(reject); } else if (params?.signal?.aborted) { reject(); } }); return { promise, resolve, reject }; } class Promised extends Promise { constructor(executor) { super((resolve, reject) => { this.resolve = resolve; this.reject = reject; // @ts-ignore if (executor !== undefined) executor(resolve, reject); }); } } const sleep = delay => function chainDelay(args) { return new Promise(res => { setTimeout(() => res(args), delay); }); }; // const e1 = new Eventify<{ lol: () => void; kek: (arg: string) => void }>(); // const e2 = new Eventify(); // const eo = EventObject({ // hello: 'world', // world: 'hello' // }); // eo.on('hello', 'change:world', (curr, prev) => {}); // eo.listenTo(e1, 'kek', 'lol', (curr, prev) => {}); // e1.emit('kek', '12'); // // e1.listenTo(eo // const listenable = { // foo: 'bar', // bar: 'foo' // }; // eo.listenTo(e1, 'kek', () => {}); // const list = e1.listenTo(e2, 'asd', '*', (curr, prev) => '123'); // e1.listenTo(eo, 'hello', () => {}); // eo.delegateTo(e1, 'hello', 'world', (curr, prev) => { // return 1; // }); // list(); // e1.on('sex', 'loveы', () => 123); // eo.on('world', 'change:hello', () => {}); // eo['world'] = 'world'; // e2.listenTo(e1, 'kek', 'lol', () => {}); /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ id: moduleId, /******/ loaded: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ /******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = (module) => { /******/ var getter = module && module.__esModule ? /******/ () => (module['default']) : /******/ () => (module); /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/harmony module decorator */ /******/ (() => { /******/ __webpack_require__.hmd = (module) => { /******/ module = Object.create(module); /******/ if (!module.children) module.children = []; /******/ Object.defineProperty(module, 'exports', { /******/ enumerable: true, /******/ set: () => { /******/ throw new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id); /******/ } /******/ }); /******/ return module; /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /************************************************************************/ /******/ /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined /******/ var __webpack_exports__ = __webpack_require__(314); /******/ MyLibrary = __webpack_exports__; /******/ })(typeof unsafeWindow !== 'undefined' ? unsafeWindow : window);