No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
//document.querySelector('#sb-pri-tgl-btn').style.display = 'none'; | //document.querySelector('#sb-pri-tgl-btn').style.display = 'none'; | ||
//document.getElementById('sb-pri-tgl-btn').remove(); | //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(); |
Revision as of 21:55, 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
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();