-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
67 lines (54 loc) · 1.82 KB
/
index.html
File metadata and controls
67 lines (54 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>H1 Checker</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
textarea { width: 100%; height: 150px; }
button { padding: 10px 20px; font-size: 16px; }
.results { margin-top: 20px; }
.ok { color: green; }
.bad { color: red; }
</style>
</head>
<body>
<h2>URL H1 Checker</h2>
<p>Enter one URL per line:</p>
<textarea id="urls"></textarea><br><br>
<button onclick="checkUrls()">Check H1s</button>
<div class="results" id="results"></div>
<script>
async function checkUrls() {
const results = document.getElementById('results');
results.innerHTML = "Checking...<br><br>";
const urls = document.getElementById('urls')
.value
.split('\n')
.map(u => u.trim())
.filter(u => u);
for (const url of urls) {
results.innerHTML += `<strong>${url}</strong>: Checking...<br>`;
try {
const response = await fetch(`https://corsproxy.io/?${encodeURIComponent(url)}`);
if (!response.ok) {
results.innerHTML += `<span class="bad">❌ Error fetching page (${response.status})</span><br><br>`;
continue;
}
const text = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(text, "text/html");
const h1 = doc.querySelector('h1');
if (h1) {
results.innerHTML += `<span class="ok">✔️ H1 found:</span> "${h1.textContent.trim()}"<br><br>`;
} else {
results.innerHTML += `<span class="bad">❌ No H1 found</span><br><br>`;
}
} catch (err) {
results.innerHTML += `<span class="bad">❌ Failed to fetch or parse</span><br><br>`;
}
}
}
</script>
</body>
</html>