fixing up NewsArticle a tiny bit to add substack support

This commit is contained in:
Kebo 2025-06-23 11:25:35 -05:00
parent 4e8103b692
commit 05a771d337
3 changed files with 9 additions and 5 deletions

View file

@ -13,12 +13,15 @@ You can technically use this extension on *any* site, as it will always automati
However, I've built in additional autofill support for certain websites. When you visit one of these sites, a badge will appear on the
moffsoft icon to indicate that additional autofill is available.
- Forgejo instances (except codeberg for now ;3;): Title and author fields are autofilled from metadata. Currently, only `git.eleboog.com`
triggers the supported site badge, but other Forgejo instances should work too.
- GitHub: Title and author fields are autofilled from scraping the page.
- Medium: Title, author, and date published fields are autofilled from the handy [`NewsArticle` JSON-LD schema](https://schema.org/NewsArticle)
included on every page.
- Substack: Title, author, and date published fields are autofilled form the handy [`NewsArticle` JSON-LD schema](https://schema.org/NewsArticle)
included on every page. The supported site badge may not show for custom domains (i.e. not a `*.substack.com` url), but autofill
should still work.
- Youtube: Title, author, and date published fields are autofilled from either the `watch7-content` metadata or the [`VideoObject` JSON-LD schema](https://schema.org/VideoObject).
- Forgejo instances (except codeberg for now ;3;): Title and author fields are autofilled from metadata. Currently, only `git.eleboog.com`
triggers the supported site badge, but other Forgejo instances should work too.
## Wait, what is this even for?

View file

@ -16,13 +16,13 @@ function parsePage() {
if (jsonLDElem) {
const jsonLDObj = JSON.parse(jsonLDElem.textContent);
if (jsonLDObj['@type'] == 'NewsArticle') { // medium, etc.
entry.publishedDate = jsonLDObj.datePublished?.slice(0, 19);
entry.author = jsonLDObj.author?.name;
entry.publishedDate = jsonLDObj.datePublished.slice(0, 19);
entry.author = jsonLDObj.author.name ?? jsonLDObj.author[0].name;
entry.title = jsonLDObj.headline;
}
if (jsonLDObj['@type'] == 'VideoObject') { // youtube, etc.
entry.url = jsonLDObj['@id']; // url fix
entry.publishedDate = jsonLDObj.uploadDate?.slice(0, 19);
entry.publishedDate = jsonLDObj.uploadDate.slice(0, 19);
entry.author = jsonLDObj.author;
entry.title = jsonLDObj.name;
}

View file

@ -8,6 +8,7 @@ chrome.tabs.onActivated.addListener((activeInfo) => {
'youtube.com',
'github.com',
'git.eleboog.com',
'substack.com'
];
let supportedSite = false;