Skip to content

Commit

Permalink
Merge pull request #14 from hbz/20-description
Browse files Browse the repository at this point in the history
Prefer og:description over meta description
  • Loading branch information
literarymachine authored Mar 24, 2020
2 parents c3b462e + a40e587 commit 242a354
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "skohub-extension",
"version": "0.0.4",
"version": "0.0.5",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_extensionName__",
"short_name": "__MSG_extensionName__",
"version": "0.0.4",
"version": "0.0.5",
"default_locale": "en",

"description": "__MSG_extensionDescription__",
Expand Down
23 changes: 13 additions & 10 deletions src/page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* global chrome */
var attach = async () => {
const EDITOR_URL = 'https://test.skohub.io/editor/'
const EDITOR_URL = 'https://skohub.io/editor/'

const loadSavedOptions = new Promise((resolve, reject) => {
chrome.storage.local.get({ defaultSchema: null }, (options) => {
Expand All @@ -14,24 +14,27 @@ var attach = async () => {
defaultSchema && url.searchParams.set('schema', defaultSchema)

const getMetaTag = (attribute, value) => {
return (document.querySelector(`meta[${attribute}="${value}"]`) && document.querySelector(`meta[${attribute}="${value}"]`).content) || null
return (document.querySelector(`meta[${attribute}="${value}"]`) &&
document.querySelector(`meta[${attribute}="${value}"]`).content) || null
}

const pageGetData = () => {
return {
name: getMetaTag('property', 'og:title') ||
getMetaTag('name', 'twitter:title') ||
document.title,
id: getMetaTag('property', 'og:url') || window.location.href,
description: getMetaTag('name', 'description') ||
getMetaTag('property', 'og:description') ||
getMetaTag('name', 'twitter:description'),
getMetaTag('name', 'twitter:title') ||
document.title,
id: getMetaTag('property', 'og:url') ||
window.location.href,
description: getMetaTag('property', 'og:description') ||
getMetaTag('name', 'twitter:description') ||
getMetaTag('name', 'description'),
keywords: getMetaTag('name', 'keywords'),
author: getMetaTag('name', 'author'),
image: getMetaTag('property', 'og:image') ||
getMetaTag('name', 'twitter:image'),
getMetaTag('name', 'twitter:image'),
locale: getMetaTag('property', 'og:locale'),
type: getMetaTag('property', 'og:type') || 'CreativeWork'
type: getMetaTag('property', 'og:type')
|| 'CreativeWork'
}
}

Expand Down

0 comments on commit 242a354

Please sign in to comment.