// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
!(function () {
"use strict";
window.i18next = window.i18next || {
t: function t(e) {
return e;
},
};
let t = window.i18next.t.bind(window.i18next);
function e(t, e) {
return document.currentScript.getAttribute("data-" + t) || e;
}
let o = e("page-url", window.location.href.replace(/#.*$/, "")),
n = e("add-urls", void 0),
r = e("id", "webmentions"),
s = e("wordcount"),
l = e("max-webmentions", 30),
i = e("prevent-spoofing") ? "wm-source" : "url",
a = e("sort-by", "published"),
u = e("sort-dir", "up"),
p = e("comments-are-reactions", !1),
c = {
"in-reply-to": t("replied"),
"like-of": t("liked"),
"repost-of": t("reposted"),
"bookmark-of": t("bookmarked"),
"mention-of": t("mentioned"),
rsvp: t("RSVPed"),
"follow-of": t("followed"),
},
f = {
"in-reply-to": "\uD83D\uDCAC",
"like-of": "❤️",
"repost-of": "\uD83D\uDD04",
"bookmark-of": "⭐️",
"mention-of": "\uD83D\uDCAC",
rsvp: "\uD83D\uDCC5",
"follow-of": "\uD83D\uDC1C",
},
m = {
yes: "✅",
no: "❌",
interested: "\uD83D\uDCA1",
maybe: "\uD83D\uDCAD",
};
function d(t) {
return t.replace(
/[&<>"]/g,
(t) =>
({ "&": "&", "<": "<", ">": ">", '"': """ })[
t
] || t,
);
}
function h(e, o) {
let n = d(e.author?.name || e.url.split("/")[2]),
r = c[e["wm-property"]] || t("reacted");
!o && e.content && e.content.text && (r += ": " + x(e));
let s = "";
s =
e.author && e.author.photo
? `
`
: `
`;
let l = "";
return (
e.rsvp && m[e.rsvp] && (l = `${m[e.rsvp]}`),
`
${s}
${f[e["wm-property"]] || "\uD83D\uDCA5"}
${l}
`
);
}
function g(t) {
return t.substr(t.indexOf("//"));
}
function w(t) {
let e = [],
o = {};
return (
t.forEach(function (t) {
let n = g(t.url);
o[n] || (e.push(t), (o[n] = !0));
}),
e
);
}
function x(t) {
let e = d(t.content.text);
if (s) {
let o = e.replace(/\s+/g, " ").split(" ", s + 1);
o.length > s &&
((o[s - 1] += "…"), (e = (o = o.slice(0, s)).join(" ")));
}
return e;
}
window.addEventListener("load", async function () {
let e = document.getElementById(r);
if (!e) return;
let s = [g(o)];
n &&
n.split("|").forEach(function (t) {
s.push(g(t));
});
let c = `https://webmention.io/api/mentions.jf2?per-page=${l}&sort-by=${a}&sort-dir=${u}`;
s.forEach(function (t) {
c += `&target[]=${encodeURIComponent("http:" + t)}&target[]=${encodeURIComponent("https:" + t)}`;
});
let f = {};
try {
let m = await window.fetch(c);
m.status >= 200 && m.status < 300
? (f = await m.json())
: (console.error("Could not parse response"),
Error(m.statusText));
} catch (y) {
console.error("Request failed", y);
}
let b = [],
k = [];
p && (b = k);
let B = {
"in-reply-to": b,
"like-of": k,
"repost-of": k,
"bookmark-of": k,
"follow-of": k,
"mention-of": b,
rsvp: b,
};
f.children.forEach(function (t) {
let e = B[t["wm-property"]];
e && e.push(t);
});
let S = "";
b.length > 0 &&
b !== k &&
(S = (function e(o) {
let n = `
暂无 Webmention 回应。
'), (e.innerHTML = $)); }); })(); // @license-end