mirror of
https://gitlab.com/idotj/mastodon-embed-timeline.git
synced 2025-05-24 08:52:46 +00:00
Fix spoiler/sensitive feature in boosted toots
This commit is contained in:
parent
bbd8ad1994
commit
0263aca50e
@ -1,3 +1,6 @@
|
|||||||
|
v3.8.0 - 04/08/2023
|
||||||
|
- Add spoiler/sensitive button for reblog content
|
||||||
|
|
||||||
v3.7.2 - 25/07/2023
|
v3.7.2 - 25/07/2023
|
||||||
- Use window.onload to take async attribute into account
|
- Use window.onload to take async attribute into account
|
||||||
- Remove extra height on loading images
|
- Remove extra height on loading images
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Mastodon embed feed timeline v3.7.2 */
|
/* Mastodon embed feed timeline v3.8.0 */
|
||||||
/* More info at: */
|
/* More info at: */
|
||||||
/* https://gitlab.com/idotj/mastodon-embed-feed-timeline */
|
/* https://gitlab.com/idotj/mastodon-embed-feed-timeline */
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Mastodon embed feed timeline v3.7.2
|
// Mastodon embed feed timeline v3.8.0
|
||||||
// More info at:
|
// More info at:
|
||||||
// https://gitlab.com/idotj/mastodon-embed-feed-timeline
|
// https://gitlab.com/idotj/mastodon-embed-feed-timeline
|
||||||
|
|
||||||
@ -283,7 +283,24 @@ MastodonApi.prototype.getToots = function () {
|
|||||||
this.formatTootText(status_.content) +
|
this.formatTootText(status_.content) +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"</div>";
|
"</div>";
|
||||||
} else if (status_.reblog && status_.reblog.content !== "") {
|
} else if (
|
||||||
|
status_.reblog &&
|
||||||
|
status_.reblog.content !== "" &&
|
||||||
|
status_.reblog.spoiler_text !== ""
|
||||||
|
) {
|
||||||
|
content =
|
||||||
|
'<div class="toot-text">' +
|
||||||
|
status_.reblog.spoiler_text +
|
||||||
|
' <button type="button" class="spoiler-link" aria-expanded="false">Show more</button>' +
|
||||||
|
'<div class="spoiler-text-hidden">' +
|
||||||
|
this.formatTootText(status_.reblog.content) +
|
||||||
|
"</div>" +
|
||||||
|
"</div>";
|
||||||
|
} else if (
|
||||||
|
status_.reblog &&
|
||||||
|
status_.reblog.content !== "" &&
|
||||||
|
status_.reblog.spoiler_text === ""
|
||||||
|
) {
|
||||||
content =
|
content =
|
||||||
'<div class="toot-text ' +
|
'<div class="toot-text ' +
|
||||||
text_css +
|
text_css +
|
||||||
@ -317,7 +334,7 @@ MastodonApi.prototype.getToots = function () {
|
|||||||
for (let picid in status_.reblog.media_attachments) {
|
for (let picid in status_.reblog.media_attachments) {
|
||||||
media = this.replaceMedias(
|
media = this.replaceMedias(
|
||||||
status_.reblog.media_attachments[picid],
|
status_.reblog.media_attachments[picid],
|
||||||
status_.sensitive
|
status_.reblog.sensitive
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,13 +400,13 @@ MastodonApi.prototype.getToots = function () {
|
|||||||
});
|
});
|
||||||
this.mtBodyContainer.addEventListener("keydown", function (e) {
|
this.mtBodyContainer.addEventListener("keydown", function (e) {
|
||||||
// Check if Enter key pressed with focus in an article
|
// Check if Enter key pressed with focus in an article
|
||||||
if (event.code === "Enter" && e.target.localName == "article") {
|
if (e.key === "Enter" && e.target.localName == "article") {
|
||||||
openTootURL(e);
|
openTootURL(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Open Toot in a new page avoiding any other natural link
|
// Open Toot in a new page avoiding any other natural link
|
||||||
let openTootURL = function (e) {
|
const openTootURL = function (e) {
|
||||||
let urlToot = e.target.closest(".mt-toot").dataset.location;
|
let urlToot = e.target.closest(".mt-toot").dataset.location;
|
||||||
if (
|
if (
|
||||||
e.target.localName !== "a" &&
|
e.target.localName !== "a" &&
|
||||||
@ -402,7 +419,7 @@ MastodonApi.prototype.getToots = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Spoiler button
|
// Spoiler button
|
||||||
let toogleSpoiler = function (e) {
|
const toogleSpoiler = function (e) {
|
||||||
const nextSibling = e.target.nextSibling;
|
const nextSibling = e.target.nextSibling;
|
||||||
if (nextSibling.localName === "img") {
|
if (nextSibling.localName === "img") {
|
||||||
e.target.parentNode.classList.remove("toot-media-spoiler");
|
e.target.parentNode.classList.remove("toot-media-spoiler");
|
||||||
@ -476,7 +493,7 @@ MastodonApi.prototype.replaceHTMLtag = function (
|
|||||||
// Place media
|
// Place media
|
||||||
MastodonApi.prototype.replaceMedias = function (m, s) {
|
MastodonApi.prototype.replaceMedias = function (m, s) {
|
||||||
let spoiler = s || false;
|
let spoiler = s || false;
|
||||||
let pic =
|
const pic =
|
||||||
'<div class="toot-media ' +
|
'<div class="toot-media ' +
|
||||||
(spoiler ? "toot-media-spoiler" : "") +
|
(spoiler ? "toot-media-spoiler" : "") +
|
||||||
' img-ratio14_7 loading-spinner">' +
|
' img-ratio14_7 loading-spinner">' +
|
||||||
@ -508,7 +525,7 @@ MastodonApi.prototype.formatDate = function (d) {
|
|||||||
|
|
||||||
let date = new Date(d);
|
let date = new Date(d);
|
||||||
|
|
||||||
let displayDate =
|
const displayDate =
|
||||||
monthNames[date.getMonth()] +
|
monthNames[date.getMonth()] +
|
||||||
" " +
|
" " +
|
||||||
date.getDate() +
|
date.getDate() +
|
||||||
@ -519,7 +536,7 @@ MastodonApi.prototype.formatDate = function (d) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Loading spinner
|
// Loading spinner
|
||||||
removeSpinner = function (e) {
|
const removeSpinner = function (e) {
|
||||||
const spinnerCSS = "loading-spinner";
|
const spinnerCSS = "loading-spinner";
|
||||||
// Find closest parent container (1st, 2nd or 3rd level)
|
// Find closest parent container (1st, 2nd or 3rd level)
|
||||||
let spinnerContainer = e.closest("." + spinnerCSS);
|
let spinnerContainer = e.closest("." + spinnerCSS);
|
||||||
|
2
src/mastodon-timeline.min.js
vendored
2
src/mastodon-timeline.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user