mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
GreaseMonkey: Fix detecting *.user.js urls
Test Plan: Try to install userscript from http://greasyfork.org/ Reviewers: #falkon, drosca Reviewed By: #falkon, drosca Subscribers: falkon Tags: #falkon Differential Revision: https://phabricator.kde.org/D26436
This commit is contained in:
parent
c934e40440
commit
6974f8c254
@ -25,6 +25,8 @@
|
|||||||
#include "webtab.h"
|
#include "webtab.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
|
#include <QtWebEngineVersion>
|
||||||
|
|
||||||
GM_Plugin::GM_Plugin()
|
GM_Plugin::GM_Plugin()
|
||||||
: QObject()
|
: QObject()
|
||||||
, m_manager(0)
|
, m_manager(0)
|
||||||
@ -69,7 +71,13 @@ bool GM_Plugin::acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEngi
|
|||||||
Q_UNUSED(page)
|
Q_UNUSED(page)
|
||||||
Q_UNUSED(isMainFrame)
|
Q_UNUSED(isMainFrame)
|
||||||
|
|
||||||
if (type == QWebEnginePage::NavigationTypeLinkClicked && url.toString().endsWith(QLatin1String(".user.js"))) {
|
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
bool navigationType = type == QWebEnginePage::NavigationTypeLinkClicked || type == QWebEnginePage::NavigationTypeRedirect;
|
||||||
|
#else
|
||||||
|
bool navigationType = type == QWebEnginePage::NavigationTypeLinkClicked;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (navigationType && url.toString().endsWith(QLatin1String(".user.js"))) {
|
||||||
m_manager->downloadScript(url);
|
m_manager->downloadScript(url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user