User:CannonProductions/monacobookbeta.js: Difference between revisions
From MediaWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
document. | var d = document.createElement("div"); | ||
d.id = "js-test-badge"; | |||
d.textContent = "User JS RUNNING"; | |||
); | d.style.cssText = "position:fixed;top:0;left:0;z-index:999999;padding:6px 10px;background:#e11;color:#fff;font:12px sans-serif"; | ||
document.body.prepend(d); | |||
(() => { | (() => { | ||
Revision as of 11:29, 30 December 2025
var d = document.createElement("div");
d.id = "js-test-badge";
d.textContent = "User JS RUNNING";
d.style.cssText = "position:fixed;top:0;left:0;z-index:999999;padding:6px 10px;background:#e11;color:#fff;font:12px sans-serif";
document.body.prepend(d);
(() => {
const BASE_W = 468;
const BASE_H = 60;
function rescaleBanner() {
const ad = document.getElementById("top-ad");
if (!ad) return;
const iframe = ad.querySelector("iframe");
if (!iframe) return;
const available = ad.getBoundingClientRect().width || window.innerWidth;
let scale = available / BASE_W;
if (scale > 1) scale = 1; // don’t upscale past 100%
if (scale < 0.5) scale = 0.5; // safety floor for tiny widths
document.documentElement.style.setProperty("--tfwiki-banner-scale", scale.toFixed(4));
// Make layout height match the scaled visual height
ad.style.height = (BASE_H * scale) + "px";
}
// Run now + on resize (debounced)
let t;
function onResize() {
clearTimeout(t);
t = setTimeout(rescaleBanner, 50);
}
window.addEventListener("load", rescaleBanner, { once: true });
window.addEventListener("resize", onResize);
window.addEventListener("orientationchange", onResize);
rescaleBanner();
})();

