Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:HashJona/common.js: Difference between revisions

From Growtopia Wiki
Created page with "$(function() { $("a.no-blank").on("click", function(event) { if ($(this).attr("target") === "_blank") { event.preventDefault(); // Optionally open in the same tab window.location = $(this).attr("href"); } }); });"
 
mNo edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
$(function() {
$(function() {
        $("a.no-blank").on("click", function(event) {
    $("span.no-blank-target").each(function() {
            if ($(this).attr("target") === "_blank") {
    $(this).closest("a").removeAttr("target");
                event.preventDefault();
    });
                // Optionally open in the same tab
});
                window.location = $(this).attr("href");
 
            }
//----- [ Sharper Slider Images ] -----//
        });
mw.hook('wikipage.content').add(($content) => {
const slides = $content.find('.sharper-slider.gtw-slider .fandom-slider .gallerybox img');
slides.each(function () {
const attrs = ['src','srcset','data-src','data-srcset'];
for (const a of attrs) {
const value = this.getAttribute(a);
if (!value) continue;
const updatedValue = value.replace(/\/scale-to-width(?:-down)?\/\d+/g, '/scale-to-width-down/1200');
if (updatedValue !== value) this.setAttribute(a, updatedValue);
}
});
});
});

Latest revision as of 14:48, 1 September 2025

$(function() {
    $("span.no-blank-target").each(function() {
    	$(this).closest("a").removeAttr("target");
    });
});

//----- [ Sharper Slider Images ] -----//
mw.hook('wikipage.content').add(($content) => {
	const slides =  $content.find('.sharper-slider.gtw-slider .fandom-slider .gallerybox img');
	slides.each(function () {
		const attrs = ['src','srcset','data-src','data-srcset'];
		for (const a of attrs) {
			const value = this.getAttribute(a);
			if (!value) continue;
			const updatedValue = value.replace(/\/scale-to-width(?:-down)?\/\d+/g, '/scale-to-width-down/1200');
			if (updatedValue !== value) this.setAttribute(a, updatedValue);
		}
	});
});