mirror of
https://github.com/gapmiss/substack-clipper.git
synced 2026-07-22 07:48:24 +00:00
Compare commits
6 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2829630e7c | ||
|
|
7a885e6aa7 | ||
|
|
5070666786 | ||
|
|
ce476bb678 | ||
|
|
abd4235867 | ||
|
|
44d48b31ab |
6 changed files with 5272 additions and 5249 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "substack-clipper",
|
||||
"name": "Substack Clipper",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.12",
|
||||
"minAppVersion": "1.13.0",
|
||||
"description": "Archive Substack posts as Markdown with images, media, and comments.",
|
||||
"author": "@gapmiss",
|
||||
|
|
|
|||
10471
package-lock.json
generated
10471
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "substack-clipper",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.12",
|
||||
"description": "Clip substack articles",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
"esbuild": "^0.28.1",
|
||||
"eslint": "^9.30.1",
|
||||
"eslint-plugin-no-unsanitized": "^4.1.2",
|
||||
"eslint-plugin-obsidianmd": "^0.3.0",
|
||||
"eslint-plugin-obsidianmd": "^0.4.1",
|
||||
"globals": "^14.0.0",
|
||||
"jiti": "^2.6.1",
|
||||
"tslib": "^2.4.0",
|
||||
|
|
|
|||
|
|
@ -9,27 +9,16 @@ function isSubstackImageUrl(url: string): boolean {
|
|||
const VIDEO_PLACEHOLDER_RE = /VIDEOEMBED([a-f0-9-]{36})ENDVIDEO/g;
|
||||
|
||||
function replaceVideoDivs(html: string, downloadedUrls: Set<string>): string {
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(html, 'text/html');
|
||||
|
||||
for (const div of Array.from(doc.querySelectorAll('div[id^="media-"]'))) {
|
||||
const id = div.getAttribute('id') ?? '';
|
||||
if (id.length !== 42) continue;
|
||||
const videoId = id.replace('media-', '');
|
||||
const videoUrl = `https://substack.com/api/v1/video/upload/${videoId}/src`;
|
||||
const p = doc.createElement('p');
|
||||
if (downloadedUrls.has(videoUrl)) {
|
||||
p.textContent = `VIDEOEMBED${videoId}ENDVIDEO`;
|
||||
} else {
|
||||
const a = doc.createElement('a');
|
||||
a.href = videoUrl;
|
||||
a.textContent = 'Video';
|
||||
p.appendChild(a);
|
||||
return html.replace(
|
||||
/<div[^>]+id="media-([^"]{36})"[^>]*>[\s\S]*?<\/div>/g,
|
||||
(_match, videoId: string) => {
|
||||
const videoUrl = `https://substack.com/api/v1/video/upload/${videoId}/src`;
|
||||
if (downloadedUrls.has(videoUrl)) {
|
||||
return `<p>VIDEOEMBED${videoId}ENDVIDEO</p>`;
|
||||
}
|
||||
return `<p><a href="${videoUrl}">Video</a></p>`;
|
||||
}
|
||||
div.replaceWith(p);
|
||||
}
|
||||
|
||||
return doc.body.innerHTML;
|
||||
);
|
||||
}
|
||||
|
||||
function restoreVideoWikilinks(md: string): string {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ export class HistoryView extends ItemView {
|
|||
const header = this.listEl.createDiv({ cls: 'substack-clipper-history-header' });
|
||||
const selectAllCb = header.createEl('input', { type: 'checkbox' });
|
||||
selectAllCb.setAttribute('aria-label', 'Select all entries');
|
||||
header.createEl('span', {
|
||||
header.createSpan({
|
||||
text: `${String(entries.length)} ${entries.length === 1 ? 'entry' : 'entries'}`,
|
||||
cls: 'substack-clipper-history-count',
|
||||
});
|
||||
|
|
@ -151,19 +151,19 @@ export class HistoryView extends ItemView {
|
|||
});
|
||||
|
||||
const info = row.createDiv({ cls: 'substack-clipper-history-info' });
|
||||
info.createEl('span', { text: entry.title, cls: 'substack-clipper-history-title' });
|
||||
info.createSpan({ text: entry.title, cls: 'substack-clipper-history-title' });
|
||||
|
||||
const meta = info.createDiv({ cls: 'substack-clipper-history-meta' });
|
||||
const userLine = meta.createDiv({ cls: 'substack-clipper-history-userline' });
|
||||
userLine.createEl('span', { text: entry.username, cls: 'substack-clipper-history-username' });
|
||||
userLine.createSpan({ text: entry.username, cls: 'substack-clipper-history-username' });
|
||||
if (entry.commentCount > 0) {
|
||||
userLine.createEl('span', {
|
||||
userLine.createSpan({
|
||||
text: String(entry.commentCount),
|
||||
cls: 'substack-clipper-history-badge',
|
||||
});
|
||||
}
|
||||
|
||||
meta.createEl('span', {
|
||||
meta.createSpan({
|
||||
text: new Date(entry.dateSaved).toLocaleDateString(),
|
||||
cls: 'substack-clipper-history-date',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,5 +7,8 @@
|
|||
"0.1.6": "1.13.0",
|
||||
"0.1.7": "1.13.0",
|
||||
"0.1.8": "1.13.0",
|
||||
"0.1.9": "1.13.0"
|
||||
"0.1.9": "1.13.0",
|
||||
"0.1.10": "1.13.0",
|
||||
"0.1.11": "1.13.0",
|
||||
"0.1.12": "1.13.0"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue