1
0
Fork 0

initial commit of the addon and README files

This commit is contained in:
Tobias Diekershoff 2020-07-06 12:48:12 +02:00
parent 4c28f16d93
commit b7eb5e9621
2 changed files with 62 additions and 0 deletions

19
README.md Normal file
View File

@ -0,0 +1,19 @@
nitter Addon for Friendica
==========================
This addon will replace all occurances of the string _https://twitter.com_ with the server address of a nitter installation (currently nitter.net) in all displayed postings on a Friendica node.
Note: If you are using the twitter connector on your server, the links to the contacts profile pages will not be replaced by this addon. Only links in the body of the postings are affected.
Nitter sources can be found on [github.com](https://github.com/zedeus/nitter) it is released unter the AGPLv3 or later.
Why
---
Excerp from nitters about page.
> It's basically impossible to use Twitter without JavaScript enabled. If you try, you're redirected to the legacy mobile version which is awful both functionally and aesthetically. For privacy-minded folks, preventing JavaScript analytics and potential IP-based tracking is important, but apart from using the legacy mobile version and a VPN, it's impossible.
>
> Using an instance of Nitter (hosted on a VPS for example), you can browse Twitter without JavaScript while retaining your privacy. In addition to respecting your privacy, Nitter is on average around 15 times lighter than Twitter, and in some cases serves pages faster.
>
> In the future a simple account system will be added that lets you follow Twitter users, allowing you to have a clean chronological timeline without needing a Twitter account.

43
nitter.php Normal file
View File

@ -0,0 +1,43 @@
<?php
/*
* Name: nitter
* Description: Replaces links to twitter.com to a nitter server in all displays of postings on a node.
* Version: 1.0
* Author: Tobias Diekershoff <tobias@social.diekershoff.de>
*
* Copyright (c) 2020 Tobias Diekershoff
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
use Friendica\Core\Addon;
use Friendica\DI;
function nitter_install() {
Addon::registerHook ('prepare_body', 'addon/nitter/nitter.php', 'nitter_render');
}
/*
* replace "twitter.com" with "nitter.net"
*/
function nitter_render(&$a, &$o) {
// this needs to be a system setting
$nitter = 'https://nitter.net';
if (strstr($o[html],'https://twitter.com')) {
$o['html'] = str_replace('https://twitter.com', $nitter, $o[html]);
$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>';
}
}