123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- /**
- Zombie Navigator API (ZAPI) documentation
-
- @copyright
- Copyright © 2016 Zombie Navigator Developers
-
- <br /><br />
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- <br /><br />
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- <br /><br />
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see {@link http://www.gnu.org/licenses/}.
-
- <br /><br />
-
- The latest version of the GNU AGPL should be available here:
- {@link https://www.gnu.org/licenses/agpl.html}
-
-
- @file
- @module zombie/webbrowser
- @license AGPL-3.0+
- @version 0.6.0
- */
- /*
- This is not a script but a JSDoc documentation source.
- */
- /**
- Open a window (tab)
- @param {string} uri
- @returns {Promise} Resolves to {@link Window}
- @public
- */
- var openWindow = function () {};
- /**
- Open a private window (tab)
- @param {string} uri
- @returns {Promise} Resolves to {@link Window}
- @public
- */
- var openPrivateWindow = function () {};
- /**
- Close all windows opened by the Zombie script
- This doesn't close any other windows, so if the user moves a Zombie tab into
- another window, that tab is not closed here.
- @returns {Promise}
- @public
- */
- var closeAll = function () {};
- /**
- A browser window, or a tab
- @example
- require('zombie/webbrowser').openPrivateWindow('about:')
- .then(window => {
- console.log(window.uri);
- })
- .catch(e => {
- console.exception(e); // failed
- });
- @class
- @protected
- */
- var Window = function Window () {
- /**
- Whether this window is private (Private Browsing)
- @type {bool}
- @public
- @readonly
- */
- this.isPrivate = false;
-
- /**
- The URI of the window
- @example
- // writable since 0.4.0
- window.uri = 'about:';
- window.waitForReload()
- .then(...)
- @type {string}
- @public
- */
- this.uri = false;
-
-
- /**
- Close the window
- @returns {Promise}
- @public
- */
- this.close = function () {};
-
- /**
- Wait until the tab is reloaded
- @returns {Promise}
- @public
- */
- this.waitForReload = function () {};
-
- /**
- Run a script inside this tab
- @example
- let promise = w.runScript(function (arg1, arg2) {
- console.log(document.title);
- return 'result';
- }, 'arg1', 'arg2');
- @param {function} callback The script to run
- @param {...*} args Passed to the callback
- @returns {Promise} Resolves to the result of the callback
- @public
- */
- this.runScript = function () {};
-
- /**
- Take a screenshot of the tab content
- @since 0.6.0
- @example
- w.screenshot().then(dataURI => {
- w.uri = dataURI;
- });
- @param {bool} windowSized Whether the screenshot is limited to the browser window boader
- @returns {Promise} Resolves to the data URI of the image
- @public
- */
- this.screenshot = function () {};
-
- /**
- Reload this tab
- @returns {Promise}
- @public
- */
- this.reload = function () {};
- };
- // vim: ts=4 noet ai ft=js
|