Messagelib

blocktrackingurlinterceptor.cpp
1/*
2 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "blocktrackingurlinterceptor.h"
8#include "webengineviewer_block_tracking_url_interceptor_debug.h"
9#include <QWebEngineUrlRequestInfo>
10
11using namespace WebEngineViewer;
12BlockTrackingUrlInterceptor::BlockTrackingUrlInterceptor(QObject *parent)
13 : WebEngineViewer::NetworkPluginUrlInterceptorInterface(parent)
14{
15 qRegisterMetaType<WebEngineViewer::BlockTrackingUrlInterceptor::TrackerBlackList>();
16 initializeList();
17}
18
19BlockTrackingUrlInterceptor::~BlockTrackingUrlInterceptor() = default;
20
21bool BlockTrackingUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
22{
23 if (!mEnabledMailTrackingInterceptor) {
24 return false;
25 }
26 const QUrl urlRequestUrl(info.requestUrl());
27 if (urlRequestUrl.scheme() != QLatin1StringView("data")) {
28 qCDebug(WEBENGINEVIEWER_BLOCK_TRACKING_URL_LOG) << " Tracking url " << urlRequestUrl;
29 }
30 for (int i = 0, total = mBackList.size(); i < total; ++i) {
31 const auto blackListinfo{mBackList.at(i)};
32 if (urlRequestUrl.url().startsWith(blackListinfo.mCompanyUrl)) {
33 qCDebug(WEBENGINEVIEWER_BLOCK_TRACKING_URL_LOG) << " found tracker " << blackListinfo;
34 Q_EMIT trackingFound(blackListinfo);
35 return true;
36 }
37 }
38 return false;
39}
40
41void BlockTrackingUrlInterceptor::initializeList()
42{
43 mBackList = {{QStringLiteral("Sidekick"), QStringLiteral("t.signaux"), QStringLiteral("http://getsidekick.com")},
44 {QStringLiteral("Sidekick"), QStringLiteral("t.sidekickopen"), QStringLiteral("http://getsidekick.com")},
45 {QStringLiteral("Sidekick"), QStringLiteral("t.sigopn"), QStringLiteral("http://getsidekick.com")},
46 {QStringLiteral("Banana Tag"), QStringLiteral("bl-1.com"), QStringLiteral("http://bananatag.com")},
47 {QStringLiteral("Boomerang"), QStringLiteral("mailstat.us/tr"), QStringLiteral("http://boomeranggmail.com")},
48 {QStringLiteral("Cirrus Insight"), QStringLiteral("tracking.cirrusinsight.com"), QStringLiteral("http://cirrusinsight.com")},
49 {QStringLiteral("Yesware"), QStringLiteral("app.yesware.com"), QStringLiteral("http://yesware.com")},
50 {QStringLiteral("Yesware"), QStringLiteral("t.yesware.com"), QStringLiteral("http://yesware.com")},
51 {QStringLiteral("Streak"), QStringLiteral("mailfoogae.appspot.com"), QStringLiteral("http://streak.com")},
52 {QStringLiteral("LaunchBit"), QStringLiteral("launchbit.com/taz-pixel"), QStringLiteral("http://launchbit.com")},
53 {QStringLiteral("MailChimp"), QStringLiteral("list-manage.com/track"), QStringLiteral("http://mailchimp.com")},
54 {QStringLiteral("Postmark"), QStringLiteral("cmail1.com/t"), QStringLiteral("http://postmarkapp.com")},
55 {QStringLiteral("iContact"), QStringLiteral("click.icptrack.com/icp/"), QStringLiteral("http://icontact.com")},
56 {QStringLiteral("Infusionsoft"), QStringLiteral("infusionsoft.com/app/emailOpened"), QStringLiteral("http://infusionsoft.com")},
57 {QStringLiteral("Intercom"), QStringLiteral("via.intercom.io/o"), QStringLiteral("http://intercom.io")},
58 {QStringLiteral("Mandrill"), QStringLiteral("mandrillapp.com/track"), QStringLiteral("http://mandrillapp.com")},
59 {QStringLiteral("Hubspot"), QStringLiteral("t.hsms06.com"), QStringLiteral("http://hubspot.com")},
60 {QStringLiteral("RelateIQ"), QStringLiteral("app.relateiq.com/t.png"), QStringLiteral("http://relateiq.com")},
61 {QStringLiteral("RJ Metrics"), QStringLiteral("go.rjmetrics.com"), QStringLiteral("http://rjmetrics.com")},
62 {QStringLiteral("Mixpanel"), QStringLiteral("api.mixpanel.com/track"), QStringLiteral("http://mixpanel.com")},
63 {QStringLiteral("Front App"), QStringLiteral("web.frontapp.com/api"), QStringLiteral("http://frontapp.com")},
64 {QStringLiteral("Mailtrack.io"), QStringLiteral("mailtrack.io/trace"), QStringLiteral("http://mailtrack.io")},
65 {QStringLiteral("ToutApp"), QStringLiteral("go.toutapp.com"), QStringLiteral("http://toutapp.com")},
66 {QStringLiteral("Outreach"), QStringLiteral("app.outreach.io"), QStringLiteral("http://outreach.io")}};
67 // https://github.com/JannikArndt/EMailTrackerBlocker
68}
69
70bool BlockTrackingUrlInterceptor::enabledMailTrackingInterceptor() const
71{
72 return mEnabledMailTrackingInterceptor;
73}
74
75void BlockTrackingUrlInterceptor::setEnabledMailTrackingInterceptor(bool enabledMailTrackingInterceptor)
76{
77 mEnabledMailTrackingInterceptor = enabledMailTrackingInterceptor;
78}
79
80QDebug operator<<(QDebug d, const WebEngineViewer::BlockTrackingUrlInterceptor::TrackerBlackList &t)
81{
82 d << "CompanyName : " << t.mCompanyName;
83 d << "mCompanyUrl : " << t.mCompanyUrl;
84 d << "mPattern : " << t.mPattern;
85 return d;
86}
87
88#include "moc_blocktrackingurlinterceptor.cpp"
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
const_reference at(qsizetype i) const const
qsizetype size() const const
Q_EMITQ_EMIT
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:49:08 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.