MediaWiki:Vector.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 47: | Line 47: | ||
p.style.fontStyle = "italic"; | p.style.fontStyle = "italic"; | ||
p.style.color = "var(--fg-dark)"; | p.style.color = "var(--fg-dark)"; | ||
if (mw.config.values.wgUserId == 1) { | p.innerText = "Ad placeholder"; | ||
// if (mw.config.values.wgUserId == 1) { | |||
// p.innerText = "Ad block user? No problem. If you want,\n" + | |||
// "you can log in to hide this ad placeholder."; | |||
// } | |||
ad.appendChild(p); | ad.appendChild(p); | ||
} | } | ||
Line 81: | Line 82: | ||
p.style.fontStyle = "italic"; | p.style.fontStyle = "italic"; | ||
p.style.color = "var(--fg-dark)"; | p.style.color = "var(--fg-dark)"; | ||
// if (mw.config.values.wgUserId == 1) { | |||
// p.innerText = "Ad block user?\nNo problem.\n\n" + | |||
// "If you want, you can log in to hide this ad placeholder."; | |||
// ad.innerHTML = ""; | |||
// ad.appendChild(p); | |||
// } | |||
} | } |
Revision as of 14:38, 7 August 2024
/* All JavaScript here will be loaded for users of the Vector skin */
/*
* Note that some of the CSS added when enabling ads is already applied via
* MW:Vector.css, but it's undone in MW:Group-user.css for logged-in users.
*
* So do it again when ads are enabled explicitly, e.g. for testing.
*/
if (mw.config.values.wgUserId == null || mw.config.values.wgUserId == 1) {
bg3wikiEnableAds();
}
function bg3wikiEnableAds () {
bg3wikiEnableSiteNoticeAd();
bg3wikiEnableSidebarAd();
}
function bg3wikiEnableSiteNoticeAd() {
var siteNotice = document.getElementById("siteNotice");
if (siteNotice == null) {
return;
}
var h1 = document.getElementById("firstHeading");
h1.style.maxWidth = "calc(100% - 468px - 16px)";
var indicators = document.getElementsByClassName("mw-indicators")[0];
indicators.style.marginRight = "16px";
var ad = document.createElement("div");
ad.id = "bg3wiki-sitenotice-ad";
ad.classList.add("bg3wiki-ad");
ad.style.width = "468px";
ad.style.height = "60px";
ad.style.float = "right";
ad.style.marginTop = "-17px";
ad.style.border = "2px dotted var(--bdr-color)";
ad.style.boxSizing = "border-box";
ad.style.alignContent = "center";
siteNotice.appendChild(ad);
var p = document.createElement("p");
p.style.textAlign = "center";
p.style.lineHeight = "1.5em";
p.style.fontSize = "1.1em";
p.style.fontStyle = "italic";
p.style.color = "var(--fg-dark)";
p.innerText = "Ad placeholder";
// if (mw.config.values.wgUserId == 1) {
// p.innerText = "Ad block user? No problem. If you want,\n" +
// "you can log in to hide this ad placeholder.";
// }
ad.appendChild(p);
}
function bg3wikiEnableSidebarAd() {
var ad = document.querySelector("#p-Advertisement > div");
if (ad == null) {
return;
}
ad.style.width = "160px";
ad.style.height = "600px";
ad.style.marginTop = "5px";
ad.style.border = "2px dotted var(--bdr-color)";
ad.style.boxSizing = "border-box";
ad.style.paddingLeft = "10px";
ad.style.paddingRight = "10px";
ad.style.alignContent = "center";
var sidebarSpecial = document.getElementById("p-Special");
sidebarSpecial.style.display = "none";
var sidebarToolbox = document.getElementById("p-tb");
sidebarToolbox.style.display = "none";
var p = document.createElement("p");
p.style.textAlign = "center";
p.style.lineHeight = "1.5em";
p.style.fontSize = "0.9em";
p.style.fontStyle = "italic";
p.style.color = "var(--fg-dark)";
// if (mw.config.values.wgUserId == 1) {
// p.innerText = "Ad block user?\nNo problem.\n\n" +
// "If you want, you can log in to hide this ad placeholder.";
// ad.innerHTML = "";
// ad.appendChild(p);
// }
}