fixing youtube because apparently my life is pain
This commit is contained in:
parent
d316dfd01e
commit
4e8103b692
2 changed files with 11 additions and 5 deletions
|
@ -16,7 +16,7 @@ moffsoft icon to indicate that additional autofill is available.
|
||||||
- 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.
|
||||||
- Youtube: Title, author, and date published fields are autofilled from the `watch7-content` metadata.
|
- 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`
|
- 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.
|
triggers the supported site badge, but other Forgejo instances should work too.
|
||||||
|
|
||||||
|
|
14
popup.js
14
popup.js
|
@ -11,14 +11,20 @@ function parsePage() {
|
||||||
entry.url = entry.url.replace('https://freedium.cfd/', '');
|
entry.url = entry.url.replace('https://freedium.cfd/', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// if schema.org NewsArticle JSON-LD is present, read that data
|
// if schema.org JSON-LD is present, read that data
|
||||||
const jsonLDElem = document.querySelector('script[type="application/ld+json"]');
|
const jsonLDElem = document.querySelector('script[type="application/ld+json"]');
|
||||||
if (jsonLDElem) {
|
if (jsonLDElem) {
|
||||||
const jsonLDObj = JSON.parse(jsonLDElem.textContent);
|
const jsonLDObj = JSON.parse(jsonLDElem.textContent);
|
||||||
if (jsonLDObj['@type'] == 'NewsArticle') {
|
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;
|
||||||
entry.title = jsonLDObj.headline
|
entry.title = jsonLDObj.headline;
|
||||||
|
}
|
||||||
|
if (jsonLDObj['@type'] == 'VideoObject') { // youtube, etc.
|
||||||
|
entry.url = jsonLDObj['@id']; // url fix
|
||||||
|
entry.publishedDate = jsonLDObj.uploadDate?.slice(0, 19);
|
||||||
|
entry.author = jsonLDObj.author;
|
||||||
|
entry.title = jsonLDObj.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue