Methods
(static) injectScript(src, positionopt , configopt ) → {Promise}
inject Script tag to the document at the specified position
Parameters:
Name
Type
Attributes
Default
Description
src
string
position
string
<optional>
head
where Script tag needs to be appended
config
object
<optional>
{}
configuration options
Properties
Name
Type
Attributes
Default
Description
html
object
<optional>
innerHTML of the script tag if src is not provided
id
object
<optional>
StringiedRandomNumber
id of the script tag
Since:
Source:
Example
injectScript('https://example.example' . 'body' ).then(src => console .log(`Appended ${src} ` ))
injectScript('https://example.example' , '#my-elm-id' ).then(src => console .log(`Appended ${src} ` ))
injectScript(null , '#my-elm-id' , {html : `<a href="">Example</a>` }).then(src => console .log(`Appended ${src} ` ))
(static) insertLink(href, positionopt ) → {Promise}
Insert link tag to the document at the specified position
Parameters:
Name
Type
Attributes
Default
Description
href
string
position
string
<optional>
head
where link tag needs to be appended
Since:
Source:
Example
// return Promise
insertLink('https://example.example' ).then (() => console .log(`Appended `))
// returns Promise
insertLink('https://example.example' , 'body' ).then (() => console .log(`Appended `))
(static) insertStyle(content, positionopt ) → {Promise}
Insert style tag to the document at the specified position
Parameters:
Name
Type
Attributes
Default
Description
content
string
position
string
<optional>
head
where style tag needs to be appended
Since:
Source:
Example
// return Promise
insertStyle(`a{color :red;} `).then (() => console .log(`Appended `))
// returns Promise
insertStyle(`a{color :red;} `, 'body' ).then (() => console .log(`Appended `))
(inner) getNearestSelectorPath(node) → {string}
Gives the nearest(shorter) selector path for the specified Node element
Parameters:
Name
Type
Description
node
*
HTML Node
Source:
Example
getNearestSelectorPath(document .querySelector('#my-id' ));
getNearestSelectorPath($0 );
(inner) isDynamicClass(identifier) → {boolean}
Checks wthether the input value matches the dynamic id criteria
Parameters:
Name
Type
Description
identifier
string
input value
Since:
Source:
Example
// return true
isDynamicClass('myDiv-aaa_1234' );
(inner) isDynamicId(identifier) → {boolean}
Checks wthether the input value matches the dynamic id criteria
Parameters:
Name
Type
Description
identifier
string
input value
Since:
Source:
Example
// returns true
isDynamicId('myDiv-aaa_1234' );
(inner) isSelectorElementPresent(path) → {boolean}
Checks if the element having the specified path exists
Parameters:
Name
Type
Description
path
string
selector of an element
Since:
Source:
Example
// returns true
isSelectorElementPresent('body' );
// returns false
isSelectorElementPresent('unknown-selector' );