fixing up NewsArticle a tiny bit to add substack support
This commit is contained in:
parent
4e8103b692
commit
05a771d337
3 changed files with 9 additions and 5 deletions
|
@ -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
|
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.
|
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.
|
- 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)
|
- Medium: Title, author, and date published fields are autofilled from the handy [`NewsArticle` JSON-LD schema](https://schema.org/NewsArticle)
|
||||||
included on every page.
|
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).
|
- 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?
|
## Wait, what is this even for?
|
||||||
|
|
||||||
|
|
6
popup.js
6
popup.js
|
@ -16,13 +16,13 @@ function parsePage() {
|
||||||
if (jsonLDElem) {
|
if (jsonLDElem) {
|
||||||
const jsonLDObj = JSON.parse(jsonLDElem.textContent);
|
const jsonLDObj = JSON.parse(jsonLDElem.textContent);
|
||||||
if (jsonLDObj['@type'] == 'NewsArticle') { // medium, etc.
|
if (jsonLDObj['@type'] == 'NewsArticle') { // medium, etc.
|
||||||
entry.publishedDate = jsonLDObj.datePublished?.slice(0, 19);
|
entry.publishedDate = jsonLDObj.datePublished.slice(0, 19);
|
||||||
entry.author = jsonLDObj.author?.name;
|
entry.author = jsonLDObj.author.name ?? jsonLDObj.author[0].name;
|
||||||
entry.title = jsonLDObj.headline;
|
entry.title = jsonLDObj.headline;
|
||||||
}
|
}
|
||||||
if (jsonLDObj['@type'] == 'VideoObject') { // youtube, etc.
|
if (jsonLDObj['@type'] == 'VideoObject') { // youtube, etc.
|
||||||
entry.url = jsonLDObj['@id']; // url fix
|
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.author = jsonLDObj.author;
|
||||||
entry.title = jsonLDObj.name;
|
entry.title = jsonLDObj.name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ chrome.tabs.onActivated.addListener((activeInfo) => {
|
||||||
'youtube.com',
|
'youtube.com',
|
||||||
'github.com',
|
'github.com',
|
||||||
'git.eleboog.com',
|
'git.eleboog.com',
|
||||||
|
'substack.com'
|
||||||
];
|
];
|
||||||
|
|
||||||
let supportedSite = false;
|
let supportedSite = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue