Useful Scripts To Use

Here you can find several scripts and examples you can use to define your own scripts.

Scrolling to a Specific Area

If you need to scroll the web viewer to a specific area on the screen, you can use JavaScript.

Syntax: window.scrollTo( xpos, ypos )

Parameter Type Description

xpos Number Required. The coordinate to scroll to, along the x-axis (horizontal), in pixels
ypos Number Required. The coordinate to scroll to, along the y-axis (vertical), in pixels

In the following Scripting Engine code, we scroll to position 300px down and 100px right.

runScript("""window.scrollTo(100,300)""")

Scrolling by Specific Pixels

If you need to scroll the web viewer by specific pixels on the screen, you can use JavaScript.

Syntax: window.scrollBy( xnum, ynum )

Parameter Type Description

xnum Number Required. How many pixels to scroll by along the x-axis (horizontal).
Positive values will scroll to the right, while negative values will scroll to the left
ynum Number Required. How many pixels to scroll by along the y-axis (vertical).
Positive values will scroll down, while negative values scroll up.

In the following Scripting Engine code, we scroll by position 300px down and 100px right.

runScript("""window.scrollBy(100,300)""")

Deleting a Specific Element

runScript("""j("css_selector").remove();""")

Moving an Element to Body

runScript("""
			 var elem = j("css_selector");
		     j("body").append(elem);		     	
  		  """)

Delete All Content Besides One Element

extract("""css_selector""")

Change the Background Color

runScript("""document.body.style.backgroundColor = "white";""")

Or you can use a hex color picker:

runScript("""document.body.style.backgroundColor = "#6217e5";""")

(info) The #6217e5 is this color:

Selecting a Specific Option from a Dropdown List

runScript("""
a = document.querySelector('Dropdown_list's_CSS_Selector')
for (var i = 0; i < a.options.length; i++) 
{
if (a.options[i].text === '_DROPDOWN_VALUE_') 
{
a.selectedIndex = i;
break; 
}
}
""")
  • (lightbulb) _DROPDOWN_VALUE_ should be an option from the dropdown menu