mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-31 17:44:52 +01:00
Simplify.
This commit is contained in:
parent
6bdb1446a1
commit
7f752a854f
@ -157,7 +157,7 @@ You can right click on any item in embedded web browser and hit `Save as` button
|
||||
You can download up to 6 files simultaneously.
|
||||
|
||||
## AdBlock
|
||||
[Web-based variant](#web-based-and-lite-app-variants) of RSS Guard offers ad-blocking functionality. AdBlock uses standard AdBlock-Plus-like scripts, thus allowing you to use EasyList etc. AdBlock supports element hiding rules and site-wide blocking.
|
||||
[Web-based variant](#web-based-and-lite-app-variants) of RSS Guard offers ad-blocking functionality. AdBlock uses standard AdBlock-Plus-like scripts, thus allowing you to use EasyList etc. AdBlock supports all fundamental features of AdBlock-Plus format, including element hiding rules and site-wide blocking.
|
||||
|
||||
You can find its settings in `Web browser & tabs` section of main menu.
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#define ARGUMENTS_LIST_SEPARATOR "\n"
|
||||
|
||||
#define ADBLOCK_ADBLOCKED_PAGE "adblockedpage"
|
||||
#define ADBLOCK_HOWTO_FILTERS "https://help.eyeo.com/en/adblockplus/how-to-write-filters"
|
||||
#define ADBLOCK_UPDATE_DAYS_INTERVAL 14
|
||||
#define ADBLOCK_ICON_ACTIVE "adblock"
|
||||
@ -116,6 +115,7 @@
|
||||
|
||||
#define INTERNAL_URL_MESSAGE "http://rssguard.message"
|
||||
#define INTERNAL_URL_BLANK "http://rssguard.blank"
|
||||
#define INTERNAL_URL_ADBLOCKED "http://rssguard.adblocked"
|
||||
#define INTERNAL_URL_MESSAGE_HOST "rssguard.message"
|
||||
#define INTERNAL_URL_BLANK_HOST "rssguard.blank"
|
||||
#define INTERNAL_URL_PASSATTACHMENT "http://rssguard.passattachment"
|
||||
|
@ -386,16 +386,14 @@ equals(USE_WEBENGINE, true) {
|
||||
gui/webbrowser.h \
|
||||
gui/discoverfeedsbutton.h \
|
||||
network-web/googlesuggest.h \
|
||||
network-web/webpage.h \
|
||||
network-web/rssguardschemehandler.h
|
||||
network-web/webpage.h
|
||||
|
||||
SOURCES += gui/locationlineedit.cpp \
|
||||
gui/webviewer.cpp \
|
||||
gui/webbrowser.cpp \
|
||||
gui/discoverfeedsbutton.cpp \
|
||||
network-web/googlesuggest.cpp \
|
||||
network-web/webpage.cpp \
|
||||
network-web/rssguardschemehandler.cpp
|
||||
network-web/webpage.cpp
|
||||
|
||||
# Add AdBlock sources.
|
||||
HEADERS += network-web/adblock/adblockaddsubscriptiondialog.h \
|
||||
|
@ -1,62 +0,0 @@
|
||||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||
//
|
||||
// RSS Guard is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// RSS Guard is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "network-web/rssguardschemehandler.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/skinfactory.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QUrlQuery>
|
||||
#include <QWebEngineUrlRequestJob>
|
||||
|
||||
RssGuardSchemeHandler::RssGuardSchemeHandler(QObject* parent) : QWebEngineUrlSchemeHandler(parent) {}
|
||||
|
||||
RssGuardSchemeHandler::~RssGuardSchemeHandler() = default;
|
||||
|
||||
void RssGuardSchemeHandler::requestStarted(QWebEngineUrlRequestJob* job) {
|
||||
// Decide which data we want.
|
||||
QByteArray data = targetData(job->requestUrl());
|
||||
|
||||
if (data.isEmpty()) {
|
||||
job->fail(QWebEngineUrlRequestJob::Error::UrlNotFound);
|
||||
}
|
||||
else {
|
||||
auto* buf = new QBuffer(job);
|
||||
|
||||
buf->setData(data);
|
||||
job->reply(QByteArray("text/html"), buf);
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray RssGuardSchemeHandler::targetData(const QUrl& url) {
|
||||
const QString& url_string = url.toString();
|
||||
|
||||
if (url_string.contains(QSL(ADBLOCK_ADBLOCKED_PAGE))) {
|
||||
QUrlQuery query(url);
|
||||
const QString& subscription = query.queryItemValue(QSL("subscription"));
|
||||
const QString& rule = query.queryItemValue(QSL("rule"));
|
||||
|
||||
return qApp->skins()->adBlockedPage(subscription, rule).toUtf8();
|
||||
}
|
||||
else {
|
||||
return QByteArray();
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
//
|
||||
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||
//
|
||||
// RSS Guard is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// RSS Guard is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef RSSGUARDSCHEMEHANDLER_H
|
||||
#define RSSGUARDSCHEMEHANDLER_H
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QWebEngineUrlSchemeHandler>
|
||||
|
||||
class QWebEngineUrlRequestJob;
|
||||
class QBuffer;
|
||||
|
||||
class RssGuardSchemeHandler : public QWebEngineUrlSchemeHandler {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RssGuardSchemeHandler(QObject* parent = nullptr);
|
||||
virtual ~RssGuardSchemeHandler();
|
||||
|
||||
void requestStarted(QWebEngineUrlRequestJob* job);
|
||||
|
||||
private:
|
||||
QByteArray targetData(const QUrl& url);
|
||||
};
|
||||
|
||||
#endif // RSSGUARDSCHEMEHANDLER_H
|
@ -13,7 +13,6 @@
|
||||
#include "network-web/adblock/adblockicon.h"
|
||||
#include "network-web/adblock/adblockmanager.h"
|
||||
#include "network-web/networkurlinterceptor.h"
|
||||
#include "network-web/rssguardschemehandler.h"
|
||||
#include "network-web/urlinterceptor.h"
|
||||
|
||||
#include <QWebEngineDownloadItem>
|
||||
@ -32,25 +31,11 @@ WebFactory::WebFactory(QObject* parent)
|
||||
#endif
|
||||
|
||||
#if defined(USE_WEBENGINE)
|
||||
QWebEngineUrlScheme url_scheme(QByteArray(APP_LOW_NAME));
|
||||
|
||||
url_scheme.setDefaultPort(QWebEngineUrlScheme::SpecialPort::PortUnspecified);
|
||||
url_scheme.setSyntax(QWebEngineUrlScheme::Syntax::Host);
|
||||
url_scheme.setFlags(QWebEngineUrlScheme::Flag::LocalScheme |
|
||||
QWebEngineUrlScheme::Flag::LocalAccessAllowed |
|
||||
QWebEngineUrlScheme::Flag::ServiceWorkersAllowed |
|
||||
QWebEngineUrlScheme::Flag::ContentSecurityPolicyIgnored);
|
||||
|
||||
QWebEngineUrlScheme::registerScheme(url_scheme);
|
||||
|
||||
#if QT_VERSION >= 0x050D00 // Qt >= 5.13.0
|
||||
QWebEngineProfile::defaultProfile()->setUrlRequestInterceptor(m_urlInterceptor);
|
||||
#else
|
||||
QWebEngineProfile::defaultProfile()->setRequestInterceptor(m_urlInterceptor);
|
||||
#endif
|
||||
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler(QByteArray(APP_LOW_NAME),
|
||||
new RssGuardSchemeHandler(QWebEngineProfile::defaultProfile()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -61,14 +61,8 @@ bool WebPage::acceptNavigationRequest(const QUrl& url, NavigationType type, bool
|
||||
|
||||
if (adblock_rule != nullptr) {
|
||||
// This website is entirely blocked.
|
||||
QUrlQuery query;
|
||||
QUrl new_url(QSL("%1:///%2/").arg(APP_LOW_NAME, ADBLOCK_ADBLOCKED_PAGE));
|
||||
|
||||
query.addQueryItem(QSL("rule"), adblock_rule->filter());
|
||||
query.addQueryItem(QSL("subscription"), adblock_rule->subscription()->title());
|
||||
new_url.setQuery(query);
|
||||
|
||||
setUrl(new_url);
|
||||
setHtml(qApp->skins()->adBlockedPage(adblock_rule->subscription()->title(), adblock_rule->filter()),
|
||||
QUrl::fromUserInput(INTERNAL_URL_ADBLOCKED));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user