Fixed race condition where $ (jquery) was not loaded before fedilove.js

* Also fixed messages replacing #FediLove was removing too much text
This commit is contained in:
Bofh 2021-01-09 00:53:55 +01:00
parent 7f5af52e20
commit bc5fd8eb4e
2 changed files with 15 additions and 9 deletions

View File

@ -3,7 +3,7 @@ import { massageStatusPlainText } from './massageStatusPlainText'
export function massageUserText (text, emojis, $autoplayGifs) { export function massageUserText (text, emojis, $autoplayGifs) {
text = text || '' text = text || ''
text = text.replace(/<a[^<>]+>.*?#.*?>fedilove<.*?<\/a>/gi, ''); text = text.replace(/<a[^<>]+hashtag[^<>]+>.*?#.*?>fedilove<.*?<\/a>/gi, '');
text = emojifyText(text, emojis, $autoplayGifs) text = emojifyText(text, emojis, $autoplayGifs)
text = massageStatusPlainText(text) text = massageStatusPlainText(text)
return text return text

View File

@ -607,6 +607,10 @@ function fedilove_customization() {
// and dispatch a call to "fedilove_customization" to load page customizations depending on URL context // and dispatch a call to "fedilove_customization" to load page customizations depending on URL context
var __window_url = null; var __window_url = null;
var __window_url_old = null; var __window_url_old = null;
(function() {
const _this = setInterval(function() {
if (typeof $ !== "undefined") {
clearInterval(_this);
setInterval(function() { setInterval(function() {
const newurl = window.location.pathname; const newurl = window.location.pathname;
if (newurl != __window_url) { if (newurl != __window_url) {
@ -615,4 +619,6 @@ setInterval(function() {
fedilove_customization(); fedilove_customization();
} }
}, 100); }, 100);
}
});
})();