User:CannonProductions/monacobookbeta.js: Difference between revisions
From MediaWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
/* | /* User:CannonProductions/monacobookbeta.js | ||
- Dynamically scales #top-ad iframe banner to fit available width on mobile | |||
- Locks background scroll when the sidebar (#column-one) is open on mobile | |||
- Adds html.tf-nav-open while the sidebar is open (for CSS styling) | |||
- Removes the redundant mobile logo portlet (#p-m-logo) so it doesn’t waste space | |||
*/ | |||
(function () { | |||
"use strict"; | |||
/ | // === SETTINGS === | ||
var DEBUG_BADGE = false; | |||
var MOBILE_MAX_WIDTH = 720; | |||
// Banner creative’s native size | |||
var BASE_W = 468; | |||
var BASE_H = 60; | |||
/ | // Banner scale limits | ||
var MIN_SCALE = 0.55; | |||
var MAX_SCALE = 1.0; | |||
function onReady(fn) { | |||
if (document.readyState === "loading") { | |||
document.addEventListener("DOMContentLoaded", fn); | |||
} else { | |||
fn(); | |||
} | |||
} | } | ||
function addBadge() { | |||
if (!DEBUG_BADGE) return; | |||
if (!document.body) return; | |||
if (document.getElementById("js-test-badge")) return; | |||
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); | |||
} | } | ||
function isMobileWidth() { | |||
return window.matchMedia("(max-width: " + MOBILE_MAX_WIDTH + "px)").matches; | |||
} | } | ||
/ | // ===== Remove the redundant mobile logo portlet ===== | ||
function removeMobileLogoPortlet() { | |||
var p = document.getElementById("p-m-l | |||
Revision as of 13:01, 30 December 2025
/* User:CannonProductions/monacobookbeta.js
- Dynamically scales #top-ad iframe banner to fit available width on mobile
- Locks background scroll when the sidebar (#column-one) is open on mobile
- Adds html.tf-nav-open while the sidebar is open (for CSS styling)
- Removes the redundant mobile logo portlet (#p-m-logo) so it doesn’t waste space
*/
(function () {
"use strict";
// === SETTINGS ===
var DEBUG_BADGE = false;
var MOBILE_MAX_WIDTH = 720;
// Banner creative’s native size
var BASE_W = 468;
var BASE_H = 60;
// Banner scale limits
var MIN_SCALE = 0.55;
var MAX_SCALE = 1.0;
function onReady(fn) {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", fn);
} else {
fn();
}
}
function addBadge() {
if (!DEBUG_BADGE) return;
if (!document.body) return;
if (document.getElementById("js-test-badge")) return;
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);
}
function isMobileWidth() {
return window.matchMedia("(max-width: " + MOBILE_MAX_WIDTH + "px)").matches;
}
// ===== Remove the redundant mobile logo portlet =====
function removeMobileLogoPortlet() {
var p = document.getElementById("p-m-l

