#include "urlinterceptor.h" UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) : QWebEngineUrlRequestInterceptor(parent) { } void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) { for(BlockerRule *rule : m_sub->urlWhitelist()) { if(rule->match(info.requestUrl())) { qDebug("OK %s", qUtf8Printable(info.requestUrl().toString())); return; } } for(BlockerRule *rule : m_sub->urlBlacklist()) { if(rule->match(info.requestUrl())) { info.block(true); qDebug(" %s", qUtf8Printable(info.requestUrl().toString())); return; } } qDebug("OK %s", qUtf8Printable(info.requestUrl().toString())); } void UrlRequestInterceptor::setSubscription(BlockerSubscription *subscription) { m_sub = subscription; }