From 32f698ce10ac2e790a8723a4a2387b58baacb10a Mon Sep 17 00:00:00 2001 From: "Dr. Tobias Quathamer" Date: Mon, 18 Mar 2024 11:05:09 +0100 Subject: [PATCH] Only show small info about replacements if the original has changed --- url_replace/url_replace.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/url_replace/url_replace.php b/url_replace/url_replace.php index 54b407e4..622ac720 100644 --- a/url_replace/url_replace.php +++ b/url_replace/url_replace.php @@ -134,6 +134,7 @@ function url_replace_addon_admin(string &$o) */ function url_replace_render(array &$b) { + $replaced = false; $replacements = []; $nitter_server = DI::config()->get('url_replace', 'nitter_server') ?? URL_REPLACE_NITTER_DEFAULT; @@ -171,6 +172,7 @@ function url_replace_render(array &$b) foreach ($replacements as $server => $replacement) { if (strpos($b['html'], $server) !== false) { $b['html'] = str_replace($server, $replacement, $b['html']); + $replaced = true; } } @@ -178,10 +180,11 @@ function url_replace_render(array &$b) foreach ($twelvefeet_sites as $twelvefeet_site) { if (strpos($b['html'], $twelvefeet_site) !== false) { $b['html'] = str_replace($twelvefeet_site, 'https://12ft.io/' . $twelvefeet_site, $b['html']); + $replaced = true; } } - if (count($replacements) > 0) { + if ($replaced) { $b['html'] .= '

' . DI::l10n()->t('(URL replace addon enabled for X, YouTube, Instagram and some news sites.)') . '

'; } }