From 0b07abb95f6fb6f536bc277c7e3f026f66d81f3e Mon Sep 17 00:00:00 2001 From: Jordan Bracco Date: Thu, 26 Jun 2025 17:36:17 +0200 Subject: link: quirky --- lib/plugins/link/html.ex | 3 +++ lib/plugins/link/quirks.ex | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 lib/plugins/link/quirks.ex (limited to 'lib/plugins/link') diff --git a/lib/plugins/link/html.ex b/lib/plugins/link/html.ex index 78f3192..aa78810 100644 --- a/lib/plugins/link/html.ex +++ b/lib/plugins/link/html.ex @@ -144,6 +144,9 @@ defmodule Nola.Plugins.Link.HTML do defp clean_text(text) do text |> String.replace("\n", " ") + |> String.replace("
", " ") + |> String.replace("
", " ") + |> String.replace("
", " ") |> HtmlEntities.decode() end end diff --git a/lib/plugins/link/quirks.ex b/lib/plugins/link/quirks.ex new file mode 100644 index 0000000..af259a2 --- /dev/null +++ b/lib/plugins/link/quirks.ex @@ -0,0 +1,26 @@ +defmodule Nola.Plugins.Link.Quirks do + # def uri(%URI{host: "x.com"} = uri) do + # %URI{uri | host: "vxtwitter.com"} + # end + + def uri(url) do + url + end + + def user_agent(host) + when host in [ + "x.com", + "vxtwitter.com", + "fxtwitter.com", + "instagram.com", + "facebook.com", + "xnstagram.com", + "ddinstagram.com" + ] do + "TelegramBot (like TwitterBot)" + end + + def user_agent(_host) do + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36" + end +end -- cgit v1.2.3