mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
AdBlock: Apply all css rules in WebPage::cleanBlockedObjects
This commit is contained in:
parent
a515d92211
commit
509c913cbe
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -390,8 +390,11 @@ bool AdBlockManager::canBeBlocked(const QUrl &url) const
|
||||
return !m_matcher->adBlockDisabledForUrl(url);
|
||||
}
|
||||
|
||||
QString AdBlockManager::elementHidingRules() const
|
||||
QString AdBlockManager::elementHidingRules(const QUrl &url) const
|
||||
{
|
||||
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url))
|
||||
return QString();
|
||||
|
||||
return m_matcher->elementHidingRules();
|
||||
}
|
||||
|
||||
@ -400,10 +403,6 @@ QString AdBlockManager::elementHidingRulesForDomain(const QUrl &url) const
|
||||
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url))
|
||||
return QString();
|
||||
|
||||
// Acid3 doesn't like the way element hiding rules are embedded into page
|
||||
if (url.host() == QLatin1String("acid3.acidtests.org"))
|
||||
return QString();
|
||||
|
||||
return m_matcher->elementHidingRulesForDomain(url.host());
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -51,7 +51,7 @@ public:
|
||||
bool useLimitedEasyList() const;
|
||||
void setUseLimitedEasyList(bool useLimited);
|
||||
|
||||
QString elementHidingRules() const;
|
||||
QString elementHidingRules(const QUrl &url) const;
|
||||
QString elementHidingRulesForDomain(const QUrl &url) const;
|
||||
|
||||
AdBlockSubscription* subscriptionByName(const QString &name) const;
|
||||
|
@ -1079,7 +1079,6 @@ void MainApplication::setUserStyleSheet(const QString &filePath)
|
||||
userCss += QString("::selection {background: %1; color: %2;} ").arg(highlightColor, highlightedTextColor);
|
||||
#endif
|
||||
|
||||
userCss += AdBlockManager::instance()->elementHidingRules().replace(QL1S("\""), QL1S("\\\""));
|
||||
userCss += QzTools::readAllFileContents(filePath).remove(QLatin1Char('\n'));
|
||||
|
||||
const QString name = QStringLiteral("_qupzilla_userstylesheet");
|
||||
|
@ -467,13 +467,15 @@ void WebPage::cleanBlockedObjects()
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply domain-specific element hiding rules
|
||||
const QString elementHiding = manager->elementHidingRulesForDomain(url());
|
||||
if (elementHiding.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Apply global element hiding rules
|
||||
const QString elementHiding = manager->elementHidingRules(url());
|
||||
if (!elementHiding.isEmpty())
|
||||
runJavaScript(Scripts::setCss(elementHiding), WebPage::SafeJsWorld);
|
||||
|
||||
runJavaScript(Scripts::setCss(elementHiding), WebPage::SafeJsWorld);
|
||||
// Apply domain-specific element hiding rules
|
||||
const QString siteElementHiding = manager->elementHidingRulesForDomain(url());
|
||||
if (!siteElementHiding.isEmpty())
|
||||
runJavaScript(Scripts::setCss(siteElementHiding), WebPage::SafeJsWorld);
|
||||
}
|
||||
|
||||
bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result)
|
||||
|
Loading…
Reference in New Issue
Block a user