From 1a6bc2f629b507ab73f5da1c353ce44499e1c9b2 Mon Sep 17 00:00:00 2001 From: dimden Date: Wed, 13 Sep 2023 01:06:02 +0300 Subject: [PATCH] fix post->tweet replacer in tombstones --- layouts/tweet/script.js | 6 +++--- scripts/tweetviewer.js | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/layouts/tweet/script.js b/layouts/tweet/script.js index 90731840..28a310d9 100644 --- a/layouts/tweet/script.js +++ b/layouts/tweet/script.js @@ -688,9 +688,6 @@ async function appendComposeComponent(container, replyTweet) { }); } async function appendTombstone(timelineContainer, text, replyTweet) { - tweets.push(['tombstone', text, replyTweet]); - let tombstone = document.createElement('div'); - tombstone.className = 'tweet-tombstone'; try { if(typeof text === 'string') LOC.replacer_post_to_tweet.message.split('|').forEach(el => { let [or, nr] = el.split('->'); @@ -698,6 +695,9 @@ async function appendTombstone(timelineContainer, text, replyTweet) { text = text.replace(new RegExp(or, "g"), nr); }); } catch(e) {} + tweets.push(['tombstone', text, replyTweet]); + let tombstone = document.createElement('div'); + tombstone.className = 'tweet-tombstone'; tombstone.innerHTML = text; timelineContainer.append(tombstone); if(replyTweet) { diff --git a/scripts/tweetviewer.js b/scripts/tweetviewer.js index 8d4c7405..8231cf72 100644 --- a/scripts/tweetviewer.js +++ b/scripts/tweetviewer.js @@ -2493,17 +2493,19 @@ class TweetViewer { } } async appendTombstone(timelineContainer, text) { - this.tweets.push(['tombstone', text]); - let tombstone = document.createElement('div'); - tombstone.className = 'tweet-tombstone'; - tombstone.innerHTML = text; try { if(typeof text === 'string') LOC.replacer_post_to_tweet.message.split('|').forEach(el => { let [or, nr] = el.split('->'); or = or[0].toUpperCase() + or.slice(1); text = text.replace(new RegExp(or, "g"), nr); }); - } catch(e) {} + } catch(e) { + console.error(e); + } + this.tweets.push(['tombstone', text]); + let tombstone = document.createElement('div'); + tombstone.className = 'tweet-tombstone'; + tombstone.innerHTML = text; timelineContainer.append(tombstone); } init() {