// LeakHub Database and State Management let leakDatabase = []; let selectedSubmissions = new Set(); let userStats = {}; let leakRequests = []; let userVotes = {}; let dailyChallenge = null; // Dynamic Achievement System const achievements = { firstBlood: { id: 'firstBlood', name: 'First Blood', description: 'Submit your first leak', icon: '🩸', points: 50, unlocked: false }, discoverer: { id: 'discoverer', name: 'Discoverer', description: 'Make your first discovery', icon: '🔍', points: 100, unlocked: false }, verifier: { id: 'verifier', name: 'Verifier', description: 'Verify 5 submissions', icon: '✅', points: 200, unlocked: false }, collector: { id: 'collector', name: 'Collector', description: 'Submit 10 different leaks', icon: '📚', points: 300, unlocked: false }, expert: { id: 'expert', name: 'Expert', description: 'Reach 1000 total points', icon: '👑', points: 500, unlocked: false }, pioneer: { id: 'pioneer', name: 'Pioneer', description: 'Discover 5 different targets', icon: '🚀', points: 400, unlocked: false }, analyst: { id: 'analyst', name: 'Analyst', description: 'Perform 20 comparisons', icon: '📊', points: 250, unlocked: false }, challenger: { id: 'challenger', name: 'Challenger', description: 'Complete 5 daily challenges', icon: '🎯', points: 350, unlocked: false }, community: { id: 'community', name: 'Community Hero', description: 'Submit 10 requests', icon: '🤝', points: 200, unlocked: false }, legend: { id: 'legend', name: 'LeakHub Legend', description: 'Unlock all achievements', icon: '🌟', points: 1000, unlocked: false } }; let userAchievements = {}; // Initialize database and UI async function initializeApp() { try { // Wait for database to be ready await window.LeakHubDB.init(); // Load data from database leakDatabase = await window.LeakHubDB.getLeakDatabase(); userStats = await window.LeakHubDB.getUserStats(); leakRequests = await window.LeakHubDB.getLeakRequests(); userVotes = await window.LeakHubDB.getUserVotes(); dailyChallenge = await window.LeakHubDB.getDailyChallenge(); // Initialize UI updateUI(); initializeDailyChallenge(); startChallengeTimer(); console.log('LeakHub initialized successfully'); } catch (error) { console.error('Error initializing LeakHub:', error); // Fallback to localStorage if database fails leakDatabase = JSON.parse(localStorage.getItem('leakDatabase') || '[]'); userStats = JSON.parse(localStorage.getItem('userStats') || '{}'); leakRequests = JSON.parse(localStorage.getItem('leakRequests') || '[]'); userVotes = JSON.parse(localStorage.getItem('userVotes') || '{}'); dailyChallenge = JSON.parse(localStorage.getItem('dailyChallenge') || 'null'); updateUI(); initializeDailyChallenge(); startChallengeTimer(); } } // Start the app initializeApp(); function submitLeak(event) { event.preventDefault(); const source = document.getElementById('sourceName').value; const submission = { id: Date.now().toString(), source: source, targetType: document.getElementById('targetType').value, instance: document.getElementById('instanceId').value, targetUrl: document.getElementById('targetUrl').value || null, requiresLogin: document.getElementById('requiresLogin').checked, requiresPaid: document.getElementById('requiresPaid').checked, accessNotes: document.getElementById('accessNotes').value || null, parentSystem: document.getElementById('parentSystem').value || null, functionName: document.getElementById('functionName').value || null, content: document.getElementById('leakContent').value, toolPrompts: document.getElementById('toolPrompts').value || null, context: document.getElementById('context').value, timestamp: new Date().toISOString(), verifications: 0, confidence: 0, isFirstDiscovery: false, hasTools: document.getElementById('hasTools').checked }; // Calculate initial confidence based on content submission.confidence = calculateInitialConfidence(submission.content); // Check if this is the first discovery for this specific target const targetKey = `${submission.targetType}:${submission.instance}${submission.functionName ? ':' + submission.functionName : ''}`; const existingForTarget = leakDatabase.filter(sub => { const subKey = `${sub.targetType}:${sub.instance}${sub.functionName ? ':' + sub.functionName : ''}`; return subKey === targetKey; }); if (existingForTarget.length === 0) { submission.isFirstDiscovery = true; } leakDatabase.push(submission); // Update user stats if (!userStats[source]) { userStats[source] = { submissions: 0, verifiedLeaks: 0, firstDiscoveries: 0, totalScore: 0, joinDate: new Date().toISOString(), toolsDiscovered: 0, appsDiscovered: 0, agentsDiscovered: 0, comparisons: 0, challengesCompleted: 0, requestsSubmitted: 0 }; } userStats[source].submissions++; if (submission.isFirstDiscovery) { userStats[source].firstDiscoveries++; userStats[source].totalScore += 100; // 100 points for first discovery // Extra points for discovering non-model targets if (submission.targetType !== 'model') { userStats[source].totalScore += 50; // Bonus for diversity } // Track specific discovery types if (submission.targetType === 'tool') userStats[source].toolsDiscovered++; if (submission.targetType === 'app') userStats[source].appsDiscovered++; if (submission.targetType === 'agent') userStats[source].agentsDiscovered++; } userStats[source].totalScore += 10; // 10 points for any submission // Bonus points for tool prompts if (submission.hasTools && submission.toolPrompts) { userStats[source].totalScore += 30; // Extra points for comprehensive submission } saveDatabase().then(() => { updateUI(); // Clear form document.getElementById('sourceName').value = ''; document.getElementById('targetType').value = ''; document.getElementById('instanceId').value = ''; document.getElementById('targetUrl').value = ''; document.getElementById('requiresLogin').checked = false; document.getElementById('requiresPaid').checked = false; document.getElementById('accessNotes').value = ''; document.getElementById('parentSystem').value = ''; document.getElementById('functionName').value = ''; document.getElementById('leakContent').value = ''; document.getElementById('toolPrompts').value = ''; document.getElementById('context').value = ''; document.getElementById('hasTools').checked = false; document.getElementById('additionalFields').style.display = 'none'; document.getElementById('toolsSection').style.display = 'none'; showAlert('Leak submitted successfully!'); }); showAlert(submission.isFirstDiscovery ? '🎉 First discovery! You found a new leak!' : 'Leak submitted successfully!'); // Check for daily challenge completion checkDailyChallengeCompletion(submission); } function updateTargetFields() { const targetType = document.getElementById('targetType').value; const additionalFields = document.getElementById('additionalFields'); const instancePlaceholder = document.getElementById('instanceId'); if (targetType === 'tool' || targetType === 'plugin') { additionalFields.style.display = 'block'; instancePlaceholder.placeholder = 'Tool/Plugin name (e.g., Code Interpreter, WebPilot)'; } else if (targetType === 'agent') { additionalFields.style.display = 'block'; instancePlaceholder.placeholder = 'Agent name (e.g., AutoGPT, BabyAGI)'; } else if (targetType === 'app') { additionalFields.style.display = 'none'; instancePlaceholder.placeholder = 'App name (e.g., Cursor, GitHub Copilot)'; } else if (targetType === 'custom') { additionalFields.style.display = 'block'; instancePlaceholder.placeholder = 'Custom GPT/Bot name'; } else { additionalFields.style.display = 'none'; instancePlaceholder.placeholder = 'Model name (e.g., GPT-4, Claude-3)'; } } function toggleToolsSection() { const toolsSection = document.getElementById('toolsSection'); const hasTools = document.getElementById('hasTools').checked; toolsSection.style.display = hasTools ? 'block' : 'none'; } function calculateInitialConfidence(content) { // Simple heuristics for initial confidence let confidence = 50; // Base confidence // Check for common system prompt patterns if (content.includes('You are') || content.includes('Your purpose')) confidence += 10; if (content.includes('instructions') || content.includes('guidelines')) confidence += 10; if (content.includes('Do not') || content.includes('Never')) confidence += 10; if (content.length > 500) confidence += 10; if (content.includes('\n') && content.split('\n').length > 5) confidence += 10; return Math.min(confidence, 90); // Cap at 90% until verified } function updateUI() { updateSubmissionsList(); updateStatistics(); updateSelectors(); } function updateSubmissionsList() { const list = document.getElementById('submissionsList'); if (leakDatabase.length === 0) { list.innerHTML = '

