From a40bd7009b672b869127bc64e87083d0d6eb39de Mon Sep 17 00:00:00 2001 From: "Dr. Tobias Quathamer" Date: Wed, 13 Mar 2024 17:07:08 +0100 Subject: [PATCH] Add proxigram for instagram redirection. Based on an idea and patch from loma-one. Thanks! --- url_replace/templates/admin.tpl | 1 + url_replace/url_replace.php | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/url_replace/templates/admin.tpl b/url_replace/templates/admin.tpl index b99e6355..01f38e6e 100644 --- a/url_replace/templates/admin.tpl +++ b/url_replace/templates/admin.tpl @@ -1,5 +1,6 @@ {{include file="field_input.tpl" field=$nitter_server}} {{include file="field_input.tpl" field=$invidious_server}} +{{include file="field_input.tpl" field=$proxigram_server}} {{include file="field_textarea.tpl" field=$twelvefeet_sites}}
diff --git a/url_replace/url_replace.php b/url_replace/url_replace.php index 7710a2e1..c7bb2e81 100644 --- a/url_replace/url_replace.php +++ b/url_replace/url_replace.php @@ -23,6 +23,7 @@ function url_replace_addon_admin_post() { DI::config()->set('url_replace', 'nitter_server', rtrim(trim($_POST['nitter_server']), '/')); DI::config()->set('url_replace', 'invidious_server', rtrim(trim($_POST['invidious_server']), '/')); + DI::config()->set('url_replace', 'proxigram_server', rtrim(trim($_POST['proxigram_server']), '/')); // Convert twelvefeet_sites into an array before setting the new value $twelvefeet_sites = explode(PHP_EOL, $_POST['twelvefeet_sites']); // Normalize URLs by using lower case, removing a trailing slash and whitespace @@ -41,12 +42,13 @@ function url_replace_addon_admin_post() /** * Hook into admin settings to enable choosing a different server - * for twitter, youtube, and news sites. + * for twitter, youtube, instagram, and news sites. */ function url_replace_addon_admin(string &$o) { $nitter_server = DI::config()->get('url_replace', 'nitter_server'); $invidious_server = DI::config()->get('url_replace', 'invidious_server'); + $proxigram_server = DI::config()->get('url_replace', 'proxigram_server'); $twelvefeet_sites = implode(PHP_EOL, DI::config()->get('url_replace', 'twelvefeet_sites') ?? []); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/url_replace/'); @@ -67,6 +69,14 @@ function url_replace_addon_admin(string &$o) null, 'placeholder="https://yewtu.be"', ], + '$proxigram_server' => [ + 'proxigram_server', + DI::l10n()->t('Proxigram server'), + $proxigram_server, + DI::l10n()->t('Specify the URL with protocol. The default is https://proxigram.lunar.icu.'), + null, + 'placeholder="https://proxigram.lunar.icu"', + ], '$twelvefeet_sites' => [ 'twelvefeet_sites', DI::l10n()->t('Sites which are accessed through 12ft.io'), @@ -96,6 +106,11 @@ function url_replace_render(array &$b) $invidious_server = 'https://yewtu.be'; } + $proxigram_server = DI::config()->get('url_replace', 'proxigram_server'); + if (empty($proxigram_server)) { + $proxigram_server = 'https://proxigram.lunar.icu'; + } + // Handle some of twitter and youtube $replacements = [ 'https://mobile.twitter.com' => $nitter_server, @@ -106,6 +121,9 @@ function url_replace_render(array &$b) 'https://youtube.com' => $invidious_server, 'https://m.youtube.com' => $invidious_server, 'https://youtu.be' => $invidious_server, + 'https://www.instagram.com' => $proxigram_server, + 'https://instagram.com' => $proxigram_server, + 'https://ig.me' => $proxigram_server, ]; foreach ($replacements as $server => $replacement) { if (strpos($b['html'], $server) !== false) { @@ -124,6 +142,6 @@ function url_replace_render(array &$b) if ($replaced) { - $b['html'] .= '

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

'; + $b['html'] .= '

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

'; } }