mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
GreaseMonkey: Add support for run-at: document-idle
This commit is contained in:
parent
7ac45b75d7
commit
0da388f206
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* GreaseMonkey plugin for QupZilla
|
* GreaseMonkey plugin for QupZilla
|
||||||
* Copyright (C) 2012-2014 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2012-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
|
||||||
|
@ -141,10 +141,25 @@ QString GM_Script::fileName() const
|
||||||
|
|
||||||
QWebEngineScript GM_Script::webScript() const
|
QWebEngineScript GM_Script::webScript() const
|
||||||
{
|
{
|
||||||
|
QWebEngineScript::InjectionPoint injectionPoint;
|
||||||
|
switch (startAt()) {
|
||||||
|
case DocumentStart:
|
||||||
|
injectionPoint = QWebEngineScript::DocumentCreation;
|
||||||
|
break;
|
||||||
|
case DocumentEnd:
|
||||||
|
injectionPoint = QWebEngineScript::DocumentReady;
|
||||||
|
break;
|
||||||
|
case DocumentIdle:
|
||||||
|
injectionPoint = QWebEngineScript::Deferred;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
QWebEngineScript script;
|
QWebEngineScript script;
|
||||||
script.setName(fullName());
|
script.setName(fullName());
|
||||||
script.setInjectionPoint(startAt() == DocumentStart ? QWebEngineScript::DocumentCreation : QWebEngineScript::DocumentReady);
|
|
||||||
script.setWorldId(QWebEngineScript::MainWorld);
|
script.setWorldId(QWebEngineScript::MainWorld);
|
||||||
|
script.setInjectionPoint(injectionPoint);
|
||||||
script.setRunsOnSubFrames(!m_noframes);
|
script.setRunsOnSubFrames(!m_noframes);
|
||||||
script.setSourceCode(QSL("%1\n%2\n%3").arg(m_metadata, m_manager->bootstrapScript(), m_script));
|
script.setSourceCode(QSL("%1\n%2\n%3").arg(m_metadata, m_manager->bootstrapScript(), m_script));
|
||||||
return script;
|
return script;
|
||||||
|
@ -274,6 +289,9 @@ void GM_Script::parseScript()
|
||||||
else if (value == QLatin1String("document-start")) {
|
else if (value == QLatin1String("document-start")) {
|
||||||
m_startAt = DocumentStart;
|
m_startAt = DocumentStart;
|
||||||
}
|
}
|
||||||
|
else if (value == QLatin1String("document-idle")) {
|
||||||
|
m_startAt = DocumentIdle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (key == QLatin1String("@downloadURL") && m_downloadUrl.isEmpty()) {
|
else if (key == QLatin1String("@downloadURL") && m_downloadUrl.isEmpty()) {
|
||||||
m_downloadUrl = QUrl(value);
|
m_downloadUrl = QUrl(value);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* GreaseMonkey plugin for QupZilla
|
* GreaseMonkey plugin for QupZilla
|
||||||
* Copyright (C) 2012-2014 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2012-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
|
||||||
|
@ -37,7 +37,7 @@ class GM_Script : public QObject
|
||||||
public:
|
public:
|
||||||
explicit GM_Script(GM_Manager* manager, const QString &filePath);
|
explicit GM_Script(GM_Manager* manager, const QString &filePath);
|
||||||
|
|
||||||
enum StartAt { DocumentStart, DocumentEnd };
|
enum StartAt { DocumentStart, DocumentEnd, DocumentIdle };
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user