From c495ac029dad1761cf23e7a4d7a46f40b54ea4e0 Mon Sep 17 00:00:00 2001 From: Thaddeus Hetling <158094684+EruditeLying@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:17:26 +0100 Subject: [PATCH] Support Substack with a custom domain Remove the substack.com domain from the target regex to support Substacks with a custom domain In detectWeb, manually check for the old target regex first, then for one of the Substack footer buttons in the page DOM. If neither matches, return false --- Substack.js | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/Substack.js b/Substack.js index ec000939046..f1401cecde1 100644 --- a/Substack.js +++ b/Substack.js @@ -2,14 +2,14 @@ "translatorID": "ac3b958f-0581-4117-bebc-44af3b876545", "label": "Substack", "creator": "Abe Jellinek", - "target": "^https://[^.]+\\.substack\\.com/(p/|archive)", + "target": "/p/|/archive", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2022-10-05 15:16:38" + "lastUpdated": "2024-01-29 20:12:55" } /* @@ -37,6 +37,8 @@ function detectWeb(doc, url) { + if (!url.match(/^https:\/\/[^.]+\.substack\.com\/(p\/|archive)/) && !text(doc, "a.footer-substack-cta")) + return false; if (url.includes('/p/')) { return "blogPost"; } @@ -49,7 +51,7 @@ function detectWeb(doc, url) { function getSearchResults(doc, checkOnly) { var items = {}; var found = false; - var rows = doc.querySelectorAll('a.post-preview-title[href*="/p/"]'); + var rows = doc.querySelectorAll('a[data-testid="post-preview-title"][href*="/p/"]'); for (let row of rows) { let href = row.href; let title = ZU.trimInternal(row.textContent); @@ -225,6 +227,37 @@ var testCases = [ "seeAlso": [] } ] + }, + { + "type": "web", + "url": "https://www.latent.space/p/ai-ux-moat", + "items": [ + { + "itemType": "blogPost", + "title": "How to Make AI UX Your Moat", + "creators": [ + { + "firstName": "Anshul", + "lastName": "Ramachandran", + "creatorType": "author" + } + ], + "date": "2023-07-07", + "abstractNote": "Design great AI Products that go beyond \"just LLM Wrappers\": make AI more present, more practical, and then more powerful.", + "blogTitle": "Latent Space", + "url": "https://www.latent.space/p/ai-ux-moat", + "websiteType": "Substack newsletter", + "attachments": [ + { + "title": "Snapshot", + "mimeType": "text/html" + } + ], + "tags": [], + "notes": [], + "seeAlso": [] + } + ] } ] /** END TEST CASES **/