mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
AdBlock: Workaround for "Blocked content" page
- QtWebEngine blocks redirection to "data:" urls. - Includes light / dark style Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
ac5c280cf4
commit
66572867d4
|
@ -6,6 +6,7 @@ Version 23.04.0
|
|||
* PyFalkon: addBookmark - make C++ own parameters (fixes potential crash)
|
||||
* KWallet: Store passwords in a map format
|
||||
* History: Don't delete all items under dates when filtering
|
||||
* AdBlock: Workaround for "Blocked content" page
|
||||
|
||||
Version 22.08.2
|
||||
* Fix: Typing text in the search bar sends data although suggestions are disabled (by Juraj Oravec) (BUG: 439268)
|
||||
|
|
|
@ -37,14 +37,13 @@ void AdBlockUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &request)
|
|||
}
|
||||
|
||||
if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) {
|
||||
QString page;
|
||||
page.append(QzTools::readAllFileContents(QSL(":adblock/data/adblock.html")));
|
||||
page.replace(QSL("%FAVICON%"), QSL("qrc:adblock/data/adblock_big.png"));
|
||||
page.replace(QSL("%IMAGE%"), QSL("qrc:adblock/data/adblock_big.png"));
|
||||
page.replace(QSL("%TITLE%"), tr("Blocked content"));
|
||||
page.replace(QSL("%RULE%"), tr("Blocked by <i>%1 (%2)</i>").arg(ruleFilter, ruleSubscription));
|
||||
page = QzTools::applyDirectionToPage(page);
|
||||
request.redirect(QUrl(QString::fromUtf8(QByteArray("data:text/html;base64,") + page.toUtf8().toBase64())));
|
||||
QString url = QSL("qrc:adblock/data/adblock.html?direction=%DIRECTION%&title=%1&rule=%3").arg(
|
||||
tr("Blocked content"),
|
||||
tr("Blocked by <i>%1 (%2)</i>").arg(ruleFilter, ruleSubscription)
|
||||
);
|
||||
url = QzTools::applyDirectionToPage(url);
|
||||
|
||||
request.redirect(QUrl(url));
|
||||
} else {
|
||||
request.block(true);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,36 @@
|
|||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>%TITLE%</title>
|
||||
<link rel="icon" href="%FAVICON%" type="image/x-icon" />
|
||||
<title>Blocked content</title>
|
||||
<link rel="icon" href="adblock_big.png" type="image/x-icon" />
|
||||
<style>
|
||||
html {background: #dddddd;}
|
||||
body {background: #dddddd;}
|
||||
#box {background: #ffffff;max-width: 300px;height: 80%;overflow:auto;padding: 25px;padding-bottom: 10px;text-align: center;vertical-align: middle;margin: auto;direction: %DIRECTION%;}
|
||||
#box {max-width: 300px;height: 80%;overflow:auto;padding: 25px;padding-bottom: 10px;text-align: center;vertical-align: middle;margin: auto;}
|
||||
h2 {font-size: 100%;font-weight: bold; border-bottom: 1px solid #f4f4f4; margin-bottom: 0px;}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
html, body {background: #dddddd;color: #525c66;}
|
||||
#box {background: #ffffff;}
|
||||
h2 {border-bottom-color: #aaa;}
|
||||
.dark {display: none;}
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html, body {background: #070709;color: #dddddd;}
|
||||
#box {background: #171717;}
|
||||
h2 {border-bottom-color: #555;}
|
||||
.light {display: none;}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="box">
|
||||
<img src="%IMAGE%" >
|
||||
<img src="adblock_big.png" >
|
||||
<h2>AdBlock</h2>
|
||||
%RULE%
|
||||
<span id="rule"></span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let params = (new URL(document.location)).searchParams;
|
||||
document.title = params.get("title");
|
||||
document.getElementById("rule").innerHTML = params.get("rule");
|
||||
document.getElementById("box").style.direction = params.get("direction");
|
||||
</script>
|
||||
</body></html>
|
||||
|
|
Loading…
Reference in New Issue
Block a user