mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
AdBlock: Apply all css rules in WebPage::cleanBlockedObjects
This commit is contained in:
parent
00df74bd64
commit
d1f266cc49
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* 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);
|
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();
|
return m_matcher->elementHidingRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,10 +403,6 @@ QString AdBlockManager::elementHidingRulesForDomain(const QUrl &url) const
|
|||||||
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url))
|
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url))
|
||||||
return QString();
|
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());
|
return m_matcher->elementHidingRulesForDomain(url.host());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -51,7 +51,7 @@ public:
|
|||||||
bool useLimitedEasyList() const;
|
bool useLimitedEasyList() const;
|
||||||
void setUseLimitedEasyList(bool useLimited);
|
void setUseLimitedEasyList(bool useLimited);
|
||||||
|
|
||||||
QString elementHidingRules() const;
|
QString elementHidingRules(const QUrl &url) const;
|
||||||
QString elementHidingRulesForDomain(const QUrl &url) const;
|
QString elementHidingRulesForDomain(const QUrl &url) const;
|
||||||
|
|
||||||
AdBlockSubscription* subscriptionByName(const QString &name) 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);
|
userCss += QString("::selection {background: %1; color: %2;} ").arg(highlightColor, highlightedTextColor);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
userCss += AdBlockManager::instance()->elementHidingRules().replace(QL1S("\""), QL1S("\\\""));
|
|
||||||
userCss += QzTools::readAllFileContents(filePath).remove(QLatin1Char('\n'));
|
userCss += QzTools::readAllFileContents(filePath).remove(QLatin1Char('\n'));
|
||||||
|
|
||||||
const QString name = QStringLiteral("_qupzilla_userstylesheet");
|
const QString name = QStringLiteral("_qupzilla_userstylesheet");
|
||||||
|
@ -428,13 +428,15 @@ void WebPage::cleanBlockedObjects()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply domain-specific element hiding rules
|
// Apply global element hiding rules
|
||||||
const QString elementHiding = manager->elementHidingRulesForDomain(url());
|
const QString elementHiding = manager->elementHidingRules(url());
|
||||||
if (elementHiding.isEmpty()) {
|
if (!elementHiding.isEmpty())
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
runJavaScript(Scripts::setCss(elementHiding));
|
runJavaScript(Scripts::setCss(elementHiding));
|
||||||
|
|
||||||
|
// Apply domain-specific element hiding rules
|
||||||
|
const QString siteElementHiding = manager->elementHidingRulesForDomain(url());
|
||||||
|
if (!siteElementHiding.isEmpty())
|
||||||
|
runJavaScript(Scripts::setCss(siteElementHiding));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result)
|
bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result)
|
||||||
|
Loading…
Reference in New Issue
Block a user