Replaces links to twitter.com an "x.com" to a nitter server

In the meantime, links are increasingly being shared on x.com instead of twitter.com. The addon has not yet been able to capture links on x.com and redirect them to nitter.
This commit is contained in:
loma-one 2024-01-22 19:41:04 +01:00
parent 2452b05cc5
commit ebd54b2398
1 changed files with 7 additions and 3 deletions

View File

@ -1,8 +1,8 @@
<?php
/*
* Name: nitter
* Description: Replaces links to twitter.com to a nitter server in all displays of postings on a node.
* Version: 2.0
* Description: Replaces links to twitter.com an "x.com" to a nitter server in all displays of postings on a node.
* Version: 2.1
* Author: Tobias Diekershoff <tobias@social.diekershoff.de>
*
* Copyright (c) 2020 Tobias Diekershoff
@ -55,7 +55,7 @@ function nitter_addon_admin(string &$o)
}
/*
* replace "twitter.com" with "nitter.net"
* replace "twitter.com" an "x.com" with "nitter.net"
*/
function nitter_render(array &$b)
{
@ -69,6 +69,10 @@ function nitter_render(array &$b)
if (strstr($b['html'], 'https://twitter.com')) {
$b['html'] = str_replace('https://twitter.com', $nitter, $b['html']);
$replaced = true;
}
if (strstr($b['html'], 'https://x.com')) {
$b['html'] = str_replace('https://x.com', $nitter, $b['html']);
$replaced = true;
}
if ($replaced) {
$b['html'] .= '<hr><p><small>' . DI::l10n()->t('(Nitter addon enabled: Twitter links via %s)', $nitter) . '</small></p>';