// Single theme URL for fastest replacement const BANNER_URL = "https://ik.imagekit.io/hxvezoqrx/IMG_6394.png?updatedAt=1744534591325";
// Cache elements to prevent DOM queries after first replacement let cachedBackdrop = null; let cachedThirdImage = null;
// Main replacement function function replaceBanner() { // Replace backdrop-asset if available if (!cachedBackdrop) { cachedBackdrop = document.getElementById("backdrop-asset"); } if (cachedBackdrop) { cachedBackdrop.src = BANNER_URL; }
// Replace third image if available if (!cachedThirdImage && document.images.length >= 3) { cachedThirdImage = document.images[2]; } if (cachedThirdImage) { cachedThirdImage.src = BANNER_URL; } }
// Create observer for dynamic element detection const observer = new MutationObserver((mutations) => { for (const mutation of mutations) { if (mutation.type === "childList") { replaceBanner(); break; } } });
// Start observing as soon as possible if (document.documentElement) { observer.observe(document.documentElement, { childList: true, subtree: true }); }
// ==UserScript==
// @name Diep.io Banner Overwrite
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Replace banner on diep.io immediately when elements appear
// @author ?
// @match *://diep.io/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
"use strict";
// Single theme URL for fastest replacement
const BANNER_URL = "https://ik.imagekit.io/hxvezoqrx/IMG_6394.png?updatedAt=1744534591325";
// Cache elements to prevent DOM queries after first replacement
let cachedBackdrop = null;
let cachedThirdImage = null;
// Main replacement function
function replaceBanner() {
// Replace backdrop-asset if available
if (!cachedBackdrop) {
cachedBackdrop = document.getElementById("backdrop-asset");
}
if (cachedBackdrop) {
cachedBackdrop.src = BANNER_URL;
}
// Replace third image if available
if (!cachedThirdImage && document.images.length >= 3) {
cachedThirdImage = document.images[2];
}
if (cachedThirdImage) {
cachedThirdImage.src = BANNER_URL;
}
}
// Create observer for dynamic element detection
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.type === "childList") {
replaceBanner();
break;
}
}
});
// Start observing as soon as possible
if (document.documentElement) {
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
}
// Initial replacement attempt
document.addEventListener("readystatechange", () => {
if (document.readyState === "interactive") {
replaceBanner();
}
});
})();
This one will fix the flicker when loading the page