1.0.1 • Published 4 years ago

webview-query v1.0.1

Weekly downloads
14
License
MIT
Repository
github
Last release
4 years ago

webview-query

Utility node.js library for Chrome Webview traversal and manipulation.

no dependencies

Install

npm install webview-query --save

Example

For example, you have NW.js app with webview tag within.

html:

<webview id="view1"></webview>

js:

const { Webview } = require('webview-query');
const webview = new Webview(view1);

// inside async function:

await webview.location('https://github.com');
console.log(await webview.title());
// -> "The world's leading software development platform · GitHub"

console.log(await webview.text('.jumbotron h1'));
// -> "Built for developers"

webview.val('form.home-hero-signup input[id="user[login]"]', 'Hello GitHub!');

Classes

External

Webview

Kind: global class

new Webview(webview)

Webview is a class for Chrome webview promise-based traversal and manipulation.

ParamTypeDescription
webviewwebviewChrome webview element.

webview.webview : webview

Kind: instance property of Webview

webview.runJs(code) ⇒ Promise

Run arbitrary javascript code inside webview context.

Kind: instance method of Webview
Returns: Promise - Promise object represents the result of the script.

ParamTypeDescription
codestringJavascript code.

webview.title(value) ⇒ Promise

Set webview document new title.

Kind: instance method of Webview

ParamTypeDescription
valuestringNew document title.

webview.location(value) ⇒ Promise

Set webview new location.

Kind: instance method of Webview

ParamTypeDescription
valuestringURL or path to local file.

webview.exists(selector) ⇒ Promise.<boolean>

Check the existence of an element(s).

Kind: instance method of Webview
Returns: Promise.<boolean> - Promise object represents the element(s) existence.

ParamTypeDescription
selectorstringCSS selector.

webview.length(selector) ⇒ Promise.<number>

Return number of elements matched by selector.

Kind: instance method of Webview
Returns: Promise.<number> - Promise object represents the number of elements currently matched..

ParamTypeDescription
selectorstringCSS selector.

webview.val(selector, value) ⇒ Promise

Set the value of every matched element.

Kind: instance method of Webview

ParamTypeDescription
selectorstringCSS selector.
valuestringValue to set.

webview.attr(selector, attribute, value) ⇒ Promise

Set an attribute for every matched element.

Kind: instance method of Webview

ParamTypeDescription
selectorstringCSS selector.
attributestringThe name of the attribute to set.
valuestringA value to set for the attribute..

webview.text(selector, value) ⇒ Promise

Set the text contents of the matched elements.

Kind: instance method of Webview

ParamTypeDescription
selectorstringCSS selector.
valuestringThe text to set as the content of each matched element.

webview.html(selector, value, options) ⇒ Promise

Set the HTML contents of every matched element.

Kind: instance method of Webview

ParamTypeDescription
selectorstringCSS selector.
valuestringA string of HTML to set as the content of each matched element.
optionsobjectOptions.
options.outerbooleanIf true the result will be outer HTML, inner HTML otherwise.

webview.click(selector) ⇒ Promise

Execute click action for the matched element(s).

Kind: instance method of Webview

ParamTypeDescription
selectorstringCSS selector.

webview

Chrome webview element

Kind: global external
See: https://developer.chrome.com/apps/tags/webview

1.0.1

4 years ago

1.0.0

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago