mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
AdBlock: Fix hiding iframes that have completely blocked contents
Closes #1552
This commit is contained in:
parent
d28154c3d2
commit
a750858ed7
@ -823,22 +823,24 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
|
|||||||
}
|
}
|
||||||
case QNetworkReply::ContentAccessDenied:
|
case QNetworkReply::ContentAccessDenied:
|
||||||
if (exOption->errorString.startsWith(QLatin1String("AdBlock"))) {
|
if (exOption->errorString.startsWith(QLatin1String("AdBlock"))) {
|
||||||
if (exOption->frame != erPage->mainFrame()) { //Content in <iframe>
|
if (exOption->frame != erPage->mainFrame()) {
|
||||||
|
// Content in <iframe>
|
||||||
QWebElement docElement = erPage->mainFrame()->documentElement();
|
QWebElement docElement = erPage->mainFrame()->documentElement();
|
||||||
|
|
||||||
QWebElementCollection elements;
|
QWebElementCollection elements;
|
||||||
elements.append(docElement.findAll("iframe"));
|
elements.append(docElement.findAll("iframe"));
|
||||||
|
|
||||||
foreach (QWebElement element, elements) {
|
foreach (QWebElement element, elements) {
|
||||||
QString src = element.attribute("src");
|
const QString src = element.attribute("src");
|
||||||
if (exOption->url.toString().contains(src)) {
|
if (!src.isEmpty() && exOption->url.toString().contains(src)) {
|
||||||
element.setStyleProperty("visibility", "hidden");
|
element.setStyleProperty("visibility", "hidden");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else { //The whole page is blocked
|
else {
|
||||||
|
// The whole page is blocked
|
||||||
QString rule = exOption->errorString;
|
QString rule = exOption->errorString;
|
||||||
rule.remove(QLatin1String("AdBlock: "));
|
rule.remove(QLatin1String("AdBlock: "));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user