Website scripting

Script execution is very powerful feature, however it requires some understanding of JavaScript code. This page provides common script examples, however with enough programming experience it’s possible to do complex workflows.

Please note that scripting does not work in web preview and Android players because they display web content in an iframe element (whereas other players use webview element) that does not support this functionality due to how web security works. Scripting is supported in Windows, Linux, Mac and Chrome extension (ChromeOS) players.

Scrolling to a position

setTimeout(window.scrollTo.bind(null, 0, 500), 1000);

The window.scrollTo function takes in 3 parameters:

  1. context (null)
  2. horizontal X coordinate (0)
  3. vertical Y coordinate (500)

Usually vertical is the axis we want to scroll. In this case we scroll 500 pixels vertically, but you need to experiment with the numbers to find appropriate amount of pixels to scroll to.

The scrollTo function call is wrapped in setTimeout function call, this delays the code execution to make sure page is loaded. In this case we delay execution by 1000 milliseconds, however depending on how the website is built, it may not be necessary. You can try setting the value to 0 and see if the page scroll still works.

Refreshing page at interval

}, 60000);

This script forces to page to refresh every 60 sections. It’s worth noting that it calls setTimeout that is executed only once, however since the script causes the page to reload which executes scripts again, so there is no need to use setInterval.

Starting video

Script can be used to start a video in the page. This example will wait for the page to load 1 second, get all <video> tags, take the first one and call play() function on it after. If the page has multiple video tags, this would start the first video it can find.

}, 1000);

Logging in to a website

When it comes to logging into a website, there is no one-size-fits-all solution. Each website is different system and needs a tailored approach. While JavaScript programming skills would be beneficial, it is certainly possible to create the script without any technical background. We gladly assist our subscription customers with simple scripts.

Login script performs following actions:

  1. Find username input field and fill it with our username
  2. Find password input field and fill it with password
  3. Find login button and click it

First we need to teach the script to find the elements in the web page. To do so, we need to find out what are the ID’s of the elements. While possible with every browser, we focus on Chrome in this guide. Navigate to the page you wish to automate the log in procedure and open up developer tools:

Open chrome developer tools

Now from the developer tools pane that just open up select “Elements” tab if not already selected. Then click on the select element button (step 1) and mouse over the username input field and click on it (step 2). The HTML code will be highlighted that represents the username field, it should be an <input> tag. Most website creators assign a unique ID to that field that we can use to reference it in the script, in this example it is “user_login” (step3).

Find login identifier that can be used by JavaScript

Repeat the same process for the password field. In our example the password field id is “user_pass“. Ideally the log in button has also id attribute present, in which case we have all the information needed to create the script:

document.getElementById('user_login').value = "YOUR_USERNAME_HERE";
document.getElementById('user_pass').value = "YOUR_PASSWORD_HERE";

Sometimes however the log in button may not have an id assigned, but instead all fields are wrapped in a <form> element. In the step 4 of the above screenshot the form has an id assigned. Instead of clicking on the button, we can also call submit() function on the form itself:


It could be possible however that the form does not have an id attributte assigned either. Then we can search for all <form> elements on the page and submit the first one we find, but beware that this only works if there is only one <form> on the page:


If you are very unlucky and none of the elements have an ID attribute assigned, then there are 2 options:

  1. Contact the website developers and ask them to assign ID values to login page elements
  2. Hire a developer to write the script – it’s still possible to find the elements, but it’s beyond the scope of this article. A qualified JavaScript developer should be able to develop the script in about 30 minutes to 1 hour

Websites built with react.js

If the website you’re trying to script is built with react.js, you need to fire events that the input field has changed, because react won’t pick up changes directly done to the element by setting value. Read more: