No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
// Function to | // Function to convert MediaWiki processed iframe text to real iframes | ||
function | function convertMediaWikiIframesToReal() { | ||
// Look for paragraphs that contain escaped iframe tags | |||
// | var paragraphs = document.querySelectorAll('p'); | ||
var | |||
for (var i = 0; i < paragraphs.length; i++) { | |||
for (var i = 0; i < | var paragraph = paragraphs[i]; | ||
var | var content = paragraph.innerHTML; | ||
if ( | // Check if this paragraph contains an escaped iframe | ||
if (content.indexOf('<iframe') !== -1 && content.indexOf('</iframe>') !== -1) { | |||
var | |||
// Find any links inside this iframe text | |||
var links = paragraph.querySelectorAll('a.external'); | |||
if (links.length > 0) { | |||
// Use the href from the first link as our iframe src | |||
var url = links[0].href; | |||
// | // Create an actual iframe element | ||
var iframe = document.createElement('iframe'); | |||
iframe.src = url; | |||
iframe.width = "100%"; | |||
iframe.height = "500px"; | |||
iframe.style.border = "none"; | |||
// Replace the paragraph with the iframe | |||
if (paragraph.parentNode) { | |||
paragraph.parentNode.replaceChild(iframe, paragraph); | |||
console.log('Converted MediaWiki iframe to real iframe with URL: ' + url); | |||
} | } | ||
} | } | ||
Line 59: | Line 52: | ||
// Call the function when the page is loaded | // Call the function when the page is loaded | ||
if (document.readyState === 'loading') { | if (document.readyState === 'loading') { | ||
document.addEventListener('DOMContentLoaded', | document.addEventListener('DOMContentLoaded', convertMediaWikiIframesToReal); | ||
} else { | } else { | ||
// If the page is already loaded | // If the page is already loaded | ||
convertMediaWikiIframesToReal(); | |||
} | } |
Revision as of 22:03, 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 convert MediaWiki processed iframe text to real iframes
function convertMediaWikiIframesToReal() {
// Look for paragraphs that contain escaped iframe tags
var paragraphs = document.querySelectorAll('p');
for (var i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
var content = paragraph.innerHTML;
// Check if this paragraph contains an escaped iframe
if (content.indexOf('<iframe') !== -1 && content.indexOf('</iframe>') !== -1) {
// Find any links inside this iframe text
var links = paragraph.querySelectorAll('a.external');
if (links.length > 0) {
// Use the href from the first link as our iframe src
var url = links[0].href;
// Create an actual iframe element
var iframe = document.createElement('iframe');
iframe.src = url;
iframe.width = "100%";
iframe.height = "500px";
iframe.style.border = "none";
// Replace the paragraph with the iframe
if (paragraph.parentNode) {
paragraph.parentNode.replaceChild(iframe, paragraph);
console.log('Converted MediaWiki iframe to real iframe with URL: ' + url);
}
}
}
}
}
// Call the function when the page is loaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', convertMediaWikiIframesToReal);
} else {
// If the page is already loaded
convertMediaWikiIframesToReal();
}