MediaWiki:Common.js: Difference between revisions

From The Skullgirls Wiki
Jump to navigation Jump to search
(forcing chat gpt to kill kyle cut idk how to code this shit)
(Just testing shit out real quick.)
 
(13 intermediate revisions by 2 users not shown)
Line 12: Line 12:
       // Add the new categories as classes to the body
       // Add the new categories as classes to the body
       $(document.body).addClass(newClasses);
       $(document.body).addClass(newClasses);
      // Check if "SG" category exists and dynamically load the SG-specific CSS
      if (cats.includes("SG")) {
        // Create a link element to load the SG-specific CSS
        var sgStyleLink = document.createElement("link");
        sgStyleLink.rel = "stylesheet";
        sgStyleLink.href = "https://example.com/sg-category-styles.css";
        sgStyleLink.type = "text/css";
        // Add the link to the head to load it first
        document.head.appendChild(sgStyleLink);
      }
      // Check if "WikiCSS" category exists and dynamically load the same CSS as SG
      if (cats.includes("WikiCSS")) {
        // Create a link element to load the SG-specific CSS (same path)
        var wikiStyleLink = document.createElement("link");
        wikiStyleLink.rel = "stylesheet";
        wikiStyleLink.href = "https://example.com/wikicss-category-styles.css";
        wikiStyleLink.type = "text/css";
        // Add the link to the head
        document.head.appendChild(wikiStyleLink);
      }
     
      // Check if "Test" category exists and dynamically load the Test-specific CSS
      if (cats.includes("Test")) {
        // Create a link element to load the Test-specific CSS
        var testStyleLink = document.createElement("link");
        testStyleLink.rel = "stylesheet";
        testStyleLink.href = "https://example.com/test-category-styles.css";
        testStyleLink.type = "text/css";
        // Add the link to the head to load it first
        document.head.appendChild(testStyleLink);
      }
     }
     }
   };
   };
Line 40: Line 76:
     }
     }
});
});
/* Admin names text style */
$(function () {
    // Define the admin usernames
    var adminUsers = ["Ninespit", "Nacho-dipsauce14", "Dung_Eater"];
    // Check all user links and apply the 'admin' class
    $(".mw-userlink").each(function () {
        var username = $(this).text().trim();
        if (adminUsers.includes(username)) {
            $(this).addClass("admin");
        }
    });
});
/* Admin name text style icon */
$(function () {
    // Define user-specific icons
    var userIcons = {
        "Ninespit": "image",
        "Nacho-dipsauce14": "image",
        "Ninimasurasilly": "image",
        "Dung_Eater": "image",
    };
    // Loop through all user links
    $(".mw-userlink").each(function () {
        var username = $(this).text().trim();
        if (userIcons[username]) {
            $(this).addClass("user-" + username);
        }
    });
});
/* STYLES */
/* Skullgirlz troll page */
mw.loader.load(
  '/index.php?title=MediaWiki:SG.css&action=raw&ctype=text/css',
  'text/css'
);
/* Normal wikipedia like style */
mw.loader.load(
  '/index.php?title=MediaWiki:Wiki.css&action=raw&ctype=text/css',
  'text/css'
);
/* Test style */
mw.loader.load(
  '/index.php?title=MediaWiki:Test.css&action=raw&ctype=text/css',
  'text/css'
);

Latest revision as of 11:32, 1 September 2026

/* Any JavaScript here will be loaded for all users on every page load. */

/*style based on category*/
(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(' ');

      // Add the new categories as classes to the body
      $(document.body).addClass(newClasses);

      // Check if "SG" category exists and dynamically load the SG-specific CSS
      if (cats.includes("SG")) {
        // Create a link element to load the SG-specific CSS
        var sgStyleLink = document.createElement("link");
        sgStyleLink.rel = "stylesheet";
        sgStyleLink.href = "https://example.com/sg-category-styles.css";
        sgStyleLink.type = "text/css";

        // Add the link to the head to load it first
        document.head.appendChild(sgStyleLink);
      }

      // Check if "WikiCSS" category exists and dynamically load the same CSS as SG
      if (cats.includes("WikiCSS")) {
        // Create a link element to load the SG-specific CSS (same path)
        var wikiStyleLink = document.createElement("link");
        wikiStyleLink.rel = "stylesheet";
        wikiStyleLink.href = "https://example.com/wikicss-category-styles.css";
        wikiStyleLink.type = "text/css";

        // Add the link to the head
        document.head.appendChild(wikiStyleLink);
      }
      
      // Check if "Test" category exists and dynamically load the Test-specific CSS
      if (cats.includes("Test")) {
        // Create a link element to load the Test-specific CSS
        var testStyleLink = document.createElement("link");
        testStyleLink.rel = "stylesheet";
        testStyleLink.href = "https://example.com/test-category-styles.css";
        testStyleLink.type = "text/css";

        // Add the link to the head to load it first
        document.head.appendChild(testStyleLink);
      }
    }
  };

  if (document.body) {
    fn();
  } else {
    $(fn);
  }
})(jQuery, mw);

/*Kyle image down there*/
$(document).ready(function() {
    // Get categories for the current page
    var cats = mw.config.get('wgCategories');

    // Check if the page belongs to the "SG" category
    if (cats && !cats.includes("SG")) {
        // Create a div element for the image
        var imageDiv = document.createElement('div');
        imageDiv.className = 'bottom-left-image';

        // Add the image markup to the div with CSS for size adjustment
        imageDiv.innerHTML = '<a href="Kyle" title="Image"><img src="https://skullgirlz.wiki/images/1/1f/Kyle_Bloodworth-Thomason2.png" style="width: 115px; height: auto;" /></a>';

        // Append the div to the body
        document.body.appendChild(imageDiv);
    }
});

/* Admin names text style */
$(function () {
    // Define the admin usernames
    var adminUsers = ["Ninespit", "Nacho-dipsauce14", "Dung_Eater"];

    // Check all user links and apply the 'admin' class
    $(".mw-userlink").each(function () {
        var username = $(this).text().trim(); 
        if (adminUsers.includes(username)) {
            $(this).addClass("admin");
        }
    });
});
/* Admin name text style icon */
$(function () {
    // Define user-specific icons
    var userIcons = {
        "Ninespit": "image",
        "Nacho-dipsauce14": "image",
        "Ninimasurasilly": "image",
        "Dung_Eater": "image",
    };

    // Loop through all user links
    $(".mw-userlink").each(function () {
        var username = $(this).text().trim();
        if (userIcons[username]) {
            $(this).addClass("user-" + username);
        }
    });
});


/* STYLES */
/* Skullgirlz troll page */
mw.loader.load(
  '/index.php?title=MediaWiki:SG.css&action=raw&ctype=text/css',
  'text/css'
);

/* Normal wikipedia like style */
mw.loader.load(
  '/index.php?title=MediaWiki:Wiki.css&action=raw&ctype=text/css',
  'text/css'
);

/* Test style */
mw.loader.load(
  '/index.php?title=MediaWiki:Test.css&action=raw&ctype=text/css',
  'text/css'
);