diff --git a/CHANGELOG b/CHANGELOG index 6e1ef665e..ef30375c0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ Version 1.5.0 * GreaseMonkey: added icon in statusbar * GreaseMonkey: added support for GM_Settings * GreaseMonkey: fixed userscripts when first loading plugin + * GreaseMonkey: run userscripts in all frames on page * oxygen: set rounded corners for tooltips * oxygen: workaround for transparent background of tooltips * X11: Set correct WM_CLASS property to windows diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index 793a4e493..decd5cc05 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -649,7 +649,7 @@ QString QzTools::escape(const QString &string) } #if defined(QZ_WS_X11) && !defined(NO_X11) -void *QzTools::X11Display(const QWidget* widget) +void* QzTools::X11Display(const QWidget* widget) { Q_UNUSED(widget) diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp index c031e16f1..8fa195b96 100644 --- a/src/plugins/GreaseMonkey/gm_manager.cpp +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -196,31 +196,40 @@ void GM_Manager::showNotification(const QString &message, const QString &title) void GM_Manager::pageLoadStart() { - QWebFrame* frame = qobject_cast(sender()); - if (!frame) { + QWebFrame* mainFrame = qobject_cast(sender()); + if (!mainFrame) { return; } - const QString &urlScheme = frame->url().scheme(); - const QString &urlString = frame->url().toEncoded(); + const QString &urlScheme = mainFrame->url().scheme(); + const QString &urlString = mainFrame->url().toEncoded(); if (!canRunOnScheme(urlScheme)) { return; } - frame->addToJavaScriptWindowObject("_qz_greasemonkey", m_jsObject); + // Run it in every frame + QList 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) { - if (script->match(urlString)) { - frame->evaluateJavaScript(m_bootstrap + script->script()); - } - } + foreach (GM_Script* script, m_startScripts) { + if (script->match(urlString)) { + mainFrame->evaluateJavaScript(m_bootstrap + script->script()); + } + } - foreach (GM_Script* script, m_endScripts) { - if (script->match(urlString)) { - const QString &jscript = QString("window.addEventListener(\"DOMContentLoaded\"," - "function(e) { \n%1\n }, false);").arg(m_bootstrap + script->script()); - frame->evaluateJavaScript(jscript); + foreach (GM_Script* script, m_endScripts) { + if (script->match(urlString)) { + const QString &jscript = QString("window.addEventListener(\"DOMContentLoaded\"," + "function(e) { \n%1\n }, false);").arg(m_bootstrap + script->script()); + mainFrame->evaluateJavaScript(jscript); + } + } + frames += frame->childFrames(); } } } diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index cd9289826..0f23378e2 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -41,7 +41,7 @@ PluginSpec GM_Plugin::pluginSpec() spec.name = "GreaseMonkey"; spec.info = "Userscripts for QupZilla"; spec.description = "Provides support for userscripts (www.userscripts.org)"; - spec.version = "0.4.1"; + spec.version = "0.4.2"; spec.author = "David Rosca "; spec.icon = QPixmap(":gm/data/icon.png"); spec.hasSettings = true;