mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
GreaseMonkey: Run usercscripts in all frames on page
This commit is contained in:
parent
7a75153b9f
commit
567d6c74f4
|
@ -16,6 +16,7 @@ Version 1.5.0
|
||||||
* GreaseMonkey: added icon in statusbar
|
* GreaseMonkey: added icon in statusbar
|
||||||
* GreaseMonkey: added support for GM_Settings
|
* GreaseMonkey: added support for GM_Settings
|
||||||
* GreaseMonkey: fixed userscripts when first loading plugin
|
* GreaseMonkey: fixed userscripts when first loading plugin
|
||||||
|
* GreaseMonkey: run userscripts in all frames on page
|
||||||
* oxygen: set rounded corners for tooltips
|
* oxygen: set rounded corners for tooltips
|
||||||
* oxygen: workaround for transparent background of tooltips
|
* oxygen: workaround for transparent background of tooltips
|
||||||
* X11: Set correct WM_CLASS property to windows
|
* X11: Set correct WM_CLASS property to windows
|
||||||
|
|
|
@ -649,7 +649,7 @@ QString QzTools::escape(const QString &string)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QZ_WS_X11) && !defined(NO_X11)
|
#if defined(QZ_WS_X11) && !defined(NO_X11)
|
||||||
void *QzTools::X11Display(const QWidget* widget)
|
void* QzTools::X11Display(const QWidget* widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
|
|
@ -196,31 +196,40 @@ void GM_Manager::showNotification(const QString &message, const QString &title)
|
||||||
|
|
||||||
void GM_Manager::pageLoadStart()
|
void GM_Manager::pageLoadStart()
|
||||||
{
|
{
|
||||||
QWebFrame* frame = qobject_cast<QWebFrame*>(sender());
|
QWebFrame* mainFrame = qobject_cast<QWebFrame*>(sender());
|
||||||
if (!frame) {
|
if (!mainFrame) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &urlScheme = frame->url().scheme();
|
const QString &urlScheme = mainFrame->url().scheme();
|
||||||
const QString &urlString = frame->url().toEncoded();
|
const QString &urlString = mainFrame->url().toEncoded();
|
||||||
|
|
||||||
if (!canRunOnScheme(urlScheme)) {
|
if (!canRunOnScheme(urlScheme)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->addToJavaScriptWindowObject("_qz_greasemonkey", m_jsObject);
|
// Run it in every frame
|
||||||
|
QList<QWebFrame*> frames;
|
||||||
|
frames.append(mainFrame);
|
||||||
|
while (!frames.isEmpty()) {
|
||||||
|
QWebFrame* frame = frames.takeFirst();
|
||||||
|
if (frame) {
|
||||||
|
mainFrame->addToJavaScriptWindowObject("_qz_greasemonkey", m_jsObject);
|
||||||
|
|
||||||
foreach (GM_Script* script, m_startScripts) {
|
foreach (GM_Script* script, m_startScripts) {
|
||||||
if (script->match(urlString)) {
|
if (script->match(urlString)) {
|
||||||
frame->evaluateJavaScript(m_bootstrap + script->script());
|
mainFrame->evaluateJavaScript(m_bootstrap + script->script());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (GM_Script* script, m_endScripts) {
|
foreach (GM_Script* script, m_endScripts) {
|
||||||
if (script->match(urlString)) {
|
if (script->match(urlString)) {
|
||||||
const QString &jscript = QString("window.addEventListener(\"DOMContentLoaded\","
|
const QString &jscript = QString("window.addEventListener(\"DOMContentLoaded\","
|
||||||
"function(e) { \n%1\n }, false);").arg(m_bootstrap + script->script());
|
"function(e) { \n%1\n }, false);").arg(m_bootstrap + script->script());
|
||||||
frame->evaluateJavaScript(jscript);
|
mainFrame->evaluateJavaScript(jscript);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frames += frame->childFrames();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ PluginSpec GM_Plugin::pluginSpec()
|
||||||
spec.name = "GreaseMonkey";
|
spec.name = "GreaseMonkey";
|
||||||
spec.info = "Userscripts for QupZilla";
|
spec.info = "Userscripts for QupZilla";
|
||||||
spec.description = "Provides support for userscripts (www.userscripts.org)";
|
spec.description = "Provides support for userscripts (www.userscripts.org)";
|
||||||
spec.version = "0.4.1";
|
spec.version = "0.4.2";
|
||||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||||
spec.icon = QPixmap(":gm/data/icon.png");
|
spec.icon = QPixmap(":gm/data/icon.png");
|
||||||
spec.hasSettings = true;
|
spec.hasSettings = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user