No edit summary  | 
				No edit summary  | 
				||
| Line 17: | Line 17: | ||
function convertTextIframesToReal() {  | function convertTextIframesToReal() {  | ||
   // Get all elements in the document  |    // Get all elements in the document  | ||
   var allElements = document.querySelectorAll('*');  | |||
   // Look for elements with text content that contains iframe tags  |    // Look for elements with text content that contains iframe tags  | ||
   allElements.  |    for (var i = 0; i < allElements.length; i++) {  | ||
    var element = allElements[i];  | |||
     if (element.childNodes && element.childNodes.length > 0) {  |      if (element.childNodes && element.childNodes.length > 0) {  | ||
       element.childNodes.  |        for (var j = 0; j < element.childNodes.length; j++) {  | ||
        var node = element.childNodes[j];  | |||
         // Check if this is a text node containing an iframe  |          // Check if this is a text node containing an iframe  | ||
         if (node.nodeType === 3 && node.textContent.trim().  |          if (node.nodeType === 3 && node.textContent.trim().indexOf('<iframe') !== -1) {  | ||
           var text = node.textContent.trim();  | |||
           // Use regex to extract the URL from src attribute  |            // Use regex to extract the URL from src attribute  | ||
           var srcMatch = /src="([^"]+)"/.exec(text);  | |||
           if (srcMatch && srcMatch[1]) {  |            if (srcMatch && srcMatch[1]) {  | ||
             var url = srcMatch[1];  | |||
             // Create a real iframe element with src attribute  |              // Create a real iframe element with src attribute  | ||
             var iframe = document.createElement('iframe');  | |||
             iframe.src = url;  |              iframe.src = url;  | ||
| Line 44: | Line 48: | ||
             // Replace the text node with the real iframe  |              // Replace the text node with the real iframe  | ||
             node.parentNode.replaceChild(iframe, node);  |              node.parentNode.replaceChild(iframe, node);  | ||
             console.log('Converted iframe with URL:'  |              console.log('Converted iframe with URL: ' + url);  | ||
           }  |            }  | ||
         }  |          }  | ||
       }  |        }  | ||
     }  |      }  | ||
   }  |    }  | ||
}  | }  | ||
// Call the function when the page is loaded  | // Call the function when the page is loaded  | ||
document.addEventListener('DOMContentLoaded', convertTextIframesToReal);  | if (document.readyState === 'loading') {  | ||
  document.addEventListener('DOMContentLoaded', convertTextIframesToReal);  | |||
// If   | } else {  | ||
convertTextIframesToReal();  |   // If the page is already loaded  | ||
  convertTextIframesToReal();  | |||
}  | |||
Revision as of 19:58, 14 March 2025
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
  var allElements = document.querySelectorAll('*');
  
  // Look for elements with text content that contains iframe tags
  for (var i = 0; i < allElements.length; i++) {
    var element = allElements[i];
    
    if (element.childNodes && element.childNodes.length > 0) {
      for (var j = 0; j < element.childNodes.length; j++) {
        var node = element.childNodes[j];
        
        // Check if this is a text node containing an iframe
        if (node.nodeType === 3 && node.textContent.trim().indexOf('<iframe') !== -1) {
          var text = node.textContent.trim();
          
          // Use regex to extract the URL from src attribute
          var srcMatch = /src="([^"]+)"/.exec(text);
          
          if (srcMatch && srcMatch[1]) {
            var url = srcMatch[1];
            
            // Create a real iframe element with src attribute
            var 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
if (document.readyState === 'loading') {
  document.addEventListener('DOMContentLoaded', convertTextIframesToReal);
} else {
  // If the page is already loaded
  convertTextIframesToReal();
}