Dc12d13
Versiunea din 22 august 2024 09:24, autor: HalfOp (Discuție | contribuții) (Pagină nouă: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Metin2 Loot</title> </head>...)
<!DOCTYPE html> <html lang="en"> <head>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Metin2 Loot</title>
</head> <body style="background-color: #26211D; color: white;">
- Câine Sălbatic
- Lup
- Selectează un monstru pentru a vedea prada
<script>
async function fetchLoot(monster) {
console.log('Fetching loot for:', monster); // Debugging line
var lootList = document.getElementById('loot-list');
lootList.innerHTML = ; // Clear existing content
// Construct the API URL to fetch the page content
var apiUrl = `https://ro-wiki.metin2.gameforge.com/api.php?action=parse&page=${monster}&prop=wikitext&format=json&origin=*`;
console.log('API URL:', apiUrl); // Debugging line
try {
const response = await fetch(apiUrl);
const data = await response.json();
console.log('API Response:', data); // Debugging line
// Get the wikitext content of the page
var wikitext = data.parse.wikitext['*'];
// Extract the Weapondrops section using regex
var weapondropsMatch = wikitext.match(/\|Weapondrops\s*=\s*(.*?)(\n|$)/s);
if (weapondropsMatch) {
var weapondrops = weapondropsMatch[1].trim();
// Split the weapondrops by "::" (assuming they are separated this way)
var lootItems = weapondrops.split('::');
lootItems.forEach(function(item) {
if (item.trim()) {
var li = document.createElement('li');
li.textContent = item.trim();
lootList.appendChild(li);
}
});
} else {
var li = document.createElement('li');
li.textContent = 'No weapon drops found';
lootList.appendChild(li);
}
} catch (error) {
var li = document.createElement('li');
li.textContent = 'Error fetching loot';
lootList.appendChild(li);
console.error('Error:', error);
}
}
</script>
</body> </html>