MediaWiki:Vector.js: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(34 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Vector skin */
/* All JavaScript here will be loaded for users of the Vector skin */
if (document.readyState === 'complete') {
bg3wikiVectorJsMain();
} else {
window.addEventListener('load', bg3wikiVectorJsMain);
}
function bg3wikiVectorJsMain() {
var reportAdsLink = document.querySelector('#n-Please-report-bad-ads a');
if (reportAdsLink) {
reportAdsLink.setAttribute("target", "_blank");
}
}


/*
/*
* Note that some of the style changes that are applied when enabling ads are
function bg3wikiCheckAdBlock() {
* already applied via MW:Vector.css, but only for anonymous visitors, so apply
var adsEnabled = document.body.classList.contains("mw-ads-enabled");
* them again in case ads are enabled explicitly, e.g. for testing.
if (adsEnabled && !window.fusetag && !window.ramp) {
*/
bg3wikiAdBlockProbable();
 
}
if (mw.config.get("wgUserId") == null) {
bg3wikiEnableAds();
}
}


function bg3wikiEnableAds () {
function bg3wikiAdBlockProbable() {
bg3wikiEnableSiteNoticeAd();
bg3wikiCleanupHeaderAd();
bg3wikiEnableSidebarAd();
bg3wikiCleanupSidebarAd();
}
}


function bg3wikiEnableSiteNoticeAd() {
function bg3wikiCleanupHeaderAd() {
var ad = document.getElementById("bg3wiki-sitenotice-ad");
var headerAd = document.getElementById("bg3wiki-header-ad");
if (ad == null) {
if (!headerAd) {
return;
return;
}
}
var p = headerAd.querySelector("p");
ad.style.display = "block";
p.style.fontSize = '1em';
p.innerText = "Ad block user? No problem.\n" +
var h1 = document.getElementById("firstHeading");
"You can log in to clean up the UI of placeholders like this.";
h1.style.maxWidth = "calc(100% - 468px - 16px)";
var indicators = document.getElementsByClassName("mw-indicators")[0];
indicators.style.marginRight = "16px";
}
}


function bg3wikiEnableSidebarAd() {
function bg3wikiCleanupSidebarAd() {
var ad = document.querySelector("#p-Advertisement > div");
var headerAd = document.getElementById("bg3wiki-sidebar-ad");
if (ad == null) {
if (!headerAd) {
return;
return;
}
}
var p = headerAd.querySelector("p");
ad.style.width = "160px";
p.style.fontSize = '0.7em';
ad.style.height = "600px";
p.innerText = "Ad block user? No problem.\n" +
ad.style.marginTop = "5px";
"You can log in to clean up the UI of placeholders like this.";
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)";
// 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);
}
}
*/

Latest revision as of 20:27, 18 September 2024

/* All JavaScript here will be loaded for users of the Vector skin */

if (document.readyState === 'complete') {
	bg3wikiVectorJsMain();
} else {
	window.addEventListener('load', bg3wikiVectorJsMain);
}

function bg3wikiVectorJsMain() {
	var reportAdsLink = document.querySelector('#n-Please-report-bad-ads a');
	if (reportAdsLink) {
		reportAdsLink.setAttribute("target", "_blank");
	}
}

/*
function bg3wikiCheckAdBlock() {
	var adsEnabled = document.body.classList.contains("mw-ads-enabled");
	if (adsEnabled && !window.fusetag && !window.ramp) {
		bg3wikiAdBlockProbable();
	}
}

function bg3wikiAdBlockProbable() {
	bg3wikiCleanupHeaderAd();
	bg3wikiCleanupSidebarAd();
}

function bg3wikiCleanupHeaderAd() {
	var headerAd = document.getElementById("bg3wiki-header-ad");
	if (!headerAd) {
		return;
	}
	var p = headerAd.querySelector("p");
	p.style.fontSize = '1em';
	p.innerText = "Ad block user? No problem.\n" +
		"You can log in to clean up the UI of placeholders like this.";
}

function bg3wikiCleanupSidebarAd() {
	var headerAd = document.getElementById("bg3wiki-sidebar-ad");
	if (!headerAd) {
		return;
	}
	var p = headerAd.querySelector("p");
	p.style.fontSize = '0.7em';
	p.innerText = "Ad block user? No problem.\n" +
		"You can log in to clean up the UI of placeholders like this.";
}
*/