MediaWiki:Common.js
De Cronicas Eternas Wiki
Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Internet Explorer/Edge: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
- Opera: Pressione Ctrl-F5.
document.addEventListener("DOMContentLoaded", function () {
// Função que adiciona os emojis à tabela
function addEmojisToContributionScores() {
const table = document.querySelector("table.contribscores");
if (table) {
const rows = table.querySelectorAll("tr");
rows.forEach((row, index) => {
if (index === 0) return; // Ignora o cabeçalho da tabela
const rankCell = row.querySelector("td:first-child"); // Seleciona a célula da classificação
if (rankCell) {
const rank = parseInt(rankCell.textContent.trim(), 10);
// Adiciona emojis com base na classificação
if (rank === 1) {
rankCell.textContent = "🏆 " + rank;
} else if (rank === 2) {
rankCell.textContent = "🥈 " + rank;
} else if (rank === 3) {
rankCell.textContent = "🥉 " + rank;
}
}
});
}
}
// Observador de mudanças no DOM
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === "childList") {
addEmojisToContributionScores();
}
});
});
// Observa o body inteiro por mudanças
observer.observe(document.body, {
childList: true,
subtree: true,
});
// Aplica os emojis imediatamente caso a tabela já esteja presente
addEmojisToContributionScores();
});