mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
AdBlock: Add DuckDuckGo ad whitelist rules to custom list
Those rules cannot be deleted, but can be disabled. Please consider not disabling those rules. Thanks!
This commit is contained in:
parent
26f466ed0d
commit
e5065185fd
@ -505,6 +505,32 @@ AdBlockCustomList::AdBlockCustomList(QObject* parent)
|
|||||||
setFilePath(DataPaths::currentProfilePath() + QLatin1String("/adblock/customlist.txt"));
|
setFilePath(DataPaths::currentProfilePath() + QLatin1String("/adblock/customlist.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdBlockCustomList::loadSubscription(const QStringList &disabledRules)
|
||||||
|
{
|
||||||
|
// DuckDuckGo ad whitelist rules
|
||||||
|
// They cannot be removed, but can be disabled.
|
||||||
|
// Please consider not disabling them. Thanks!
|
||||||
|
|
||||||
|
const QString ddg1 = QSL("@@||duckduckgo.com^$document");
|
||||||
|
const QString ddg2 = QSL("duckduckgo.com#@#.has-ad");
|
||||||
|
|
||||||
|
const QString rules = QzTools::readAllFileContents(filePath());
|
||||||
|
|
||||||
|
QFile file(filePath());
|
||||||
|
if (file.open(QFile::WriteOnly | QFile::Append)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
|
||||||
|
if (!rules.contains(ddg1))
|
||||||
|
stream << ddg1;
|
||||||
|
|
||||||
|
if (!rules.contains(ddg2))
|
||||||
|
stream << ddg2;
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
AdBlockSubscription::loadSubscription(disabledRules);
|
||||||
|
}
|
||||||
|
|
||||||
void AdBlockCustomList::saveSubscription()
|
void AdBlockCustomList::saveSubscription()
|
||||||
{
|
{
|
||||||
QFile file(filePath());
|
QFile file(filePath());
|
||||||
|
@ -143,6 +143,7 @@ class AdBlockCustomList : public AdBlockSubscription
|
|||||||
public:
|
public:
|
||||||
explicit AdBlockCustomList(QObject* parent = 0);
|
explicit AdBlockCustomList(QObject* parent = 0);
|
||||||
|
|
||||||
|
void loadSubscription(const QStringList &disabledRules);
|
||||||
void saveSubscription();
|
void saveSubscription();
|
||||||
|
|
||||||
bool canEditRules() const;
|
bool canEditRules() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user