MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
})(); | })(); | ||
document.addEventListener("DOMContentLoaded", function () { | document.addEventListener("DOMContentLoaded", function () { | ||
// Disable right-click on all images | |||
document.addEventListener("contextmenu", function (event) { | document.addEventListener("contextmenu", function (event) { | ||
if (event.target.tagName === "IMG") { | if (event.target.tagName === "IMG") { | ||
Line 22: | Line 21: | ||
} | } | ||
}); | }); | ||
/ | // Disable clicking on image links for anonymous users | ||
if (mw.config.get('wgUserGroups').includes('anon')) { | if (mw.config.get('wgUserGroups').includes('anon')) { | ||
document.querySelectorAll('a > img').forEach(function(img) { | document.querySelectorAll('a > img').forEach(function(img) { |
Revision as of 16:30, 7 August 2025
// Google Analytics 4 tracking via MediaWiki:Common.js
(function() {
var gaScript = document.createElement('script');
gaScript.async = true;
gaScript.src = 'https://www.googletagmanager.com/gtag/js?id=G-01G5LMDW7X';
document.head.appendChild(gaScript);
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
window.gtag = gtag;
gtag('js', new Date());
gtag('config', 'G-01G5LMDW7X');
})();
document.addEventListener("DOMContentLoaded", function () {
// Disable right-click on all images
document.addEventListener("contextmenu", function (event) {
if (event.target.tagName === "IMG") {
event.preventDefault();
}
});
// Disable clicking on image links for anonymous users
if (mw.config.get('wgUserGroups').includes('anon')) {
document.querySelectorAll('a > img').forEach(function(img) {
let link = img.parentElement;
if (link && link.tagName === 'A') {
link.addEventListener('click', function(event) {
event.preventDefault();
});
link.style.cursor = 'default';
}
});
}
});
By using this site, you agree to the Terms of Use. © 1996–2025 The Quincy Examiner / MTB. All rights reserved.