diff --git a/contents/read.ts b/contents/read.ts index 689c16d..ff76850 100644 --- a/contents/read.ts +++ b/contents/read.ts @@ -1,5 +1,15 @@ const getTitle = () => { const title = document.title; + const metaTitle = document.querySelector(`meta[name="title"]`); + const metaOgTitle = document.querySelector(`meta[name="og:title"]`); + + if (metaOgTitle) { + return metaOgTitle.getAttribute("content");; + } + + if (metaTitle) { + return metaTitle.getAttribute("content");; + } if (title.includes(" - ")) { const end = title.lastIndexOf(" - "); @@ -47,7 +57,7 @@ const getFrom = () => { const getAuthor = () => { const metaAuthor = document.querySelector(`meta[name="author"]`); const metaOgAuthor = document.querySelector(`meta[property="og:article:author"]`); - const itemPropAuthor = document.querySelector(`[itemprop="author"] meta[itemprop="name"]`); + const itemPropAuthor = document.querySelector(`[itemprop="author"] [itemprop="name"]`); if (metaAuthor) { return metaAuthor.getAttribute("content"); @@ -98,8 +108,13 @@ const getSiteName = () => { } const getTags = () => { + const metaKeywords = document.querySelector(`meta[name="keywords"]`); const itemPropKeywords = document.querySelector(`meta[itemprop="keywords"]`); + if (metaKeywords) { + return metaKeywords.getAttribute("content"); + } + if (itemPropKeywords) { return itemPropKeywords.getAttribute("content"); }