From 4b5029e208affc15cde07006ea91d4a28c243a57 Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Thu, 27 Jul 2017 08:58:30 +0200 Subject: [PATCH] Doc: Add example code for using Greasemonkey attributes in scripts Task-number: QTBUG-61788 Change-Id: Ie6c29f3999ea795a37ea444f56e40ddc70ca1c03 Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/webengine/doc/src/external-resources.qdoc | 10 ++++++++ .../doc/src/qtwebengine-overview.qdoc | 25 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc index a75c7aaed..6cced588c 100644 --- a/src/webengine/doc/src/external-resources.qdoc +++ b/src/webengine/doc/src/external-resources.qdoc @@ -136,3 +136,13 @@ \externalpage https://http2.akamai.com/demo \title Akamai HTTP/2 Demo */ + +/*! + \externalpage https://www.chromium.org/developers/design-documents/user-scripts + \title User Scripts +*/ + +/*! + \externalpage https://wiki.greasespot.net/Metadata_Block#.40name + \title Metadata Block +*/ diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc index e180b22c0..e9ca573b7 100644 --- a/src/webengine/doc/src/qtwebengine-overview.qdoc +++ b/src/webengine/doc/src/qtwebengine-overview.qdoc @@ -181,8 +181,29 @@ script to run, the injection point, and the world where the script is run. This enables accessing the DOM to manipulate it within a world. - The following \l Greasemonkey attributes are supported since Qt 5.8: - \c @exclude, \c @include, \c @name, \c @match, and \c @run-at. + Since Qt 5.8, Qt WebEngine supports augmenting a script by using the + following \l{Metadata Block}{Greasemonkey-like attributes}: + + \list + \li \c {@exclude <regexp>} + \li \c {@include <regexp>} + \li \c {@match <regexp>} + \li \c {@name <free text>} + \li \c {@run-at [document-start|document-end|document-idle]} + \endlist + + The attributes determine if and when a \l {User Scripts}{user script} is + run. They must be placed immediately in the beginning of the script, inside + a \c ==UserScript== comment: + + \code + // ==UserScript== + // @include http://*.qt.io/* + // @exclude http://wiki.qt.io/* + // ==/UserScript== + + window.alert("Page is from qt.io, but not wiki.qt.io"); + \endcode \section1 Managing Certificates -- GitLab