demo-tibia-simple.js•3.35 kB
#!/usr/bin/env node
import { firefox } from 'playwright';
async function demoTibia() {
console.log('🦎 Demo: Visiting tibia.com with Firefox automation...\n');
try {
// Launch Firefox (visible so you can see it working)
console.log('📱 Launching Firefox browser...');
const browser = await firefox.launch({
headless: false,
slowMo: 500
});
const page = await browser.newPage();
console.log('🌐 Navigating to tibia.com...');
// Use a more forgiving timeout and wait condition
await page.goto('https://tibia.com', {
waitUntil: 'domcontentloaded',
timeout: 15000
});
// Wait a bit for content to load
await page.waitForTimeout(2000);
// Get basic page info
console.log('📄 Getting page information...');
const title = await page.title();
const url = page.url();
console.log(`✅ Successfully loaded!`);
console.log(`📄 Title: ${title}`);
console.log(`🌐 URL: ${url}\n`);
// Take a screenshot
console.log('📸 Taking screenshot...');
await page.screenshot({ path: 'tibia-demo.png' });
// Get visible text content
console.log('👀 Analyzing visible content...');
const bodyText = await page.evaluate(() => {
return document.body.innerText;
});
console.log('\n=== TIBIA.COM CONTENT DESCRIPTION ===\n');
// Look for key information
const textLower = bodyText.toLowerCase();
if (textLower.includes('tibia')) {
console.log('🎮 This appears to be the official Tibia game website');
}
if (textLower.includes('download')) {
console.log('💾 Download options are available on the page');
}
if (textLower.includes('play') || textLower.includes('game')) {
console.log('🎯 Game-related content is present');
}
if (textLower.includes('world') || textLower.includes('server')) {
console.log('🌍 Game world/server information is mentioned');
}
if (textLower.includes('premium') || textLower.includes('account')) {
console.log('💳 Account/premium features are discussed');
}
// Extract first few lines of visible text
const lines = bodyText.split('\n').filter(line => line.trim().length > 0).slice(0, 8);
console.log('\n📝 First visible content lines:');
lines.forEach((line, index) => {
if (line.trim().length > 5) {
console.log(` ${index + 1}. ${line.trim().substring(0, 80)}${line.length > 80 ? '...' : ''}`);
}
});
console.log('\n📸 Screenshot saved as "tibia-demo.png"');
// Wait so you can see the browser
console.log('\n⏱️ Keeping browser open for 3 seconds...');
await page.waitForTimeout(3000);
console.log('🔒 Closing browser...');
await browser.close();
console.log('\n✅ Demo completed successfully!');
console.log('🔄 Once you restart VSCode, the Firefox MCP server will be available for direct control.');
} catch (error) {
console.error('❌ Demo failed:', error.message);
console.log('\n💡 Note: This could be due to network connectivity or site loading issues.');
console.log('The Firefox MCP server setup is still complete and working properly.');
process.exit(1);
}
}
demoTibia();