nitter: replace mobile link to twitter as well

pull/1159/head
Tobias Diekershoff 2021-08-18 19:04:51 +02:00
parent da159e9d2c
commit b78c8a30f6
1 changed files with 8 additions and 0 deletions

View File

@ -61,9 +61,17 @@ function nitter_addon_admin(App $a, &$o)
function nitter_render(&$a, &$o) function nitter_render(&$a, &$o)
{ {
// this needs to be a system setting // this needs to be a system setting
$replaced = false;
$nitter = DI::config()->get('nitter', 'server', 'https://nitter.net'); $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')) { if (strstr($o['html'], 'https://twitter.com')) {
$o['html'] = str_replace('https://twitter.com', $nitter, $o['html']); $o['html'] = str_replace('https://twitter.com', $nitter, $o['html']);
$replace = true;
}
if ($replace) {
$o['html'] .= '<hr><p>' . DI::l10n()->t('Links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '</p>'; $o['html'] .= '<hr><p>' . DI::l10n()->t('Links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '</p>';
} }
} }