diff --git a/weblog/B0. Template/fediverse.js.md b/weblog/B0. Template/fediverse.js.md
index 5f1c3ef..87a3a45 100644
--- a/weblog/B0. Template/fediverse.js.md
+++ b/weblog/B0. Template/fediverse.js.md
@@ -121,21 +121,39 @@ customElements.define('fedi-social', FediSocial)
function fediverse() {
const data = JSON.parse(localStorage.getItem('fedi-social') || '{}')
- document.querySelectorAll("a.external_url:not([href='{external_url}'])").forEach(el => {
+ document.querySelectorAll("a.external_url:not([href='{external_url}'])").forEach(async (el) => {
if(data.template){
- href = data.template.replace("{uri}", el.href)
- const innerHTML = `
-
-
-
- `
+ const orig_href = el.href
+ let href = data.template.replace("{uri}", orig_href)
+ el.href = href
- const span = document.createElement('span')
- span.classList.add('fediverse')
- span.innerHTML = innerHTML
+ try{
+ const res = await fetch(`https://monrepos.casa/api/v2/search?type=statuses&q=${orig_href}`, {
+ headers: {
+ 'Authorization': 'Basic Ym90OjJuUmZhTGJ1c3cyaFhA'
+ }
+ })
+ const json = await res.json()
+ const status = json?.statuses?.find(s => s.uri == orig_href)
- el.insertAdjacentElement('afterend', span)
- el.remove()
+ if(status) {
+ const innerHTML = `
+ ${status?.replies_count}
+ ${status?.favourites_count}
+ ${status?.reblogs_count}
+ `
+
+ const span = document.createElement('span')
+ span.classList.add('fediverse')
+ span.innerHTML = innerHTML
+
+ el.insertAdjacentElement('afterend', span)
+ el.remove()
+ }
+ }
+ catch(ex){
+ console.error(ex)
+ }
}
else {
el.addEventListener('click', ev =>{