'Delta - 999999 in 1

Delta - extension for agario, agar.io mod collection. Zoom+, macro eject mass, double split, hot-keys, minimap, chat, helpers, themes

// ==UserScript==
// @name         'Delta - 999999 in 1
// @name:ru      'Delta - 999999 в 1
// @description         Delta - extension for agario, agar.io mod collection. Zoom+, macro eject mass, double split, hot-keys, minimap, chat, helpers, themes
// @description:es      Delta - extensión para agario, colección de mods agar.io. Zoom+, masa de expulsión de macro, doble división, teclas de acceso rápido, minimapa, chat, ayudas, temas
// @description:ru      Delta - расширение для агарио, сборник модов для agar.io. Зум, авто-ц, дабл-сплит, горячие клавиши, мини-карта, чат, подсказки, темы
// @description:zh      Delta - agario 的擴展,agar.io mod 集合。縮放+、巨集彈出品質、雙分割、熱鍵、小地圖、聊天、助理、主題
// @description:uk      Delta - розширення для agario, колекція модів agar.io. Zoom+, макро викидна маса, подвійний поділ, гарячі клавіші, міні-карта, чат, помічники, теми
// @description:tr      Delta - agario, agar.io mod koleksiyonu için uzantı. Zoom+, makro çıkarma kütlesi, çift bölme, kısayol tuşları, mini harita, sohbet, yardımcılar, temalar
// @description:de      Delta – Erweiterung für Agario, agar.io Mod-Sammlung. Zoom+, Makro-Auswurfmasse, Doppelsplit, Hotkeys, Minikarte, Chat, Helfer, Themen
// @description:ja      Delta - agario の拡張機能、agar.io mod コレクション。 Zoom+、マクロイジェクトマス、ダブルスプリット、ホットキー、ミニマップ、チャット、ヘルパー、テーマ
// @description:pl      Delta - rozszerzenie do kolekcji modów agario, agar.io. Zoom+, masa wyrzucania makro, podwójny podział, klawisze skrótu, minimapa, czat, pomocnicy, motywy
// @description:fr      Delta - extension para sa agario, agar.io mod collection. Zoom+, macro eject mass, double split, hot-keys, minimap, chat, mga katulong, mga tema
// @version      7.5
// @namespace    delta.agar
// @author       neo
// @icon         https://deltav4.gitlab.io/ext/assets/favicon.ico
// @match        *://*.agar.io/*
// @match        *://*.sigmally.com/*
// @match        *://*.gota.io/*
// @run-at       document-start
// @grant        GM.xmlHttpRequest
// @grant        GM.registerMenuCommand
// @grant        window.close
// @grant        unsafeWindow
// @license      Proprietary
// ==/UserScript==

/*
  GREASYFORK VERSION

  Sorry, Delta is no longer available for GreasyFork users.
  Delta will be available again after all GreasyFork rules are met.
  Right now there is a lite version of Delta

  If this user script does not start, write me a discord
  Если данное расширение не запускается, напишите мне в дискорд
  https://discord.gg/HHmyKW6

*/

function sorry() {
    alert('Sorry, this extension is not available in this user-script');
}

try {
    GM.registerMenuCommand('\uD83D\uDF02\u2077 Delta 7', function () {
        window.location.href = 'https://delt.io/';
    });
    GM.registerMenuCommand('\ud83d\uddf8 Stock Agar.io', function () {
        window.location.href = 'https://agar.io/noext';
    });
    GM.registerMenuCommand('\ud83d\udd17 Visit our website', function () {
        window.location.href = 'https://deltav4.glitch.me/';
    });
    GM.registerMenuCommand('\uD83D\uDDAD Delta Discord', function () {
        window.location.href = 'https://bit.ly/3RXQXQd';
    });
} catch (e) {}

if (window.document && window.document.title === 'Attention Required! | Cloudflare') {
    if (!/you have been blocked/.test(window.document.body.innerHTML)) {
        return;
    }
}

const host2path = {
    'sigmally': '/terms.html',
    '': '/delta',
}

if (window.location.pathname === '/') {
    window.stop()
    for(const [host, path] of Object.entries(host2path)) {
        if(window.location.host.includes(host)) return window.location.href = path;
    }
}

for(const [, path] of Object.entries(host2path)) {
    if(window.location.pathname.includes(path)) {
        window.history && window.history.replaceState && window.history.replaceState({}, window.document.title, '/');
        break
    }
}

var defaultMode = 'default';

var modes = {
    default: function () {
        /**
         * Vue selector
         * example: find_node(window['agarApp'].home, (child, depth) => { if(child.$vnode?.tag?.toLowerCase().includes('home')) return true })
         * @param {*} where window.agarApp.home
         * @param {(child: any, depth: number) => any} cond 
         * @returns {any[]}
         */
        const find_node = (where = unsafeWindow['agarApp'].home, cond) => {
            const results = []

            const find_static = (where = unsafeWindow['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){
                depth += 1
                if(cond(child, depth)) results.push(child)
                child._staticTrees && find_static(child._staticTrees, cond)
                // console.log(depth, 'TAG:', child, child.$vnode?.tag)
                child.$children?.forEach((ch) => {
                    each_children(ch, depth)
                })
                child.children?.forEach((ch) => {
                    each_children(ch, depth)
                })
                child._vnode?.children?.forEach((ch) => {
                    each_children(ch, depth)
                })
                child._vnode?.componentOptions?.children?.forEach((ch) => {
                    each_children(ch, depth)
                })
            }
            each_children(where, -1)
            return results
        }

        function init() {
            // Ads delete
            find_node(undefined, (child, depth) => { if (child.$vnode?.tag.includes('-ads')) return true })[0]?.$destroy()
            find_node(undefined, (child, depth) => { if (child.$vnode?.tag.includes('-promo')) return true })[0]?.$destroy()
            find_node(undefined, (child, depth) => {
                return child.elm?.id?.includes('agar-io')
            }).forEach(child => {
                child.elm.parentElement?.removeChild(child.elm)
            })

            find_node(undefined, (child, depth) => child.playVideoAd)
                .forEach(elem => {
                    elem.getVideoTimestamp = () => Date.now()
                })

            {
                const vnode = find_node(undefined, (child, depth) => Object.getPrototypeOf(child).hasOwnProperty('hasBottomAd'))?.[0]
                if (vnode) {
                    Object.defineProperties(vnode, {
                        fastEntry: { get: () => true },
                    });
                }
            }

            // Youtube, FB buttons
            {
                const vnode = find_node(undefined, (child, depth) => { if (child?.elm?.id == 'socialButtons') return true })[0]
                if (vnode) {
                    vnode.elm.parentElement.removeChild(vnode.elm)
                }
            }

            // Skin floating badge
            {
                const bubble = find_node(undefined, (child, depth) => child.data?.staticClass?.includes('bubble'))[0]
                bubble?.elm?.parentElement.removeChild(bubble?.elm)
            }

            unsafeWindow['agarApp'].ads = {
                requestAds() { },
                requestAd() { },
                refreshAd() { },
                destroyAd() { },
                adSlots() { },
                enableTargetedAds() { },
                disableTargetedAds() { },
                isTargeted() { },
                supersonicAds: {
                    BrandConnectReadyEvent() { },
                    BrandConnectDoneEvent() { },
                    BrandConnectOpenEvent() { },
                    BrandConnectCloseEvent() { },
                    BrandConnectCompletedEvent() { },
                    hasEngagement() { return false }
                },
            }

        }

        addEventListener("core_init_complete", () => {
            try{
				init()
            }catch(e){
                console.error(e)
            }
		})
        
    }
};


var matched = modes[defaultMode]
for (var mode in modes) {
    var isMatched = window.location.pathname.toLowerCase().indexOf(mode) > -1;
    if (isMatched) {
        matched = modes[mode];
        break;
    }
}

if(document && document.documentElement) {
    const style = '<style>html{font: 1.2em "Fira Sans", sans-serif;color:white;background: radial-gradient(circle at bottom right,#36003e, #000000 27%); height: 100%;}</style>'
    document.documentElement.innerHTML = style +
        'Extension is loading....<br>'+
        'Sorry, Delta is no longer available on GreasyFork users. Delta will be available again after all GreasyFork rules are met.<br>'+
        'Right now there is a lite version of Delta.'

}

loader();

function loader() {
    setTimeout(function() {
        GM.xmlHttpRequest({
            method: 'GET',
            url: window.location.pathname,
            onload: async function (e) {
                var blob = new Blob(['\ufeff' + e.responseText], { type: 'text/html;charset=windows-1252' });
                var reader = new FileReader();
                reader.onload = function () {
                    document.open();
                    document.write(reader.result);
                    document.close();
                    matched();
                };
                reader.readAsText(blob);
            }
        });
    }, 1500)
    
}