Spiderjjr45 (talk | contribs) No edit summary Tag: Reverted |
Spiderjjr45 (talk | contribs) No edit summary Tags: Manual revert Reverted |
||
| Line 44: | Line 44: | ||
//Images can be renamed to have "-ai-" anywhere in their name and automatically get a watermark |
//Images can be renamed to have "-ai-" anywhere in their name and automatically get a watermark |
||
$(document).ready(function() { |
$(document).ready(function() { |
||
// |
// Loop through all img tags |
||
var watermarkURL = 'https://quelmarwiki.com/wiki/images/b/b8/Aiwatermark.png'; |
|||
// Loop through images on the page |
|||
$('img').each(function() { |
$('img').each(function() { |
||
var img = $(this); // Reference to the current img tag in the loop |
var img = $(this); // Reference to the current img tag in the loop |
||
var src = img.attr('src'); // Get the src attribute |
var src = img.attr('src'); // Get the src attribute |
||
// Check if image name contains '-ai' |
|||
if |
// Check if src contains '-ai' and doesn't already have 'watermarked' class |
||
if (src.includes('-ai') && !img.hasClass('watermarked')) { |
|||
// Create a div to contain the image and its watermark |
|||
img.addClass('watermarked'); // Add the 'watermarked' class |
|||
'position': 'relative', |
|||
'display': 'inline-block', |
|||
'overflow': 'hidden', |
|||
'width': img.width(), |
|||
'height': img.height() |
|||
}); |
|||
//Generate the watermark |
|||
var watermark = $('<img>').attr('src', watermarkURL).css({ |
|||
'position': 'absolute', |
|||
'bottom': '0', |
|||
'right': '0', |
|||
'max-width': '30%', // Adjust size if needed |
|||
'max-height': '30%', // Adjust size if needed |
|||
'pointer-events': 'none', // Ensure it doesn't interfere with any interactions |
|||
'opacity': '0.5' // Adjust opacity if needed |
|||
}); |
|||
// Insert the container before the original image, then move the original image and watermark inside the container |
|||
img.before(container).appendTo(container); |
|||
container.append(watermark); |
|||
} |
} |
||
}); |
}); |
||
Revision as of 20:25, 16 October 2023
/**
* Adds CSS classes to the body tag based on the categories this page belongs to. Used for CR/Astral page theming.
*
* @source https://www.mediawiki.org/wiki/Snippets/Style_pages_based_on_categories
* @revision 2016-01-18
*/
(function($, mw) {
var fn = function() {
var cats = mw.config.get('wgCategories'), newClasses;
if (cats) {
newClasses = $.map(cats, function(el) {
return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
}).join(' ');
$(document.body).addClass(newClasses);
}
};
if (document.body) {
fn();
} else {
$(fn);
}
})(jQuery, mw);
//Deprecated code: Used for autoplaying theme songs
//function Bebop(){
// console.log("OK 3 2 1 Let's Jam");
// var x = document.getElementById("myaudio");
// x.play();
//}
//
//setTimeout(Bebop, 2000);
// START HOTCAT
/*
This imports the latest version of HotCat from Commons.
HotCat is a gadget to make changes to categories much easier.
Full documentation can be found at http://commons.wikimedia.org/wiki/Help:Gadget-HotCat
*/
window.hotcat_translations_from_commons = true;
mw.loader.load( 'https://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );
// END HOTCAT
//Watermark AI Image
//Images can be renamed to have "-ai-" anywhere in their name and automatically get a watermark
$(document).ready(function() {
// Loop through all img tags
$('img').each(function() {
var img = $(this); // Reference to the current img tag in the loop
var src = img.attr('src'); // Get the src attribute
// Check if src contains '-ai' and doesn't already have 'watermarked' class
if (src.includes('-ai') && !img.hasClass('watermarked')) {
img.addClass('watermarked'); // Add the 'watermarked' class
}
});
});
