This commit is contained in:
2025-07-20 20:43:06 +02:00
parent 0abee5b794
commit 29592c7fc8
93 changed files with 23400 additions and 131 deletions

View File

@ -0,0 +1,125 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Link Testing Debug</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.test-result { margin: 10px 0; padding: 10px; border-radius: 5px; }
.success { background-color: #d4edda; border: 1px solid #c3e6cb; }
.error { background-color: #f8d7da; border: 1px solid #f5c6cb; }
.info { background-color: #d1ecf1; border: 1px solid #bee5eb; }
</style>
</head>
<body>
<h1>Link Testing Debug</h1>
<p>This page will test a few common URLs to see if the link testing logic is working correctly.</p>
<button onclick="testLinks()">Test Sample Links</button>
<div id="results"></div>
<script>
const testUrls = [
'https://www.google.com',
'https://github.com',
'https://stackoverflow.com',
'https://www.wikipedia.org',
'https://invalid-url-that-should-fail.nonexistent'
];
async function testSingleLink(url) {
try {
console.log(`Testing: ${url}`);
// Create abort controller for timeout
const controller = new AbortController();
const timeoutId = setTimeout(() => {
controller.abort();
}, 10000); // 10 second timeout
// Perform the HTTP request
const response = await fetch(url, {
method: 'HEAD',
mode: 'no-cors',
signal: controller.signal,
cache: 'no-cache',
headers: {
'User-Agent': 'Mozilla/5.0 (compatible; BookmarkTester/1.0)'
}
});
clearTimeout(timeoutId);
// Analyze response
if (response.ok || response.type === 'opaque') {
return {
url: url,
status: 'valid',
responseType: response.type,
httpStatus: response.status || 'opaque',
error: null
};
} else {
return {
url: url,
status: 'invalid',
responseType: response.type,
httpStatus: response.status,
error: `HTTP ${response.status} ${response.statusText}`
};
}
} catch (error) {
return {
url: url,
status: 'invalid',
responseType: 'error',
httpStatus: null,
error: error.message
};
}
}
async function testLinks() {
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '<div class="info">Testing links...</div>';
const results = [];
for (const url of testUrls) {
const result = await testSingleLink(url);
results.push(result);
// Update UI with each result
const resultDiv = document.createElement('div');
resultDiv.className = `test-result ${result.status === 'valid' ? 'success' : 'error'}`;
resultDiv.innerHTML = `
<strong>${url}</strong><br>
Status: ${result.status}<br>
Response Type: ${result.responseType}<br>
HTTP Status: ${result.httpStatus}<br>
${result.error ? `Error: ${result.error}` : ''}
`;
resultsDiv.appendChild(resultDiv);
}
// Summary
const validCount = results.filter(r => r.status === 'valid').length;
const invalidCount = results.filter(r => r.status === 'invalid').length;
const summaryDiv = document.createElement('div');
summaryDiv.className = 'test-result info';
summaryDiv.innerHTML = `
<strong>Summary:</strong><br>
Valid: ${validCount}<br>
Invalid: ${invalidCount}<br>
Total: ${results.length}
`;
resultsDiv.appendChild(summaryDiv);
console.log('Test Results:', results);
}
</script>
</body>
</html>