No submissions yet. Be the first to contribute!

'; return; } // Group by target type and instance const grouped = leakDatabase.reduce((acc, submission) => { const targetType = submission.targetType || 'model'; // Backwards compatibility const typeEmoji = { 'model': '🤖 ', 'app': '📱 ', 'tool': '🔧 ', 'agent': '🤝 ', 'plugin': '🔌 ', 'custom': '🛠️ ' }[targetType] || '📄 '; const groupKey = `${typeEmoji} ${submission.instance}`; if (!acc[groupKey]) acc[groupKey] = []; acc[groupKey].push(submission); return acc; }, {}); list.innerHTML = Object.entries(grouped).map(([groupName, submissions]) => `

${groupName} (${submissions.length} submissions)

${submissions.map(sub => { const targetInfo = sub.functionName ? `→ ${sub.functionName}` : ''; const parentInfo = sub.parentSystem ? `(${sub.parentSystem})` : ''; const toolsBadge = sub.hasTools ? '+tools' : ''; // Access badges const accessBadges = []; if (sub.requiresLogin) accessBadges.push('🔒'); if (sub.requiresPaid) accessBadges.push('💰'); const linkButton = sub.targetUrl ? `🔗 Visit` : ''; return `
${linkButton}
${sub.source} ${parentInfo} ${new Date(sub.timestamp).toLocaleDateString()}
${targetInfo}
${sub.content.substring(0, 100)}...
${sub.accessNotes ? `
📋 ${sub.accessNotes}
` : ''}
${sub.confidence}%
${toolsBadge}${accessBadges.join('')}
`; }).join('')}
`).join(''); } function updateStatistics() { // Count unique targets by type const targetCounts = leakDatabase.reduce((acc, sub) => { const targetType = sub.targetType || 'model'; const key = `${targetType}:${sub.instance}`; acc.add(key); return acc; }, new Set()); document.getElementById('activeLeaks').textContent = targetCounts.size; document.getElementById('totalSubmissions').textContent = leakDatabase.length; const verified = leakDatabase.filter(sub => sub.confidence >= 90).length; document.getElementById('verifiedPrompts').textContent = verified; document.getElementById('uniqueInstances').textContent = targetCounts.size; // Calculate average similarity from recent comparisons const avgSim = localStorage.getItem('avgSimilarity') || '0'; document.getElementById('avgSimilarity').textContent = avgSim + '%'; const highConf = leakDatabase.filter(sub => sub.confidence >= 80).length; document.getElementById('highConfidence').textContent = highConf; } function updateSelectors() { const selectA = document.getElementById('instanceA'); const selectB = document.getElementById('instanceB'); const options = '' + leakDatabase.map(sub => { const targetType = sub.targetType || 'model'; const typeLabel = targetType.charAt(0).toUpperCase() + targetType.slice(1); const fullName = sub.functionName ? `${sub.instance} → ${sub.functionName}` : sub.instance; return ``; }).join(''); selectA.innerHTML = options; selectB.innerHTML = options; } function toggleSelection(id) { if (selectedSubmissions.has(id)) { selectedSubmissions.delete(id); } else { selectedSubmissions.add(id); } updateUI(); } function compareInstances() { const idA = document.getElementById('instanceA').value; const idB = document.getElementById('instanceB').value; if (!idA || !idB || idA === idB) { showAlert('Please select two different submissions to compare'); return; } const subA = leakDatabase.find(sub => sub.id === idA); const subB = leakDatabase.find(sub => sub.id === idB); performComparison(subA, subB); } function performComparison(subA, subB) { document.getElementById('comparisonResults').style.display = 'block'; // Display content document.getElementById('instanceAContent').textContent = subA.content; document.getElementById('instanceBContent').textContent = subB.content; // Normalize texts for comparison (remove extra whitespace, lowercase for some checks) const normA = normalizeText(subA.content); const normB = normalizeText(subB.content); // Calculate metrics const charMatch = calculateCharMatch(normA, normB); const wordMatch = calculateWordMatch(normA, normB); const structureMatch = calculateStructureMatch(subA.content, subB.content); const coreSimilarity = calculateCoreSimilarity(normA, normB); // Update UI document.getElementById('charMatch').textContent = charMatch + '%'; document.getElementById('wordMatch').textContent = wordMatch + '%'; document.getElementById('structureMatch').textContent = structureMatch + '%'; document.getElementById('coreSimilarity').textContent = coreSimilarity + '%'; // Generate consensus view generateConsensusView(subA.content, subB.content); // Update average similarity const avgSim = Math.round((charMatch + wordMatch + structureMatch + coreSimilarity) / 4); localStorage.setItem('avgSimilarity', avgSim.toString()); // Update confidence scores if high match if (coreSimilarity > 85) { subA.confidence = Math.min(100, subA.confidence + 5); subB.confidence = Math.min(100, subB.confidence + 5); subA.verifications++; subB.verifications++; // Award points for verification if (userStats[subA.source]) { userStats[subA.source].totalScore += 20; // 20 points for verification if (subA.confidence >= 95 && !subA.wasVerified) { userStats[subA.source].verifiedLeaks++; userStats[subA.source].totalScore += 50; // Bonus for reaching verified status subA.wasVerified = true; } } if (userStats[subB.source]) { userStats[subB.source].totalScore += 20; if (subB.confidence >= 95 && !subB.wasVerified) { userStats[subB.source].verifiedLeaks++; userStats[subB.source].totalScore += 50; subB.wasVerified = true; } } saveDatabase().then(() => { updateUI(); }); } // Scroll to results document.getElementById('comparisonResults').scrollIntoView({ behavior: 'smooth' }); } function normalizeText(text) { return text .toLowerCase() .replace(/\s+/g, ' ') .replace(/[^\w\s]/g, '') .trim(); } function calculateCharMatch(textA, textB) { const longer = textA.length > textB.length ? textA : textB; const shorter = textA.length > textB.length ? textB : textA; let matches = 0; for (let i = 0; i < shorter.length; i++) { if (shorter[i] === longer[i]) matches++; } return Math.round((matches / longer.length) * 100); } function calculateWordMatch(textA, textB) { const wordsA = new Set(textA.split(' ')); const wordsB = new Set(textB.split(' ')); const intersection = new Set([...wordsA].filter(x => wordsB.has(x))); const union = new Set([...wordsA, ...wordsB]); return Math.round((intersection.size / union.size) * 100); } function calculateStructureMatch(textA, textB) { // Compare line counts, paragraph structure, etc. const linesA = textA.split('\n').filter(l => l.trim()); const linesB = textB.split('\n').filter(l => l.trim()); const lineRatio = Math.min(linesA.length, linesB.length) / Math.max(linesA.length, linesB.length); // Check for similar patterns (numbered lists, bullet points, etc.) const hasNumbersA = /^\d+\./.test(textA); const hasNumbersB = /^\d+\./.test(textB); const hasBulletsA = /^[-*•]/.test(textA); const hasBulletsB = /^[-*•]/.test(textB); let structureScore = lineRatio * 50; if (hasNumbersA === hasNumbersB) structureScore += 25; if (hasBulletsA === hasBulletsB) structureScore += 25; return Math.round(structureScore); } function calculateCoreSimilarity(textA, textB) { // Use a simple sliding window approach to find common phrases const minPhraseLength = 10; const commonPhrases = []; for (let i = 0; i <= textA.length - minPhraseLength; i++) { for (let len = minPhraseLength; len <= 50 && i + len <= textA.length; len++) { const phrase = textA.substring(i, i + len); if (textB.includes(phrase)) { commonPhrases.push(phrase); } } } // Remove overlapping phrases const uniquePhrases = commonPhrases.filter((phrase, index) => { return !commonPhrases.some((other, otherIndex) => otherIndex !== index && other.includes(phrase) && other.length > phrase.length ); }); const commonLength = uniquePhrases.reduce((sum, phrase) => sum + phrase.length, 0); const avgLength = (textA.length + textB.length) / 2; return Math.round((commonLength / avgLength) * 100); } function generateConsensusView(textA, textB) { const consensusDiv = document.getElementById('consensusText'); // Find common lines/sections const linesA = textA.split('\n'); const linesB = textB.split('\n'); let consensus = []; linesA.forEach(lineA => { const trimmedA = lineA.trim(); if (!trimmedA) return; const matchingLine = linesB.find(lineB => { const trimmedB = lineB.trim(); // Allow for minor differences return trimmedB && ( trimmedA === trimmedB || similarity(trimmedA.toLowerCase(), trimmedB.toLowerCase()) > 0.8 ); }); if (matchingLine) { consensus.push(`${trimmedA}`); } }); if (consensus.length > 0) { consensusDiv.innerHTML = consensus.join('\n'); } else { consensusDiv.innerHTML = 'No exact line matches found. Consider checking word-level similarities above.'; } } function similarity(s1, s2) { const longer = s1.length > s2.length ? s1 : s2; const shorter = s1.length > s2.length ? s2 : s1; if (longer.length === 0) return 1.0; const editDistance = levenshteinDistance(longer, shorter); return (longer.length - editDistance) / longer.length; } function levenshteinDistance(s1, s2) { const costs = []; for (let i = 0; i <= s1.length; i++) { let lastValue = i; for (let j = 0; j <= s2.length; j++) { if (i === 0) { costs[j] = j; } else if (j > 0) { let newValue = costs[j - 1]; if (s1.charAt(i - 1) !== s2.charAt(j - 1)) { newValue = Math.min(Math.min(newValue, lastValue), costs[j]) + 1; } costs[j - 1] = lastValue; lastValue = newValue; } } if (i > 0) costs[s2.length] = lastValue; } return costs[s2.length]; } async function saveDatabase() { try { await window.LeakHubDB.setLeakDatabase(leakDatabase); await window.LeakHubDB.setUserStats(userStats); await window.LeakHubDB.setLeakRequests(leakRequests); await window.LeakHubDB.setUserVotes(userVotes); await window.LeakHubDB.setDailyChallenge(dailyChallenge); // Also save to localStorage as backup localStorage.setItem('leakDatabase', JSON.stringify(leakDatabase)); localStorage.setItem('userStats', JSON.stringify(userStats)); localStorage.setItem('leakRequests', JSON.stringify(leakRequests)); localStorage.setItem('userVotes', JSON.stringify(userVotes)); localStorage.setItem('dailyChallenge', JSON.stringify(dailyChallenge)); } catch (error) { console.error('Error saving to database:', error); // Fallback to localStorage only localStorage.setItem('leakDatabase', JSON.stringify(leakDatabase)); localStorage.setItem('userStats', JSON.stringify(userStats)); localStorage.setItem('leakRequests', JSON.stringify(leakRequests)); localStorage.setItem('userVotes', JSON.stringify(userVotes)); localStorage.setItem('dailyChallenge', JSON.stringify(dailyChallenge)); } } function showAlert(message) { const alert = document.getElementById('alert'); alert.textContent = message; alert.style.display = 'block'; setTimeout(() => { alert.style.display = 'none'; }, 3000); } // Leaderboard functions function toggleLeaderboard() { const overlay = document.getElementById('leaderboardOverlay'); overlay.style.display = overlay.style.display === 'none' ? 'block' : 'none'; if (overlay.style.display === 'block') { updateLeaderboard(); } } function switchLeaderboardTab(tab) { document.querySelectorAll('.leaderboard-tab').forEach(t => t.classList.remove('active')); document.querySelectorAll('.leaderboard-content').forEach(c => c.style.display = 'none'); event.target.classList.add('active'); document.getElementById(`${tab}-content`).style.display = 'block'; } function updateLeaderboard() { updateRankings(); updateAchievements(); updateTimeline(); } function updateRankings() { const rankingsList = document.getElementById('rankingsList'); // Sort users by total score const sortedUsers = Object.entries(userStats) .sort((a, b) => b[1].totalScore - a[1].totalScore) .slice(0, 10); // Top 10 if (sortedUsers.length === 0) { rankingsList.innerHTML = '

No contributors yet!

'; return; } rankingsList.innerHTML = sortedUsers.map(([username, stats], index) => { const rank = index + 1; const rankClass = rank <= 3 ? `rank-${rank}` : ''; const rankEmoji = rank === 1 ? '🥇' : rank === 2 ? '🥈' : rank === 3 ? '🥉' : `#${rank}`; return `
${rankEmoji}
${username}
📤 ${stats.submissions} submissions ✅ ${stats.verifiedLeaks} verified 🎯 ${stats.firstDiscoveries} first discoveries
${stats.totalScore} pts
`; }).join(''); } function updateAchievements() { const achievementsList = document.getElementById('achievementsList'); const unlockedAchievements = displayAchievements(localStorage.getItem('currentUser')); if (unlockedAchievements.length === 0) { achievementsList.innerHTML = '

No achievements yet!

'; return; } achievementsList.innerHTML = unlockedAchievements.map(achievement => `
${achievement.icon}
${achievement.name}

${achievement.description}

`).join(''); } function updateTimeline() { const timelineList = document.getElementById('timelineList'); // Get significant events const events = []; // First discoveries const instanceFirsts = {}; leakDatabase.forEach(sub => { if (sub.isFirstDiscovery && !instanceFirsts[sub.instance]) { instanceFirsts[sub.instance] = { user: sub.source, date: sub.timestamp, instance: sub.instance }; } }); Object.values(instanceFirsts).forEach(event => { events.push({ date: event.date, type: 'discovery', text: `${event.user} discovered the first ${event.instance} leak` }); }); // Verification milestones leakDatabase.forEach(sub => { if (sub.confidence >= 95 && sub.wasVerified) { events.push({ date: sub.timestamp, type: 'verification', text: `${sub.instance} leak verified by ${sub.source}` }); } }); // Sort by date events.sort((a, b) => new Date(b.date) - new Date(a.date)); if (events.length === 0) { timelineList.innerHTML = '

No events yet!

'; return; } timelineList.innerHTML = events.slice(0, 20).map(event => `
${new Date(event.date).toLocaleString()}
${event.text}
`).join(''); } // Requests & Challenges functions function toggleRequests() { const overlay = document.getElementById('requestsOverlay'); overlay.style.display = overlay.style.display === 'none' ? 'block' : 'none'; if (overlay.style.display === 'block') { updateRequestsList(); } } function initializeDailyChallenge() { const now = new Date(); const tomorrow = new Date(now); tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setHours(0, 0, 0, 0); if (!dailyChallenge || new Date(dailyChallenge.expires) < now) { // Create new daily challenge const challenges = [ { model: 'GPT-4 Turbo', reward: 500 }, { model: 'Claude 3 Opus', reward: 600 }, { model: 'Gemini Ultra', reward: 700 }, { model: 'Llama 3', reward: 400 }, { model: 'Mistral Large', reward: 450 } ]; const randomChallenge = challenges[Math.floor(Math.random() * challenges.length)]; dailyChallenge = { model: randomChallenge.model, reward: randomChallenge.reward, expires: tomorrow.toISOString(), completedBy: [] }; saveDatabase(); } document.getElementById('challengeDescription').textContent = `Find and verify a system prompt from ${dailyChallenge.model}!`; } function startChallengeTimer() { setInterval(updateChallengeTimer, 1000); updateChallengeTimer(); } function updateChallengeTimer() { if (!dailyChallenge) return; const now = new Date(); const expires = new Date(dailyChallenge.expires); const diff = expires - now; if (diff <= 0) { initializeDailyChallenge(); return; } const hours = Math.floor(diff / (1000 * 60 * 60)); const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((diff % (1000 * 60)) / 1000); document.getElementById('challengeTimer').textContent = `Time remaining: ${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; } function submitRequest(event) { event.preventDefault(); const currentUser = prompt('Enter your username to submit this request:'); if (!currentUser) return; const request = { id: Date.now().toString(), targetType: document.getElementById('requestTargetType').value, model: document.getElementById('requestModel').value, targetUrl: document.getElementById('requestUrl').value || null, requiresLogin: document.getElementById('requestRequiresLogin').checked, requiresPaid: document.getElementById('requestRequiresPaid').checked, description: document.getElementById('requestDescription').value, bounty: parseInt(document.getElementById('requestBounty').value) || 0, requestedBy: currentUser, timestamp: new Date().toISOString(), votes: 0, voters: [], status: 'open' }; leakRequests.push(request); saveDatabase().then(() => { updateRequestsList(); // Clear form document.getElementById('requestModel').value = ''; document.getElementById('requestDescription').value = ''; document.getElementById('requestBounty').value = ''; showAlert('Request submitted successfully!'); }); } function updateRequestsList() { const requestsList = document.getElementById('requestsList'); const filterType = document.querySelector('.filter-tab.active')?.textContent.includes('Trending') ? 'trending' : document.querySelector('.filter-tab.active')?.textContent.includes('Bounty') ? 'bounty' : document.querySelector('.filter-tab.active')?.textContent.includes('Newest') ? 'new' : 'myvotes'; let filteredRequests = [...leakRequests]; // Apply filters switch(filterType) { case 'trending': filteredRequests.sort((a, b) => b.votes - a.votes); break; case 'bounty': filteredRequests.sort((a, b) => b.bounty - a.bounty); break; case 'new': filteredRequests.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp)); break; case 'myvotes': const currentUser = localStorage.getItem('currentUser'); if (currentUser && userVotes[currentUser]) { filteredRequests = filteredRequests.filter(req => userVotes[currentUser].includes(req.id)); } break; } if (filteredRequests.length === 0) { requestsList.innerHTML = '

No requests found.

'; return; } requestsList.innerHTML = filteredRequests.slice(0, 10).map(request => { const currentUser = localStorage.getItem('currentUser'); const hasVoted = currentUser && userVotes[currentUser] && userVotes[currentUser].includes(request.id); const isTrending = request.votes > 5; const targetType = request.targetType || 'model'; const typeEmoji = { 'model': '🤖 ', 'app': '📱 ', 'tool': '🔧 ', 'agent': '🤝 ', 'plugin': '🔌 ', 'custom': '🛠️ ' }[targetType] || '📄 '; // Access indicators const accessInfo = []; if (request.requiresLogin) accessInfo.push('🔒'); if (request.requiresPaid) accessInfo.push('💰'); const accessString = accessInfo.length > 0 ? ` ${accessInfo.join(' ')}` : ''; const linkIcon = request.targetUrl ? `🔗` : ''; return `
${typeEmoji} ${request.model}${accessString}${linkIcon}
${isTrending ? '🔥 Trending' : ''} ${request.votes} votes
${request.description ? `

${request.description}

` : ''}
Requested by ${request.requestedBy} ${request.bounty > 0 ? `+${request.bounty} bounty` : ''}
`; }).join(''); } function voteForRequest(requestId) { const currentUser = prompt('Enter your username to vote:'); if (!currentUser) return; localStorage.setItem('currentUser', currentUser); if (!userVotes[currentUser]) { userVotes[currentUser] = []; } const request = leakRequests.find(r => r.id === requestId); if (!request) return; if (userVotes[currentUser].includes(requestId)) { // Remove vote userVotes[currentUser] = userVotes[currentUser].filter(id => id !== requestId); request.votes--; request.voters = request.voters.filter(v => v !== currentUser); } else { // Add vote userVotes[currentUser].push(requestId); request.votes++; request.voters.push(currentUser); } saveDatabase(); updateRequestsList(); } function filterRequests(type) { document.querySelectorAll('.filter-tab').forEach(tab => tab.classList.remove('active')); event.target.classList.add('active'); updateRequestsList(); } // Check for daily challenge completion function checkDailyChallengeCompletion(submission) { if (!dailyChallenge || dailyChallenge.completedBy.includes(submission.source)) return; if (submission.instance === dailyChallenge.model && submission.confidence >= 90) { // Challenge completed! dailyChallenge.completedBy.push(submission.source); if (!userStats[submission.source]) { userStats[submission.source] = { submissions: 0, verifiedLeaks: 0, firstDiscoveries: 0, totalScore: 0, joinDate: new Date().toISOString(), dailyChallenges: 0 }; } userStats[submission.source].totalScore += dailyChallenge.reward; userStats[submission.source].dailyChallenges = (userStats[submission.source].dailyChallenges || 0) + 1; saveDatabase().then(() => { showAlert(`🎯 Daily Challenge Completed! +${dailyChallenge.reward} points!`); }); } } // Advanced AI-Powered Similarity Detection function advancedSimilarityAnalysis(text1, text2) { const analysis = { semantic: calculateSemanticSimilarity(text1, text2), structural: calculateStructuralSimilarity(text1, text2), pattern: detectCommonPatterns(text1, text2), keyword: analyzeKeywordOverlap(text1, text2), confidence: 0 }; // Calculate overall confidence based on all metrics analysis.confidence = ( analysis.semantic * 0.4 + analysis.structural * 0.3 + analysis.pattern * 0.2 + analysis.keyword * 0.1 ); return analysis; } function calculateSemanticSimilarity(text1, text2) { // Normalize and tokenize const tokens1 = text1.toLowerCase().replace(/[^\w\s]/g, ' ').split(/\s+/).filter(t => t.length > 2); const tokens2 = text2.toLowerCase().replace(/[^\w\s]/g, ' ').split(/\s+/).filter(t => t.length > 2); // Calculate Jaccard similarity const set1 = new Set(tokens1); const set2 = new Set(tokens2); const intersection = new Set([...set1].filter(x => set2.has(x))); const union = new Set([...set1, ...set2]); return intersection.size / union.size; } function calculateStructuralSimilarity(text1, text2) { // Analyze sentence structure and formatting const lines1 = text1.split('\n').filter(line => line.trim().length > 0); const lines2 = text2.split('\n').filter(line => line.trim().length > 0); // Compare line count and average line length const avgLength1 = lines1.reduce((sum, line) => sum + line.length, 0) / lines1.length; const avgLength2 = lines2.reduce((sum, line) => sum + line.length, 0) / lines2.length; const lengthSimilarity = 1 - Math.abs(avgLength1 - avgLength2) / Math.max(avgLength1, avgLength2); const countSimilarity = 1 - Math.abs(lines1.length - lines2.length) / Math.max(lines1.length, lines2.length); return (lengthSimilarity + countSimilarity) / 2; } function detectCommonPatterns(text1, text2) { const patterns = []; // Detect common phrases (3+ words) const words1 = text1.toLowerCase().split(/\s+/); const words2 = text2.toLowerCase().split(/\s+/); for (let i = 0; i <= words1.length - 3; i++) { for (let j = 0; j <= words2.length - 3; j++) { const phrase1 = words1.slice(i, i + 3).join(' '); const phrase2 = words2.slice(j, j + 3).join(' '); if (phrase1 === phrase2 && phrase1.length > 10) { patterns.push(phrase1); } } } // Calculate pattern density const totalWords = Math.min(words1.length, words2.length); return patterns.length / Math.max(totalWords / 10, 1); } function analyzeKeywordOverlap(text1, text2) { // Define AI-related keywords const aiKeywords = [ 'system', 'prompt', 'assistant', 'user', 'context', 'instruction', 'behavior', 'response', 'format', 'output', 'input', 'model', 'ai', 'artificial', 'intelligence', 'language', 'processing', 'generate', 'analyze', 'provide', 'help', 'support', 'guide' ]; const text1Lower = text1.toLowerCase(); const text2Lower = text2.toLowerCase(); let overlap = 0; aiKeywords.forEach(keyword => { if (text1Lower.includes(keyword) && text2Lower.includes(keyword)) { overlap++; } }); return overlap / aiKeywords.length; } // Enhanced comparison function function performAdvancedComparison() { const submission1Id = document.getElementById('submission1').value; const submission2Id = document.getElementById('submission2').value; if (!submission1Id || !submission2Id) { showAlert('Please select two submissions to compare.'); return; } const submission1 = leakDatabase.find(s => s.id === submission1Id); const submission2 = leakDatabase.find(s => s.id === submission2Id); if (!submission1 || !submission2) { showAlert('Selected submissions not found.'); return; } // Perform advanced analysis const advancedAnalysis = advancedSimilarityAnalysis(submission1.content, submission2.content); // Update comparison results const resultsDiv = document.getElementById('comparisonResults'); resultsDiv.innerHTML = `

🤖 Advanced AI Analysis Results

${Math.round(advancedAnalysis.confidence * 100)}% Match

🧠 Semantic Similarity

${Math.round(advancedAnalysis.semantic * 100)}%

Meaning and context similarity

🏗️ Structural Similarity

${Math.round(advancedAnalysis.structural * 100)}%

Format and organization similarity

🔍 Pattern Detection

${Math.round(advancedAnalysis.pattern * 100)}%

Common phrase and pattern density

🎯 Keyword Overlap

${Math.round(advancedAnalysis.keyword * 100)}%

AI-related terminology overlap

🔍 Verification Recommendation

${advancedAnalysis.confidence > 0.8 ? '✅ HIGH CONFIDENCE - Strong evidence of similarity' : advancedAnalysis.confidence > 0.6 ? '⚠️ MODERATE CONFIDENCE - Some similarities detected' : '❌ LOW CONFIDENCE - Minimal similarity detected'}

`; // Auto-boost confidence if high similarity if (advancedAnalysis.confidence > 0.7) { submission1.confidence = Math.min(100, submission1.confidence + 20); submission2.confidence = Math.min(100, submission2.confidence + 20); saveDatabase().then(() => { updateUI(); showAlert('High similarity detected! Confidence scores automatically boosted! 🚀'); }); } } // Dynamic Achievement System function checkAchievements(username) { if (!userStats[username]) return; const stats = userStats[username]; const newAchievements = []; // Check each achievement Object.values(achievements).forEach(achievement => { if (userAchievements[username] && userAchievements[username].includes(achievement.id)) return; let unlocked = false; switch (achievement.id) { case 'firstBlood': unlocked = stats.submissions >= 1; break; case 'discoverer': unlocked = stats.firstDiscoveries >= 1; break; case 'verifier': unlocked = stats.verifiedLeaks >= 5; break; case 'collector': unlocked = stats.submissions >= 10; break; case 'expert': unlocked = stats.totalScore >= 1000; break; case 'pioneer': unlocked = stats.firstDiscoveries >= 5; break; case 'analyst': unlocked = (stats.comparisons || 0) >= 20; break; case 'challenger': unlocked = (stats.challengesCompleted || 0) >= 5; break; case 'community': unlocked = (stats.requestsSubmitted || 0) >= 10; break; case 'legend': unlocked = Object.keys(achievements).every(id => userAchievements[username] && userAchievements[username].includes(id) ); break; } if (unlocked) { if (!userAchievements[username]) userAchievements[username] = []; userAchievements[username].push(achievement.id); newAchievements.push(achievement); // Award points stats.totalScore += achievement.points; // Show achievement notification showAchievementNotification(achievement); } }); if (newAchievements.length > 0) { saveDatabase(); updateUI(); } } function showAchievementNotification(achievement) { const notification = document.createElement('div'); notification.className = 'achievement-notification'; notification.innerHTML = `
${achievement.icon}

🏆 Achievement Unlocked!

${achievement.name}

${achievement.description}

+${achievement.points} points
`; document.body.appendChild(notification); // Animate in setTimeout(() => notification.classList.add('show'), 100); // Remove after 5 seconds setTimeout(() => { notification.classList.remove('show'); setTimeout(() => document.body.removeChild(notification), 500); }, 5000); } function displayAchievements(username) { if (!userAchievements[username]) return []; return userAchievements[username].map(id => achievements[id]).filter(Boolean); } // Enhanced user stats tracking function updateUserStats(username, action, data = {}) { if (!userStats[username]) { userStats[username] = { submissions: 0, verifiedLeaks: 0, firstDiscoveries: 0, totalScore: 0, joinDate: new Date().toISOString(), toolsDiscovered: 0, appsDiscovered: 0, agentsDiscovered: 0, comparisons: 0, challengesCompleted: 0, requestsSubmitted: 0 }; } switch (action) { case 'submission': userStats[username].submissions++; break; case 'firstDiscovery': userStats[username].firstDiscoveries++; break; case 'verification': userStats[username].verifiedLeaks++; break; case 'comparison': userStats[username].comparisons++; break; case 'challengeComplete': userStats[username].challengesCompleted++; break; case 'requestSubmitted': userStats[username].requestsSubmitted++; break; } // Check for new achievements checkAchievements(username); } // Chat System Functions let chatMessages = []; let onlineUsers = new Set(); let currentUser = null; function toggleChat() { const chatPanel = document.getElementById('chatPanel'); if (chatPanel.style.display === 'none') { chatPanel.style.display = 'block'; if (!currentUser) { currentUser = prompt('Enter your username for chat:'); if (currentUser) { onlineUsers.add(currentUser); updateOnlineUsers(); addChatMessage('system', `${currentUser} joined the chat!`); } } } else { chatPanel.style.display = 'none'; } } function sendChatMessage() { const input = document.getElementById('chatInput'); const message = input.value.trim(); if (message && currentUser) { addChatMessage('user', message, currentUser); input.value = ''; // Simulate responses for demo setTimeout(() => { const responses = [ 'Interesting discovery! 🔍', 'I\'ll help verify that! ✅', 'Great find! 🚀', 'Let me check the similarity...', 'This looks promising! 💡' ]; const randomResponse = responses[Math.floor(Math.random() * responses.length)]; addChatMessage('bot', randomResponse, 'LeakHub Bot'); }, 1000 + Math.random() * 2000); } } function addChatMessage(type, message, username = 'System') { const messagesDiv = document.getElementById('chatMessages'); const messageDiv = document.createElement('div'); messageDiv.className = `chat-message ${type}-message`; const timestamp = new Date().toLocaleTimeString(); messageDiv.innerHTML = `
${username} ${timestamp}
${message}
`; messagesDiv.appendChild(messageDiv); messagesDiv.scrollTop = messagesDiv.scrollHeight; // Keep only last 50 messages if (messagesDiv.children.length > 50) { messagesDiv.removeChild(messagesDiv.firstChild); } } function updateOnlineUsers() { const usersDiv = document.getElementById('chatUsers'); const countSpan = document.getElementById('onlineCount'); countSpan.textContent = onlineUsers.size; const usersList = Array.from(onlineUsers).map(user => `
🟢 ${user}
` ).join(''); usersDiv.innerHTML = `
🟢 Online: ${onlineUsers.size}
${usersList}
`; } // Initialize chat document.addEventListener('DOMContentLoaded', () => { const chatInput = document.getElementById('chatInput'); if (chatInput) { chatInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') { sendChatMessage(); } }); } });