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
mNo edit summary
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 5: Line 5:
});
});


$(".gtw-tabview").on("click","a", function() {
//----- [ Sharper Slider Images ] -----//
var $parent = $(this).parents(".gtw-tabview");
mw.hook('wikipage.content').add(($content) => {
var $href = $(this).attr("href");
const slides =  $content.find('.sharper-slider.gtw-slider .fandom-slider .gallerybox img');
if(!/^\/wiki\//.test($href)) return false; // Only allow wiki interlink for security reason
slides.each(function () {
$parent.find("a").removeClass("active");
const attrs = ['src','srcset','data-src','data-srcset'];
$(this).addClass("active");
for (const a of attrs) {
$parent.next(".gtw-tabpage").remove();
const value = this.getAttribute(a);
$.get($href, function(a) {
if (!value) continue;
$parent.next(".gtw-tabpage").remove();
const updatedValue = value.replace(/\/scale-to-width(?:-down)?\/\d+/g, '/scale-to-width-down/1200');
$("<div>",{class:"gtw-tabpage"}).insertAfter($parent).html($(a).find("#mw-content-text .mw-parser-output").html());
if (updatedValue !== value) this.setAttribute(a, updatedValue);
});
    return false;
}).each(function(){
var $default = $(this).attr("data-default");
if($default != undefined) {
$(this).find("a[href$="+$default+"]").click();
console.log('logging: ' +  $default);
}
}
});
});
});

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);
		}
	});
});