Documentation/Source/eric6.WebBrowser.GreaseMonkey.GreaseMonkeyScript.html

Tue, 24 Oct 2017 19:09:09 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 24 Oct 2017 19:09:09 +0200
changeset 5928
a3809f75ca07
parent 5727
c8842a8d1167
child 6123
39cd368143db
permissions
-rw-r--r--

Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.

<!DOCTYPE html>
<html><head>
<title>eric6.WebBrowser.GreaseMonkey.GreaseMonkeyScript</title>
<meta charset="UTF-8">
<style>
body {
    background: #EDECE6;
    margin: 0em 1em 10em 1em;
    color: black;
}

h1 { color: white; background: #85774A; }
h2 { color: white; background: #85774A; }
h3 { color: white; background: #9D936E; }
h4 { color: white; background: #9D936E; }
    
a { color: #BA6D36; }

</style>
</head>
<body><a NAME="top" ID="top"></a>
<h1>eric6.WebBrowser.GreaseMonkey.GreaseMonkeyScript</h1>
<p>
Module implementing the GreaseMonkey script.
</p>
<h3>Global Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Classes</h3>
<table>
<tr>
<td><a href="#GreaseMonkeyScript">GreaseMonkeyScript</a></td>
<td>Class implementing the GreaseMonkey script.</td>
</tr>
</table>
<h3>Functions</h3>
<table>
<tr><td>None</td></tr>
</table>
<hr /><hr />
<a NAME="GreaseMonkeyScript" ID="GreaseMonkeyScript"></a>
<h2>GreaseMonkeyScript</h2>
<p>
    Class implementing the GreaseMonkey script.
</p><h3>Signals</h3>
<dl>
<dt>scriptChanged()</dt>
<dd>
emitted to indicate a script change
</dd><dt>updatingChanged(bool)</dt>
<dd>
emitted to indicate a change of the
        updating state
</dd>
</dl>
<h3>Derived from</h3>
QObject
<h3>Class Attributes</h3>
<table>
<tr><td>DocumentEnd</td></tr><tr><td>DocumentIdle</td></tr><tr><td>DocumentStart</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr>
<td><a href="#GreaseMonkeyScript.__init__">GreaseMonkeyScript</a></td>
<td>Constructor</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__downloadRequires">__downloadRequires</a></td>
<td>Private method to download the required scripts.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__downloaderError">__downloaderError</a></td>
<td>Private slot to handle a downloader error.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__downloaderFinished">__downloaderFinished</a></td>
<td>Private slot to handle a finished download.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__parseScript">__parseScript</a></td>
<td>Private method to parse the given script and populate the data structure.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__reloadScript">__reloadScript</a></td>
<td>Private method to reload the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__requireDownloadError">__requireDownloadError</a></td>
<td>Private slot to handle a downloader error.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__requireDownloaded">__requireDownloaded</a></td>
<td>Private slot to handle a finished download of a required script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__toJavaScriptList">__toJavaScriptList</a></td>
<td>Private method to convert a list of str to a string containing a valid JavaScript list definition.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.__watchedFileChanged">__watchedFileChanged</a></td>
<td>Private slot handling changes of the script file.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.description">description</a></td>
<td>Public method to get the description of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.downloadUrl">downloadUrl</a></td>
<td>Public method to get the download URL of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.exclude">exclude</a></td>
<td>Public method to get the list of excluded URLs.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.fileName">fileName</a></td>
<td>Public method to get the path of the Javascript file.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.fullName">fullName</a></td>
<td>Public method to get the full name of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.include">include</a></td>
<td>Public method to get the list of included URLs.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.isEnabled">isEnabled</a></td>
<td>Public method to check, if the script is enabled.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.isUpdating">isUpdating</a></td>
<td>Public method to get the updating flag.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.isValid">isValid</a></td>
<td>Public method to check the validity of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.name">name</a></td>
<td>Public method to get the name of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.nameSpace">nameSpace</a></td>
<td>Public method to get the name space of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.noFrames">noFrames</a></td>
<td>Public method to get the noFrames flag.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.require">require</a></td>
<td>Public method to get the list of required scripts.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.setEnabled">setEnabled</a></td>
<td>Public method to enable a script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.startAt">startAt</a></td>
<td>Public method to get the start point of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.updateScript">updateScript</a></td>
<td>Public method to updated the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.updateUrl">updateUrl</a></td>
<td>Public method to get the update URL of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.version">version</a></td>
<td>Public method to get the version of the script.</td>
</tr><tr>
<td><a href="#GreaseMonkeyScript.webScript">webScript</a></td>
<td>Public method to create a script object.</td>
</tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<a NAME="GreaseMonkeyScript.__init__" ID="GreaseMonkeyScript.__init__"></a>
<h4>GreaseMonkeyScript (Constructor)</h4>
<b>GreaseMonkeyScript</b>(<i>manager, path</i>)
<p>
        Constructor
</p><dl>
<dt><i>manager</i></dt>
<dd>
reference to the manager object (GreaseMonkeyManager)
</dd><dt><i>path</i></dt>
<dd>
path of the Javascript file (string)
</dd>
</dl><a NAME="GreaseMonkeyScript.__downloadRequires" ID="GreaseMonkeyScript.__downloadRequires"></a>
<h4>GreaseMonkeyScript.__downloadRequires</h4>
<b>__downloadRequires</b>(<i></i>)
<p>
        Private method to download the required scripts.
</p><a NAME="GreaseMonkeyScript.__downloaderError" ID="GreaseMonkeyScript.__downloaderError"></a>
<h4>GreaseMonkeyScript.__downloaderError</h4>
<b>__downloaderError</b>(<i></i>)
<p>
        Private slot to handle a downloader error.
</p><a NAME="GreaseMonkeyScript.__downloaderFinished" ID="GreaseMonkeyScript.__downloaderFinished"></a>
<h4>GreaseMonkeyScript.__downloaderFinished</h4>
<b>__downloaderFinished</b>(<i></i>)
<p>
        Private slot to handle a finished download.
</p><a NAME="GreaseMonkeyScript.__parseScript" ID="GreaseMonkeyScript.__parseScript"></a>
<h4>GreaseMonkeyScript.__parseScript</h4>
<b>__parseScript</b>(<i></i>)
<p>
        Private method to parse the given script and populate the data
        structure.
</p><a NAME="GreaseMonkeyScript.__reloadScript" ID="GreaseMonkeyScript.__reloadScript"></a>
<h4>GreaseMonkeyScript.__reloadScript</h4>
<b>__reloadScript</b>(<i></i>)
<p>
        Private method to reload the script.
</p><a NAME="GreaseMonkeyScript.__requireDownloadError" ID="GreaseMonkeyScript.__requireDownloadError"></a>
<h4>GreaseMonkeyScript.__requireDownloadError</h4>
<b>__requireDownloadError</b>(<i></i>)
<p>
        Private slot to handle a downloader error.
</p><a NAME="GreaseMonkeyScript.__requireDownloaded" ID="GreaseMonkeyScript.__requireDownloaded"></a>
<h4>GreaseMonkeyScript.__requireDownloaded</h4>
<b>__requireDownloaded</b>(<i></i>)
<p>
        Private slot to handle a finished download of a required script.
</p><a NAME="GreaseMonkeyScript.__toJavaScriptList" ID="GreaseMonkeyScript.__toJavaScriptList"></a>
<h4>GreaseMonkeyScript.__toJavaScriptList</h4>
<b>__toJavaScriptList</b>(<i>patterns</i>)
<p>
        Private method to convert a list of str to a string containing a valid
        JavaScript list definition.
</p><dl>
<dt><i>patterns</i> (list of str)</dt>
<dd>
list of match patterns
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
JavaScript script containing the list
</dd>
</dl><dl>
<dt>Return Type:</dt>
<dd>
str
</dd>
</dl><a NAME="GreaseMonkeyScript.__watchedFileChanged" ID="GreaseMonkeyScript.__watchedFileChanged"></a>
<h4>GreaseMonkeyScript.__watchedFileChanged</h4>
<b>__watchedFileChanged</b>(<i>fileName</i>)
<p>
        Private slot handling changes of the script file.
</p><dl>
<dt><i>fileName</i> (str)</dt>
<dd>
path of the script file
</dd>
</dl><a NAME="GreaseMonkeyScript.description" ID="GreaseMonkeyScript.description"></a>
<h4>GreaseMonkeyScript.description</h4>
<b>description</b>(<i></i>)
<p>
        Public method to get the description of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
description of the script (string)
</dd>
</dl><a NAME="GreaseMonkeyScript.downloadUrl" ID="GreaseMonkeyScript.downloadUrl"></a>
<h4>GreaseMonkeyScript.downloadUrl</h4>
<b>downloadUrl</b>(<i></i>)
<p>
        Public method to get the download URL of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
download URL of the script (QUrl)
</dd>
</dl><a NAME="GreaseMonkeyScript.exclude" ID="GreaseMonkeyScript.exclude"></a>
<h4>GreaseMonkeyScript.exclude</h4>
<b>exclude</b>(<i></i>)
<p>
        Public method to get the list of excluded URLs.
</p><dl>
<dt>Returns:</dt>
<dd>
list of excluded URLs (list of strings)
</dd>
</dl><a NAME="GreaseMonkeyScript.fileName" ID="GreaseMonkeyScript.fileName"></a>
<h4>GreaseMonkeyScript.fileName</h4>
<b>fileName</b>(<i></i>)
<p>
        Public method to get the path of the Javascript file.
</p><dl>
<dt>Returns:</dt>
<dd>
path of the Javascript file (string)
</dd>
</dl><a NAME="GreaseMonkeyScript.fullName" ID="GreaseMonkeyScript.fullName"></a>
<h4>GreaseMonkeyScript.fullName</h4>
<b>fullName</b>(<i></i>)
<p>
        Public method to get the full name of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
full name of the script (string)
</dd>
</dl><a NAME="GreaseMonkeyScript.include" ID="GreaseMonkeyScript.include"></a>
<h4>GreaseMonkeyScript.include</h4>
<b>include</b>(<i></i>)
<p>
        Public method to get the list of included URLs.
</p><dl>
<dt>Returns:</dt>
<dd>
list of included URLs (list of strings)
</dd>
</dl><a NAME="GreaseMonkeyScript.isEnabled" ID="GreaseMonkeyScript.isEnabled"></a>
<h4>GreaseMonkeyScript.isEnabled</h4>
<b>isEnabled</b>(<i></i>)
<p>
        Public method to check, if the script is enabled.
</p><dl>
<dt>Returns:</dt>
<dd>
flag indicating an enabled state (boolean)
</dd>
</dl><a NAME="GreaseMonkeyScript.isUpdating" ID="GreaseMonkeyScript.isUpdating"></a>
<h4>GreaseMonkeyScript.isUpdating</h4>
<b>isUpdating</b>(<i></i>)
<p>
        Public method to get the updating flag.
</p><dl>
<dt>Returns:</dt>
<dd>
updating flag
</dd>
</dl><dl>
<dt>Return Type:</dt>
<dd>
bool
</dd>
</dl><a NAME="GreaseMonkeyScript.isValid" ID="GreaseMonkeyScript.isValid"></a>
<h4>GreaseMonkeyScript.isValid</h4>
<b>isValid</b>(<i></i>)
<p>
        Public method to check the validity of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
flag indicating a valid script (boolean)
</dd>
</dl><a NAME="GreaseMonkeyScript.name" ID="GreaseMonkeyScript.name"></a>
<h4>GreaseMonkeyScript.name</h4>
<b>name</b>(<i></i>)
<p>
        Public method to get the name of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
name of the script (string)
</dd>
</dl><a NAME="GreaseMonkeyScript.nameSpace" ID="GreaseMonkeyScript.nameSpace"></a>
<h4>GreaseMonkeyScript.nameSpace</h4>
<b>nameSpace</b>(<i></i>)
<p>
        Public method to get the name space of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
name space of the script (string)
</dd>
</dl><a NAME="GreaseMonkeyScript.noFrames" ID="GreaseMonkeyScript.noFrames"></a>
<h4>GreaseMonkeyScript.noFrames</h4>
<b>noFrames</b>(<i></i>)
<p>
        Public method to get the noFrames flag.
</p><dl>
<dt>Returns:</dt>
<dd>
flag indicating to not run on sub frames
</dd>
</dl><dl>
<dt>Return Type:</dt>
<dd>
bool
</dd>
</dl><a NAME="GreaseMonkeyScript.require" ID="GreaseMonkeyScript.require"></a>
<h4>GreaseMonkeyScript.require</h4>
<b>require</b>(<i></i>)
<p>
        Public method to get the list of required scripts.
</p><dl>
<dt>Returns:</dt>
<dd>
list of required scripts (list of strings)
</dd>
</dl><a NAME="GreaseMonkeyScript.setEnabled" ID="GreaseMonkeyScript.setEnabled"></a>
<h4>GreaseMonkeyScript.setEnabled</h4>
<b>setEnabled</b>(<i>enable</i>)
<p>
        Public method to enable a script.
</p><dl>
<dt><i>enable</i></dt>
<dd>
flag indicating the new enabled state (boolean)
</dd>
</dl><a NAME="GreaseMonkeyScript.startAt" ID="GreaseMonkeyScript.startAt"></a>
<h4>GreaseMonkeyScript.startAt</h4>
<b>startAt</b>(<i></i>)
<p>
        Public method to get the start point of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
start point of the script (DocumentStart or DocumentEnd)
</dd>
</dl><a NAME="GreaseMonkeyScript.updateScript" ID="GreaseMonkeyScript.updateScript"></a>
<h4>GreaseMonkeyScript.updateScript</h4>
<b>updateScript</b>(<i></i>)
<p>
        Public method to updated the script.
</p><a NAME="GreaseMonkeyScript.updateUrl" ID="GreaseMonkeyScript.updateUrl"></a>
<h4>GreaseMonkeyScript.updateUrl</h4>
<b>updateUrl</b>(<i></i>)
<p>
        Public method to get the update URL of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
update URL of the script (QUrl)
</dd>
</dl><a NAME="GreaseMonkeyScript.version" ID="GreaseMonkeyScript.version"></a>
<h4>GreaseMonkeyScript.version</h4>
<b>version</b>(<i></i>)
<p>
        Public method to get the version of the script.
</p><dl>
<dt>Returns:</dt>
<dd>
version of the script (string)
</dd>
</dl><a NAME="GreaseMonkeyScript.webScript" ID="GreaseMonkeyScript.webScript"></a>
<h4>GreaseMonkeyScript.webScript</h4>
<b>webScript</b>(<i></i>)
<p>
        Public method to create a script object.
</p><dl>
<dt>Returns:</dt>
<dd>
prepared script object
</dd>
</dl><dl>
<dt>Return Type:</dt>
<dd>
QWebEngineScript
</dd>
</dl><dl>
<dt>Raises <b>ValueError</b>:</dt>
<dd>
raised to indicate an unsupported start point
</dd>
</dl>
<div align="right"><a href="#top">Up</a></div>
<hr />
</body></html>

eric ide

mercurial