修改以适用于Pleroma

This commit is contained in:
BuildTools 2024-06-26 10:36:15 +08:00
parent 370986cd21
commit 38e0b5a451
7 changed files with 65 additions and 45 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -132,7 +132,9 @@
<!-- JavaScript -->
<script src="../dist/mastodon-timeline.umd.js"></script>
<script>
const myTimeline = new MastodonTimeline.Init();
const myTimeline = new MastodonTimeline.Init({
instanceUrl: "https://mastodon.social"
});
</script>
</body>
</html>

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mastodon embed timeline</title>
<link rel="stylesheet" href="../dist/mastodon-timeline.min.css" />
<div class="dummy-wrapper-timeline">
<!-- Mastodon Timeline -->
<div id="mt-container" class="mt-container">
<div class="mt-body" role="feed">
<div class="mt-loading-spinner"></div>
</div>
</div>
</div>
</div>
<!-- JavaScript -->
<script src="../dist/mastodon-timeline.umd.js"></script>
<script>
const myTimeline = new MastodonTimeline.Init({
instanceUrl: "https://wb.kunjk.top",
timelineType: "profile",
userId: "AhVoZyMjM1sRAccpEW",
profileName: "@aaa",
});
</script>
</body>
</html>

View File

@ -107,9 +107,9 @@
<script src="../dist/mastodon-timeline.umd.js"></script>
<script>
const myTimeline = new MastodonTimeline.Init({
instanceUrl: "https://mastodon.online",
instanceUrl: "https://wb.kunjk.top",
timelineType: "profile",
userId: "000180745",
userId: "AhT6JrTQPecQY1Ztaq",
profileName: "@idotj",
});
</script>

26
src/backup_code.js Normal file
View File

@ -0,0 +1,26 @@
if (type === "image") {
media =
'<div class="mt-post-media ' +
(spoiler ? "mt-post-media-spoiler " : "") +
this.mtSettings.spinnerClass +
'" data-media-type="' +
type +
'" data-media-url-hd="' +
m.url +
'" data-media-alt-txt="' +
(m.description ? this.#escapeHTML(m.description) : "") +
'" data-media-width-hd="' +
m.meta.original.width +
'" data-media-height-hd="' +
m.meta.original.height +
'" style="padding-top: calc(100%/' +
m.meta.small.aspect +
')">' +
(spoiler ? spoilerBtns : "") +
'<img src="' +
m.preview_url +
'" alt="' +
(m.description ? this.#escapeHTML(m.description) : "") +
'" loading="lazy" />' +
"</div>";
}

View File

@ -243,14 +243,7 @@ export class Init {
}
// Fetch more posts if maxNbPostFetch is not reached
if (this.#isNbPostsFulfilled()) {
resolve();
} else {
do {
await this.#fetchMorePosts();
} while (!this.#isNbPostsFulfilled() && this.linkHeader.next);
resolve();
}
});
});
}
@ -1010,7 +1003,7 @@ export class Init {
if (type === "image") {
media =
'<div class="mt-post-media ' +
'<div class="mt-post-mediaa ' +
(spoiler ? "mt-post-media-spoiler " : "") +
this.mtSettings.spinnerClass +
'" data-media-type="' +
@ -1019,15 +1012,9 @@ export class Init {
m.url +
'" data-media-alt-txt="' +
(m.description ? this.#escapeHTML(m.description) : "") +
'" data-media-width-hd="' +
m.meta.original.width +
'" data-media-height-hd="' +
m.meta.original.height +
'" style="padding-top: calc(100%/' +
m.meta.small.aspect +
')">' +
'" style="position: relative; float: left; inset: auto;">' +
(spoiler ? spoilerBtns : "") +
'<img src="' +
'<img style="max-width:150%; overflow:hidden;" src="' +
m.preview_url +
'" alt="' +
(m.description ? this.#escapeHTML(m.description) : "") +
@ -1499,30 +1486,7 @@ export class Init {
</a>`;
}
// Create button to refresh the timeline
if (this.mtSettings.btnReload) {
btnReloadHTML = `
<button class="mt-btn-violet btn-refresh">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M21 3v5m0 0h-5m5 0l-3-2.708C16.408 3.867 14.305 3 12 3a9 9 0 1 0 0 18c4.283 0 7.868-2.992 8.777-7" stroke="var(--mt-color-btn-txt)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
${this.mtSettings.btnReload}
</button>`;
}
// Add footer container
this.mtBodyNode.parentNode.insertAdjacentHTML(
"beforeend",
'<div class="mt-footer">' + btnSeeMoreHTML + btnReloadHTML + "</div>"
);
// Add event listener to the button "Refresh"
if (this.mtSettings.btnReload) {
const reloadBtn =
this.mtContainerNode.getElementsByClassName("btn-refresh")[0];
reloadBtn.addEventListener("click", () => {
this.mtUpdate();
});
}
}
/**