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,12 +607,18 @@ 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;
setInterval(function() { (function() {
const newurl = window.location.pathname; const _this = setInterval(function() {
if (newurl != __window_url) { if (typeof $ !== "undefined") {
__window_url_old = __window_url; clearInterval(_this);
__window_url = newurl; setInterval(function() {
fedilove_customization(); const newurl = window.location.pathname;
if (newurl != __window_url) {
__window_url_old = __window_url;
__window_url = newurl;
fedilove_customization();
}
}, 100);
} }
}, 100); });
})();