homes/desktop/.local/share/poezio/plugins/remove_get_trackers.py
kujiu (@uberwald) 8ca6287fb1
Update all tools
-> Passwords in KeePassXC (access by keyring)
-> Neomutt + Aerc (mail)
-> vdirsyncer + khal + khard (calendar and contacts)
zsh -> fish
-> poezio (XMPP)
-> newsboat (RSS with FreshRSS)
-> toot (Mastodon client)
vim -> neovim (with lunarvim)
-> nvimpager (pager based on neovim)
-> konsole

With Nightfox theme.
2023-09-02 00:40:34 +02:00

24 lines
1.1 KiB
Python

"""
Remove GET trackers from URLs in sent messages.
"""
from poezio.plugin import BasePlugin
import re
class Plugin(BasePlugin):
def init(self):
self.api.information('This plugin is deprecated and will be replaced by \'untrackme\'.', 'Warning')
self.api.add_event_handler('muc_say', self.remove_get_trackers)
self.api.add_event_handler('conversation_say', self.remove_get_trackers)
self.api.add_event_handler('private_say', self.remove_get_trackers)
def remove_get_trackers(self, msg, tab):
# fbclid: used globally (Facebook)
# utm_*: used globally https://en.wikipedia.org/wiki/UTM_parameters
# ncid: DoubleClick (Google)
# ref_src, ref_url: twitter
# Others exist but are excluded because they are not common.
# See https://en.wikipedia.org/wiki/UTM_parameters
msg['body'] = re.sub('(https?://[^ ]+)&?(fbclid|dclid|ncid|utm_source|utm_medium|utm_campaign|utm_term|utm_content|ref_src|ref_url)=[^ &#]*',
r'\1',
msg['body'])