Add feature - hide replies and boosts

This commit is contained in:
i.j 2022-12-02 17:12:43 +00:00
parent 340fa3d086
commit 0e823ba2a9

View File

@ -10,6 +10,8 @@ document.addEventListener("DOMContentLoaded", () => {
user_id: '180745',
profile_name: '@idotj',
toots_limit: 13,
hide_reblog: false,
hide_replies: true,
btn_see_more: 'See more posts at Mastodon'
});
});
@ -21,6 +23,8 @@ let MastodonApi = function (params_) {
this.USER_ID = params_.user_id;
this.PROFILE_NAME = params_.profile_name;
this.TOOTS_LIMIT = params_.toots_limit || 20;
this.HIDE_REBLOG = typeof params_.hide_reblog !== 'undefined' ? params_.hide_reblog : false;
this.HIDE_REPLIES = typeof params_.hide_replies !== 'undefined' ? params_.hide_replies : false;
this.BTN_SEE_MORE = params_.btn_see_more || 'See more'
// Target selectors
@ -58,11 +62,15 @@ MastodonApi.prototype.getToots = function () {
// Add toots
for (let i in jsonData) {
if (jsonData[i].visibility == 'public') {
// List only public toots
if (jsonData[i].visibility == 'public') {
if(mapi.HIDE_REBLOG && jsonData[i].reblog || mapi.HIDE_REPLIES && jsonData[i].in_reply_to_id){
// Nothing here (Don't append boosts and/or replies toots)
}else{
appendToot.call(mapi, jsonData[i]);
}
}
}
// Add target="_blank" to all hashtags
let allHashtags = document.querySelectorAll("#mt-timeline .hashtag");