-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulk-rss-finder.html
More file actions
136 lines (122 loc) · 4.36 KB
/
bulk-rss-finder.html
File metadata and controls
136 lines (122 loc) · 4.36 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bulk Feed Finder | tools.eliana.lol</title>
<link rel="stylesheet" href="global.css" />
<link rel="icon" type="image/x-icon" href="favicon.svg" />
<style>
/* Specific tweaks for this tool's results */
.feed-result {
border-left: 3px solid var(--text);
padding-left: 15px;
margin-top: 20px;
margin-bottom: 20px;
}
.feed-item {
margin: 8px 0;
display: block;
}
</style>
</head>
<body>
<nav>
<div class="left">
<a href="index.html">home</a> | <a href="extra.html">extra</a> |
<a href="credits.html">credits</a> |
<a href="changelog.html">logs</a>
</div>
<div class="right">
<button id="theme-toggle">[theme]</button> |
<a href="https://eliana.lol">site</a>
</div>
</nav>
<main>
<h1>Bulk Feed Finder</h1>
<p class="puny">Enter URLs (one per line) to sniff out RSS/Atom feeds.</p>
<textarea
id="urlInput"
rows="8"
placeholder="j3s.sh eliana.lol"
></textarea>
<div class="tool-actions">
<button id="findBtn">Find Feeds</button>
<button id="clearBtn">Clear</button>
</div>
<div id="results"></div>
</main>
<script>
const html = document.documentElement;
const toggle = document.getElementById('theme-toggle');
const saved =
localStorage.getItem('theme') ||
(window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light');
html.setAttribute('data-theme', saved);
if (toggle) toggle.innerText = saved === 'dark' ? '[light]' : '[dark]';
if (toggle) {
toggle.onclick = () => {
const now = html.getAttribute('data-theme');
const next = now === 'dark' ? 'light' : 'dark';
html.setAttribute('data-theme', next);
localStorage.setItem('theme', next);
toggle.innerText = next === 'dark' ? '[light]' : '[dark]';
};
}
</script>
<script type="module">
import { findRssFeeds } from 'https://esm.sh/rss-agent-discovery@0.1.6';
const resultsDiv = document.getElementById('results');
document.getElementById('findBtn').onclick = async () => {
const input = document.getElementById('urlInput').value.trim();
if (!input) return;
const urls = input.split('\n').filter((u) => u.trim());
resultsDiv.innerHTML = '<p class="puny">Processing...</p>';
for (let url of urls) {
if (!/^https?:\/\//i.test(url)) url = 'https://' + url;
const container = document.createElement('div');
container.className = 'feed-result';
container.innerHTML = `<strong>${url}</strong>`;
resultsDiv.appendChild(container);
try {
const discovered = await findRssFeeds(url, {
fetcher: async (u) => {
// Using AllOrigins to bypass CORS
const p = `https://api.allorigins.win/get?url=${encodeURIComponent(u)}`;
const r = await fetch(p);
const d = await r.json();
return d.contents;
},
});
if (!discovered.length) {
container.innerHTML += `<div class="puny">No feeds found.</div>`;
} else {
discovered.forEach((f) => {
const link = document.createElement('a');
link.href = f.url;
link.className = 'feed-item';
link.innerHTML = `> ${f.title || 'Feed'} <span class="puny">(${f.type || 'XML'})</span>`;
container.appendChild(link);
});
}
} catch (e) {
container.innerHTML += `<div class="puny">Error connecting to site.</div>`;
}
}
// Remove the "Processing" text once done
if (
resultsDiv.firstChild &&
resultsDiv.firstChild.textContent === 'Processing...'
) {
resultsDiv.removeChild(resultsDiv.firstChild);
}
};
document.getElementById('clearBtn').onclick = () => {
document.getElementById('urlInput').value = '';
resultsDiv.innerHTML = '';
};
</script>
</body>
</html>