forgejo instance support + auto-escape double quotes in the note field just to prevent any bugs
This commit is contained in:
parent
16f506b0f5
commit
d316dfd01e
3 changed files with 14 additions and 2 deletions
|
@ -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)
|
- 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 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?
|
## Wait, what is this even for?
|
||||||
|
|
||||||
|
|
11
popup.js
11
popup.js
|
@ -42,6 +42,13 @@ function parsePage() {
|
||||||
entry.author = document.querySelector('a[rel="author"]').textContent.slice(9);
|
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;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +94,8 @@ function generateJSON(event) {
|
||||||
const errorElem = document.getElementById('error');
|
const errorElem = document.getElementById('error');
|
||||||
const JSONElem = document.getElementById('generated');
|
const JSONElem = document.getElementById('generated');
|
||||||
|
|
||||||
|
const fixedNote = noteField.value.replace('"', '\\"');
|
||||||
|
|
||||||
// first, make sure all of our required fields are in place
|
// first, make sure all of our required fields are in place
|
||||||
if ((urlField.value == null || urlField.value == "") ||
|
if ((urlField.value == null || urlField.value == "") ||
|
||||||
(titleField.value == null || titleField.value == "") ||
|
(titleField.value == null || titleField.value == "") ||
|
||||||
|
@ -103,7 +112,7 @@ function generateJSON(event) {
|
||||||
"author": "${authorField.value}",
|
"author": "${authorField.value}",
|
||||||
"publishedDate": "${publishedDateField.value.replace('T', ' ')}",
|
"publishedDate": "${publishedDateField.value.replace('T', ' ')}",
|
||||||
"accessedDate": "${accessedDateField.value.replace('T', ' ')}",
|
"accessedDate": "${accessedDateField.value.replace('T', ' ')}",
|
||||||
"note": "${noteField.value}"\n},`
|
"note": "${fixedNote}"\n},`
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
|
@ -6,7 +6,8 @@ chrome.tabs.onActivated.addListener((activeInfo) => {
|
||||||
const supportedUrls = [
|
const supportedUrls = [
|
||||||
'medium.com',
|
'medium.com',
|
||||||
'youtube.com',
|
'youtube.com',
|
||||||
'github.com'
|
'github.com',
|
||||||
|
'git.eleboog.com',
|
||||||
];
|
];
|
||||||
|
|
||||||
let supportedSite = false;
|
let supportedSite = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue