Info |
---|
The Chromium Browser can now be used when creating addons instead of having to use Internet Explorer. This enhancement is available in ILLiad 9v9.0 and higher, Aeon v4.0 and higher, and Ares v4.7 and higher. |
...
Anchor | ||||
---|---|---|---|---|
|
Property Name | Type |
---|---|
Message | string |
Success | bool |
Result | object |
EvaluateScript(script)
Executes the javascript code or function name.
Parameter Direction | Parameter Name | Parameter Description |
---|---|---|
Input | script | The javascript code or javascript method name on the page that should be executed. |
Output | javascriptResponse | The result of the script execution as a JavascriptResponse object, defined as the following. |
EvaluateScript(script, args)
Executes the javascript code or function name and passes in arguments.
Parameter Direction | Parameter Name | Parameter Description |
---|---|---|
Input | script | The javascript method name on the page that should be executed. |
Input | args | The arguments passed to the javascript method. |
Output | javascriptResponse | The result of the script execution as a JavascriptResponse object, defined as the following. |
EvaluateScript(timeout, script)
Executes the javascript code or function name with a timeout.
Parameter Direction | Parameter Name | Parameter Description |
---|---|---|
Input | timeout | The timeout specified in milliseconds. |
Input | script | The javascript code or method name that should be executed. |
Output | javascriptResponse | The result of the script execution as a JavascriptResponse object, defined as the following. |
EvaluateScript(timeout, script, args)
Executes the javascript code or function name and passes in arguments and sets a timeout.
Parameter Direction | Parameter Name | Parameter Description |
---|---|---|
Input | timeout | The timeout specified in milliseconds. |
Input | script | The javascript method that should be executed. |
Input | args | The arguments passed to the javascript method. |
Output | javascriptResponse | The result of the script execution as a JavascriptResponse object, defined as the following. |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
local browser = addonForm:CreateBrowser("BrowserName", "BrowserLabel", "BrowserRibbon", "Chromium"); --Create a browser on the form --Evaluate a script checking if an HtmlElement with the id name exists on the page and if it's value is Addon. --The HTML that would pass this check would look like <input id="username" value="Addon" /> local response = browser:EvaluateScript("(document.getElementById('username') != null && document.getElementById('username').value == 'Addon')"); if (response.Success) then --Do something with the value returned if (response.Result == true) then browser:ExecuteScript("alert('Username set to Addon!')"); else browser:ExecuteScript("alert('Username not set to Addon!')"); end else LogDebug(response.Message); end |
...
Executes the supplied javascript code asynchronously in the context of the browser.
Parameter Direction | Parameter Name | Parameter Description |
---|---|---|
Input | script | The javascript code or javascript function name that should be executed. |
Input - Optional | arguments | The arguments to be passed as params to the method |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
local browser = addonForm:CreateBrowser("BrowserName", "BrowserLabel", "BrowserRibbon", "Chromium"); --Create a browser on the form browser:ExecuteScript("console.log('The browser has been loaded!')"); --Writes a message to the browser console, visible when the developer tools are opened. browser:ExecuteScript("alert('Show a javascript popup alert message')"); --Displays an alert - See https://www.w3schools.com/jsref/met_win_alert.asp --Execute a script with arguments local login = [[ (function(username, password) { var usernameInput = document.getElementById('username'); var passwordInput = document.getElementById('password'); var loginInput = document.getElementById('login'); if (!(usernameInput && passwordInput && loginInput)) { console.log('Unable to find all three login elements'); } usernameInput.value = username; passwordInput.value = password; loginInput.click(); }) ]]; local username = "jdoe"; local unsecurePassword = "123"; browser:ExecuteScript(login, { username, unsecurePassword }); |
...
Attempts to load the specified url into the browser.
Parameter Direction | Parameter Name | Parameter Description |
---|---|---|
Input | url | The url to navigate to |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
local browser = addonForm:CreateBrowser("BrowserName", "BrowserLabel", "BrowserRibbon", "Chromium"); --Create a browser on the form browser:Navigate("https://www.atlas-sys.com"); |
...
Registers a new page handler for use in detecting when pages that have automated actions associated with them are loaded and alerting the addon script to respond to the page load.
Parameter Direction | Parameter Name | Parameter Description | ||
---|---|---|---|---|
Input | idType | The type of page handler matching that should be done against the given id.
| ||
Input | id | The id to match against | ||
Input | handlerName | The name of the Lua method that should be called when the page handler is invoked | ||
Input | critical | Whether or not the page handler is considered a critical page handler, which should exist outside of the normal queue and should be checked every time the the system checks for a page match |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
local browser = addonForm:CreateBrowser("BrowserName", "BrowserLabel", "BrowserRibbon", "Chromium"); --Create a browser on the form --Register a title page handler that will call the GoogleLoaded function if the title of the page matches "Google" browser:RegisterPageHandler("title", "Google", "GoogleLoaded", true); function GoogleLoaded() --The google page was detected via the page handler. end |
...
Starts the page watcher, which will check the page handler queue (and critical page handlers) at an interval defined by checkInterval. If no match is found when the maxWatchTime is reached, the handler will stop. This is primarily used on pages that use AJAX or other similar methods to make dynamic changes to the page content without actually causing the page to fully change. In these cases, a page watcher can be started before performing an action that will cause a page update so that the new page state can be checked.
Parameter Direction | Parameter Name | Parameter Description |
---|---|---|
Input | checkInterval | The interval, in milliseconds, that the page handler queue should be checked |
Input | maxWatchTime | The maximum amount of time,in milliseconds, the page watcher should run before stopping |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
local browser = addonForm:CreateBrowser("BrowserName", "BrowserLabel", "BrowserRibbon", "Chromium"); --Create a browser on the form --Register a custom page handler that will call the ResultsLoaded function browser:RegisterPageHandler("custom", "AreResultsLoaded", "ResultsLoaded", true); --Start the page watcher which will check page handlers every 2 seconds for up to 30 seconds. browser:StartPageWatcher(2000, 30000); function AreResultsLoaded() --Perform logic to check if results are loaded. local result = browser:EvaluateScript("(document.getElementById('resultId') != null)"); return result.Result; end function ResultsLoaded() --The page has a results section end |
...
Info | |||||
---|---|---|---|---|---|
Since javascript is case-sensitive, ensure that you call the function exactly as seen below.
|
Parameter | Type | Description |
---|---|---|
functionName | string | The lua function to be called |
args | object[] | The arguments to be passed to the lua function |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
local initializeScript = [[ $(document).on("click", "#importButton", function() { atlasAddonAsync.executeAddonFunction('Import', { document.getElementById('valueToImport').value }); --call the Import function with the value of the valueToImport element in the web page as a parameter. }); $(document).on("click", "#replaceButton", function() { atlasAddonAsync.executeAddonFunction('Replace', { document.getElementById('originalValue').value, document.getElementById('valueToImport').value }); --call the Replace function with the values of the originalValue element and the valueToImport element }); ]]; function Import(newValue) --Process the import of the newValue ... end function Replace(oldValue, newValue) --Process the replacement ... end function Init() --Assume browser has been created, initialized, and navigated to a site. --Execute the initialization javascript so that when the buttons are clicked it will trigger the addon functions to be called via the scripting bridge browser:ExecuteScript(initializeScript); end |
...