diff --git a/README.md b/README.md index 5bfca67..b4afe7f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ moffsoft icon to indicate that additional autofill is available. - Medium: Title, author, and date published fields are autofilled from the handy [`NewsArticle` JSON-LD schema](https://schema.org/NewsArticle) included on every page. - Youtube: Title, author, and date published fields are autofilled from the `watch7-content` metadata. +- 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? diff --git a/popup.js b/popup.js index 85c4270..37634e8 100644 --- a/popup.js +++ b/popup.js @@ -42,6 +42,13 @@ function parsePage() { entry.author = document.querySelector('a[rel="author"]').textContent.slice(9); } + // forgejo meta elements + const forgejoIdentElem = document.querySelector('meta[name="keywords"]'); + if (forgejoIdentElem && forgejoIdentElem.content.includes('forgejo')) { + entry.title = document.querySelector('meta[name="description"]').content; + entry.author = document.querySelector('meta[name="author"]').content; + } + return entry; } @@ -87,6 +94,8 @@ function generateJSON(event) { const errorElem = document.getElementById('error'); const JSONElem = document.getElementById('generated'); + const fixedNote = noteField.value.replace('"', '\\"'); + // first, make sure all of our required fields are in place if ((urlField.value == null || urlField.value == "") || (titleField.value == null || titleField.value == "") || @@ -103,7 +112,7 @@ function generateJSON(event) { "author": "${authorField.value}", "publishedDate": "${publishedDateField.value.replace('T', ' ')}", "accessedDate": "${accessedDateField.value.replace('T', ' ')}", - "note": "${noteField.value}"\n},` + "note": "${fixedNote}"\n},` } window.addEventListener('DOMContentLoaded', () => { diff --git a/service-worker.js b/service-worker.js index a3c265e..9a16b19 100644 --- a/service-worker.js +++ b/service-worker.js @@ -6,7 +6,8 @@ chrome.tabs.onActivated.addListener((activeInfo) => { const supportedUrls = [ 'medium.com', 'youtube.com', - 'github.com' + 'github.com', + 'git.eleboog.com', ]; let supportedSite = false;