-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookmarklet.js
More file actions
44 lines (40 loc) · 1.39 KB
/
bookmarklet.js
File metadata and controls
44 lines (40 loc) · 1.39 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
/**
* substack-opml-export
* Exports your Substack subscriptions as an OPML file.
*
* Run this in your browser console at substack.com while logged in.
* The OPML file will download automatically.
*
* Last verified working: April 2026
*/
fetch('/api/v1/subscriptions')
.then(r => r.json())
.then(d => {
const feeds = d.publications.map(p => {
const base = p.custom_domain
? `https://${p.custom_domain}`
: `https://${p.subdomain}.substack.com`;
return ` <outline type="rss" text="${p.name.replace(/"/g, '"')}" title="${p.name.replace(/"/g, '"')}" htmlUrl="${base}" xmlUrl="${base}/feed" />`;
});
const opml = [
'<?xml version="1.0" encoding="UTF-8"?>',
'<opml version="2.0">',
'<body>',
' <outline text="Substack" title="Substack">',
...feeds,
' </outline>',
'</body>',
'</opml>'
].join('\n');
const a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([opml], { type: 'application/xml' }));
a.download = 'substack-subscriptions.opml';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
console.log(`Downloaded OPML with ${d.publications.length} subscriptions.`);
})
.catch(err => {
console.error('Export failed:', err);
console.error('Make sure you are logged in at substack.com and run this script from that tab.');
});