Last edited one month ago
by WikiSysop

Common.js

Revision as of 21:55, 14 March 2025 by WikiSysop (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.using('mediawiki.user').then(function () {
    mw.user.getGroups().then(function (groups) {
        console.log('User groups:', groups);
        if (groups.includes('sysop')) {
            console.log('User is an administrator.');
        }
    });
});

//	hide the sidebar navigation. 
//document.querySelector('#sb-pri-tgl-btn').style.display = 'none';
//document.getElementById('sb-pri-tgl-btn').remove();



// Function to find text iframes and convert them to real iframes
function convertTextIframesToReal() {
  // Get all elements in the document
  const allElements = document.querySelectorAll('*');
  
  // Look for elements with text content that contains iframe tags
  allElements.forEach(element => {
    if (element.childNodes && element.childNodes.length > 0) {
      element.childNodes.forEach(node => {
        // Check if this is a text node containing an iframe
        if (node.nodeType === 3 && node.textContent.trim().includes('<iframe')) {
          const text = node.textContent.trim();
          
          // Use regex to extract the URL from src attribute
          const srcMatch = text.match(/src="([^"]+)"/);
          
          if (srcMatch && srcMatch[1]) {
            const url = srcMatch[1];
            
            // Create a real iframe element with src attribute
            const iframe = document.createElement('iframe');
            iframe.src = url;
            
            // You can add additional attributes as needed
            iframe.width = "100%";
            iframe.height = "500px";
            iframe.style.border = "none";
            
            // Replace the text node with the real iframe
            node.parentNode.replaceChild(iframe, node);
            console.log('Converted iframe with URL:', url);
          }
        }
      });
    }
  });
}

// Call the function when the page is loaded
document.addEventListener('DOMContentLoaded', convertTextIframesToReal);

// If you need to run it immediately on an already loaded page
convertTextIframesToReal();