From b78c8a30f6d8c14d6301aa7819ba7f09e05ece8c Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Wed, 18 Aug 2021 19:04:51 +0200 Subject: [PATCH 1/3] nitter: replace mobile link to twitter as well --- nitter/nitter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nitter/nitter.php b/nitter/nitter.php index ea8e24be..fab7aa06 100644 --- a/nitter/nitter.php +++ b/nitter/nitter.php @@ -61,9 +61,17 @@ function nitter_addon_admin(App $a, &$o) function nitter_render(&$a, &$o) { // this needs to be a system setting + $replaced = false; $nitter = DI::config()->get('nitter', 'server', 'https://nitter.net'); + if (strstr($o['html'], 'https://mobile.twitter.com')) { + $o['html'] = str_replace('https://mobile.twitter.com', $nitter, $o['html']); + $replace = true; + } if (strstr($o['html'], 'https://twitter.com')) { $o['html'] = str_replace('https://twitter.com', $nitter, $o['html']); + $replace = true; + } + if ($replace) { $o['html'] .= '

' . DI::l10n()->t('Links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '

'; } } From 81fce72efe15c5408a576fdff7bc3274fbfef905 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Wed, 18 Aug 2021 19:11:23 +0200 Subject: [PATCH 2/3] nitter: the nitter instance base url should not contain the trailing / --- nitter/nitter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nitter/nitter.php b/nitter/nitter.php index fab7aa06..549356de 100644 --- a/nitter/nitter.php +++ b/nitter/nitter.php @@ -38,6 +38,9 @@ function nitter_install() function nitter_addon_admin_post(App $a) { $nitterserver = trim($_POST['nitterserver']); + if ((substr($apiurl, -1) == '/')) { + $apiurl = substr($apiurl, 0, -1); + } DI::config()->set('nitter', 'server', $nitterserver); } From a843e96c1f638d2d67ba91e185f02fe1b23c4b2f Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Thu, 19 Aug 2021 06:57:46 +0200 Subject: [PATCH 3/3] use rtrim --- nitter/nitter.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nitter/nitter.php b/nitter/nitter.php index 549356de..e8f3bcdb 100644 --- a/nitter/nitter.php +++ b/nitter/nitter.php @@ -37,10 +37,7 @@ function nitter_install() */ function nitter_addon_admin_post(App $a) { - $nitterserver = trim($_POST['nitterserver']); - if ((substr($apiurl, -1) == '/')) { - $apiurl = substr($apiurl, 0, -1); - } + $nitterserver = rtrim(trim($_POST['nitterserver']),'/'); DI::config()->set('nitter', 'server', $nitterserver); }