newer mariadb version, work on adblock
This commit is contained in:
parent
0617ad7d19
commit
cf5edc2558
5 changed files with 58 additions and 7 deletions
|
@ -30,7 +30,7 @@
|
|||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="3.9.0" date="2021-05-07"/>
|
||||
<release version="3.9.2" date="2021-05-07"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
|
|
@ -23,7 +23,7 @@ $qt_version = "5.15.2"
|
|||
$qt_link = "https://github.com/qt/qtbase/archive/$qt_version.zip"
|
||||
$qt_output = "qt.zip"
|
||||
|
||||
$maria_version = "10.5.8"
|
||||
$maria_version = "10.5.9"
|
||||
$maria_link = "https://downloads.mariadb.org/f/mariadb-$maria_version/winx64-packages/mariadb-$maria_version-winx64.zip/from/https%3A//mirror.vpsfree.cz/mariadb/?serve"
|
||||
$maria_output = "maria.zip"
|
||||
|
||||
|
|
|
@ -58,8 +58,9 @@ BlockingResult AdBlockManager::block(const AdblockRequestInfo& request) const {
|
|||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
qCriticalNN << LOGSEC_ADBLOCK
|
||||
<< "HTTP error when calling server:"
|
||||
<< "HTTP error when calling server for blocking rules:"
|
||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
||||
return { false };
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -105,8 +106,22 @@ bool AdBlockManager::canRunOnScheme(const QString& scheme) const {
|
|||
}
|
||||
|
||||
QString AdBlockManager::elementHidingRulesForDomain(const QUrl& url) const {
|
||||
// TODO: call service for cosmetic rules.
|
||||
if (m_serverProcess->state() == QProcess::ProcessState::Running) {
|
||||
try {
|
||||
auto result = askServerForCosmeticRules(url.toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
qCriticalNN << LOGSEC_ADBLOCK
|
||||
<< "HTTP error when calling server for cosmetic rules:"
|
||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
QStringList AdBlockManager::filterLists() const {
|
||||
|
@ -168,7 +183,7 @@ BlockingResult AdBlockManager::askServerIfBlocked(const QString& url) const {
|
|||
|
||||
if (network_res.first == QNetworkReply::NetworkError::NoError) {
|
||||
qDebugNN << LOGSEC_ADBLOCK
|
||||
<< "Query to server took "
|
||||
<< "Query for blocking info to server took "
|
||||
<< tmr.elapsed()
|
||||
<< " ms.";
|
||||
|
||||
|
@ -187,6 +202,41 @@ BlockingResult AdBlockManager::askServerIfBlocked(const QString& url) const {
|
|||
}
|
||||
}
|
||||
|
||||
QString AdBlockManager::askServerForCosmeticRules(const QString& url) const {
|
||||
QJsonObject req_obj;
|
||||
QByteArray out;
|
||||
QElapsedTimer tmr;
|
||||
|
||||
req_obj["url"] = url;
|
||||
req_obj["cosmetic"] = true;
|
||||
|
||||
tmr.start();
|
||||
|
||||
auto network_res = NetworkFactory::performNetworkOperation(QSL("http://%1:%2").arg(QHostAddress(QHostAddress::SpecialAddress::LocalHost).toString(),
|
||||
ADBLOCK_SERVER_PORT),
|
||||
500,
|
||||
QJsonDocument(req_obj).toJson(),
|
||||
out,
|
||||
QNetworkAccessManager::Operation::PostOperation,
|
||||
{ {
|
||||
QSL(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
|
||||
QSL("application/json").toLocal8Bit() } });
|
||||
|
||||
if (network_res.first == QNetworkReply::NetworkError::NoError) {
|
||||
qDebugNN << LOGSEC_ADBLOCK
|
||||
<< "Query for cosmetic rules to server took "
|
||||
<< tmr.elapsed()
|
||||
<< " ms.";
|
||||
|
||||
QJsonObject out_obj = QJsonDocument::fromJson(out).object();
|
||||
|
||||
return out_obj["cosmetic"].toObject()["styles"].toString();
|
||||
}
|
||||
else {
|
||||
throw NetworkException(network_res.first);
|
||||
}
|
||||
}
|
||||
|
||||
void AdBlockManager::restartServer() {
|
||||
if (m_serverProcess->state() == QProcess::ProcessState::Running) {
|
||||
m_serverProcess->kill();
|
||||
|
|
|
@ -59,6 +59,7 @@ class AdBlockManager : public QObject {
|
|||
|
||||
private:
|
||||
BlockingResult askServerIfBlocked(const QString& url) const;
|
||||
QString askServerForCosmeticRules(const QString& url) const;
|
||||
|
||||
void restartServer();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void WebPage::hideUnwantedElements() {
|
|||
auto js = qApp->web()->adBlock()->generateJsForElementHiding(css);
|
||||
|
||||
runJavaScript(js);
|
||||
qDebugNN << LOGSEC_JS << "Running domain-specific JS for element hiding rules.";
|
||||
qDebugNN << LOGSEC_ADBLOCK << "Running domain-specific JS for element hiding rules.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue