This site has an English translation of the original, if you do not need a translation, please go to the original
  • webisida.com
  • Dynamic presentation mode

    Content



    Dynamic presentation mode

    The dynamic presentation mode provides a mechanism for controlling the browser program using the program code in JavaScript directly during the display of the site. Dynamic presentation allows you to create individual display algorithms for each visitor, make certain decisions depending on the opened page of the site, create screenshots of pages or parts of them, as well as check the success of certain commands and, if necessary, repeat their execution. Thus, the use of dynamic presentation opens up almost unlimited possibilities.

    The dynamic presentation script runs in a separate context, so the script retains its state across tabbed page transitions and reloads.



    Continue function

    Most of the presentation control commands (functions) take some time to complete the required actions. The state of the active tab immediately after executing the command may be undefined. For example, after the transition in the current tab, the old page may remain for a short time, and you need to wait until the new page is loaded by the browser. Clicks on objects on the page are also performed asynchronously. It may take up to 5-6 seconds to complete a click, so it is advisable to evaluate the success of a click no less than 5 seconds after calling the function responsible for performing the click.

    In this regard, most of the presentation control functions accept as the last two parameters a function that will deal with further presentation control, and the time after which this function should be called after the command starts executing. If the time is omitted, the function will be called immediately after the command is executed. Specifying the time without passing the continuation function is meaningless.

    The continuation function function FuncName (window) {...} can take one parameter, window , to which the context of the active tab ( Window object ) is passed . Using the Window object, you can access the objects of the page loaded in the active tab, for example the page document ( window.document ).

    // 1. Passing an anonymous (unnamed) continuation function 
    activateTab ( 0 , function ( aWindow ) { // here, inside the continuation function, // you can write your script code print ( 'Inside the continuation function' ); }, 10 ) ;  
    	
    	
    	
     
    
    // 2. Pass the continuation function 
    activateTab ( 0 , step1 , 10 ); function step1 ( aWindow ) { // here, inside the continuation function, // you can write your script code print ( 'Inside the continuation function' ); }; 
     
    	
    	
    	
    


    CallChain object

    The CallChain object provides chaining support. Each call to the next method of the CallChain object places the function passed to it into the call chain that the current instance of the CallChain object is responsible for servicing , and returns that instance for further action. The execution of the chain begins after it is completely built and after leaving the synchronization context in which it was created (in other words, you should not wait for the completion of the execution of any function in the chain immediately after its creation, using a loop and / or the wait (t) method and checking the variable which the chained function should set, since that function won't even start executing) . After executing the function passed to the chain, the object waits for a set amount of time and then executes the next function in the chain. Etc. If there are no more functions in the chain, the CallChain object exits processing functions and, if there are no more references to it, it self-destructs. Although it is possible to save a reference to a CallChain object, it cannot be reused.

    Unhandled exceptions during function chaining are ignored.

    Functions available when working with an object of the CallChain type :

    • The next (timeout, callback) function adds the function passed in the callback parameter to the call chain.
      • timeout - time in seconds allotted for the execution of the function passed in the callback parameter .
      • callback is the continuation function to be executed.
    // 1. Go to Yandex, Google, Rambler // For each site to load, 5 seconds 
    run (). next ( 5 , function ( aWindow ) { 
    	navigate ( 'http://ya.ru' ); }). next ( 5 , function ( aWindow ) { 
    	navigate ( 'http://google.com' ); }). next ( 5 , function () { 
    	navigate ( 'http://rambler.ru' ); }). next ( 0 , function () { print ( 'Everyone !!!' ); });
      
      
      
      
    	
    



    Dynamic presentation control

    Standard JavaScript objects and the following properties and functions are available for dynamic presentation scripts .

    • Property window contains the Window object for the currently selected frame in the active tab. May be overridden.

      Examples of using:

      // 1. Outputting the address of the open page to the log print ( 'Page address:' + window . Location );
       
      
      // 2. Attention !!! Don't name your variables window and document. var window = 12345 ; // don't do this print ( '12345 =' + window );
        
       
    • Property document contains the Document object for the currently selected frame in the active tab. May be overridden.

      Examples of using:

      // 1. Logging the name of the open site 
      navigate ( 'http://example.com' ); 
      wait ( 5000 ); print ( 'Site name:' + document . domain );
       
      
      // 2. Attention !!! Don't name your variables window and document. var document = 12345 ; // don't do this print ( '12345 =' + document );
        
       
    • Function activateTab (tabIndex, callback, timeout) sets the active tab. If a tab has not yet been created, creates it and all tabs whose index is less than tabIndex .
      • tabIndex - tab number. It can be 0, 1, 2, or 3.
      • callback (optional) - A continuation function that will be called after the specified tab is activated.
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Return Value: The Window object for the activated tab if the callback parameter was not specified, or undefined if the callback parameter was specified .

      Call examples:

      // 1. Activates the main tab and returns its context (Window object) var aWindow = activateTab ( 0 ); 
      aWindow . document . body . innerHTML = 'Main Tab' ;
       
      
      // 2. Creates 2 additional tabs, activates the 2nd tab // and uses the JavaScript DOM API to load Wikipedia into it. var aWindow = activateTab ( 2 ); 
      aWindow . location = 'http://wikipedia.org/' ;
      
       
    • Function loadHTML (html, documentUrl, referringUrl, callback, timeout) loads an HTML document created from the passed string into the active tab.
      • html is a string containing content to download.
      • documentUrl - The URL to set for the uploaded document.
      • referringUrl (optional) - the address of the referrer page.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Loads an HTML document from a string into the active tab, // replacing the page address with the Yandex address // substituting the referrer - the main page of Google 
      loadHTML ( 'Hello, World!' , 'Http://ya.ru' , 'http://google.com' );
      
        
      
      // 2. Loads an HTML document from a string to the active tab, // substituting the page address for the Yandex address var yandexLogo = '//yastatic.net/www/1.930/yaru/i/logo.png' ; var googleLogo = '//www.google.com/images/srpr/logo11w.png' ; var content = http . getSync ( 'http://ya.ru' ) + '' ; 
      content = content . replace ( yandexLogo , googleLogo ); 
      loadHTML ( content , 'http://ya.ru' );
      
       
       
         
      
      // 3. Loads the page from the string 
      loadHTML ( 'Hello, World!' );
    • Function navigate (url, referrer, callback, timeout) loads the page at the url into the active tab. Analogue of the "Transition" command in a static presentation.
      • url - the address of the site page that you want to load into the active tab.
      • referrer (optional) - the address of the referrer page. To pass the address of the current page as a referrer, specify the CURRENT keyword. If the value is absent, then a direct jump will be performed.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Goes to Yandex with the substitution of the referrer - the main page of Google 
      navigate ( 'http://ya.ru' , 'http://google.com' ); 
      
      // 2. Direct transition to Yandex (without referrer) 
      navigate ( 'http://ya.ru' );
      
      // 3. Direct transition to Yandex, then after 10 seconds. going to Google // with substitution of the URL of the open page (http://ya.ru) as a referrer. 
      navigate ( 'http://ya.ru' ); 
      wait ( 10000 ); 
      navigate ( 'http://google.com' , 'CURRENT' );
       
    • Functions loadLink find the link on the page loaded in the active tab and follow the found link.
      loadLink (searchKey, data, index, canSendEvents, callback, timeout)
      loadLink (linkElement, canSendEvents, callback, timeout)
      The address of the page on which the search was performed is always passed as a referrer. Analogue of the Find Link command in a static presentation.
      • searchKey - search key, a string that can take one of the following values:
        • id  - search for a link by ID, then the data parameter is the required identifier or part of it, depending on the current type of search .
        • link  - search for a link by its part, then the data parameter is a part of the desired link. All types of search are available .
        • number  - search for a link by its ordinal number in the document, data - sequential number, starting from zero. Note: the data parameter must be specified as a string containing a number. For example, a call to the loadLink ('number', '2' ); will force the program to skip the first 2 links it finds and follow the third. In this case, the call to the loadLink ('number', 2); will throw an exception with a message about an invalid data parameter .
        • text  - search for a link by its text, data  - a part of the link text. The search is done in the innerHTML property . All types of search are available .
        • name  - search for a link by its name, data  - part of the link name. All types of search are available .
        • last  - selection of the last link found earlier by the text , check or sendEvents functions , the data parameter is ignored, but its input is required.
        • selector  - search for a link by a CSS selector, the data parameter must be a valid CSS selector. For example, calling loadLink ('selector', '. Mylink [href * = example]') will find a link that has the class mylink and contains the word example in the address , for example: <a href = " http://example.com "class =" mylink "> sample site </a> .
        • custom  - search for a link by attributes for which no separate commands have been created (for example, title, class, etc.), the data parameter is entered as a string in the format name = value , where name is the name of the attribute, value is part of the value of this parameter. Search by several attributes is possible, in this case the data parameter is specified as name1 = value1 !! name2 = value2 !! name3 = value3 ... (separated by !! by two exclamation marks). For example, when calling loadLink ('custom', 'class = mylink !! href = http: //mysite.ru'), the following link will be found: <a href = " http://mysite.ru " class = " mylink " > My site </a> . All types of search are available .
      • data - string value: the data by which the search is performed. Depends on the searchKey parameter .
      • index (optional) - numeric value: specifies the index of the link starting from zero (among those matching the search conditions), which will be followed. In the absence of this parameter, the transition is carried out on the first found link. If the value of this parameter is set to a negative value, the transition will be performed by a random link.
      • canSendEvents (optional) - boolean value: true - send mouse events to the link before transition, false - prohibit sending events. By default, events are sent. It can also be set with a NoEvents string value, for example, loadLink ('link', 'http', 0, 'NoEvents' ) , which will prevent the dispatch of mousedown, click, etc. events.
      • linkElement  - a previously found link (HTML element with the A tag) to follow.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. 
      Follow the forum link navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); // following a random link containing a viewtopic 
      loadLink ( 'link' , 'viewtopic' , - 1 );
       
      
      // 2. Go to the 20 forum link 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); // follow link 20, then call 2 functions 
      loadLink ( 'number' , '20' );
      
      
      // 3. Go to the link selected by the script (the Instructions link) 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); var links = document . getElementsByTagName ( 'a' ); for ( var i = links . length - 1 ; i > = 0 ; i -) { var a = links [ i ]; if ( a . innerHTML == 'Instructions' ) { 
      		loadLink ( a ); // follow the link } }
      
          
      	
      	    
      	
      
    • Function loadSiteLink (searchKey, data, index, events, callback, timeout) finds an internal link on the page loaded in the active tab and follows the found link. The address of the page on which the search was performed is always transmitted as a referrer. Similar to the Inner Navigation command in a static presentation.
      • searchKey - search key, a string that can take one of the following values:
        • id  - search for a link by ID, then the data parameter is the required identifier or part of it, depending on the current type of search .
        • link  - search for a link by its part, then the data parameter is a part of the desired link. All types of search are available .
        • text  - search for a link by its text, data  - a part of the link text. The search is done in the innerHTML property . All types of search are available .
        • name  - search for a link by its name, data  - part of the link name. All types of search are available .
        • selector  - search for a link by a CSS selector, the data parameter must be a valid CSS selector. For example, calling loadLink ('selector', '. Mylink [href * = example]') will find a link that has the class mylink and contains the word example in the address , for example: <a href = " http://example.com "class =" mylink "> sample site </a> .
        • custom  - search for a link by attributes for which no separate commands have been created (for example, title, class, etc.), the data parameter is entered as a string in the format name = value , where name is the name of the attribute, value is part of the value of this parameter. Search by several attributes is possible, in this case the data parameter is specified as name1 = value1 !! name2 = value2 !! name3 = value3 ... (separated by !! by two exclamation marks). For example, when calling loadLink ('custom', 'class = mylink !! href = http: //mysite.ru'), the following link will be found: <a href = " http://mysite.ru " class = " mylink " > My site </a> . All types of search are available .
      • data - string value: the data by which the search is performed. Depends on the searchKey parameter .
      • index (optional) - numeric value: specifies the index of the link starting from zero (among those matching the search conditions), which will be followed. In the absence of this parameter, the transition is carried out on the first found link. If the value of this parameter is set to a negative value, the transition will be performed by a random link.
      • events (optional) - boolean value: true - send mouse events to the link before the transition, false - prohibit sending events. By default, events are sent. It can also be set with a NoEvents string value, for example, loadSiteLink ('link', 'http', 0, 'NoEvents' ) , which will prevent the dispatch of mousedown, click, etc. events.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Go to the internal forum link 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); 
      loadSiteLink ( 'link' , 'viewtopic' , - 1 ); 
    • Functions setText inserts the text specified in the text parameter into INPUT or TEXTAREA elements on the page in the active tab, or select the value specified in the text parameter from the SELECT drop-down list.
      setText (formName, elementName, text, callback, timeout)
      setText (tag, searchInfo, text, index, callback, timeout)
      setText (element, text, callback, timeout)
      setText (selector, selectorData, text, callback, timeout)
      Analogue of the command "Entering text" in a static presentation.
      • form - name (name attribute) or index of the form in which the element is located. A string or numeric value is allowed.
      • element - the name (name attribute) or index of the element in the form into which you want to insert the text. A string or numeric value is allowed.
      • text is a string containing the text to be inserted.
      • selector - a string containing the selector keyword , which determines the search for an element by the selector.
      • selectorData - a string containing one or more CSS selectors, separated by commas, required to search for a text field by selector.
      • tag - the tag of the element where you want to insert the text. Valid values ​​are input , textarea, and select . String value.
      • searchInfo - a string value containing data for searching for an element by its attributes in the format attribute = attribute_value . Search by several attributes is possible, in this case attribute-value pairs must be separated by two exclamation marks ( !! ): attribute_A = value_attribute_A !! attribute_B = value_attribute_B .
      • index (optional) - the ordinal number of the element among those found (if not specified, the element with index 0 is selected). Numerical value.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Search in Yandex 
      navigate ( 'http://ya.ru/' ); 
      wait ( 30,000 ); 
      setText ( 0 , 'text' , 'forum.webisida.com' ); 
      wait ( 5000 ); 
      submit ( 0 );  
      
      // 2. Search in Google 
      navigate ( 'https://www.google.ru/' ); 
      wait ( 30,000 ); 
      setText ( 0 , 'q' , 'forum.webisida.com' ); 
      submit ();  
      
      // 3. Search in Google 
      activateTab ( 0 ); 
      navigate ( 'https://www.google.ru/' ); 
      wait ( 30,000 ); var q = document . getElementsByName ( 'q' ). item ( 0 ); if ( q ) { // insert text into the search string q 
      	setText ( q , 'forum.webisida.com' ); 
      	submit (); }
      
       
      	 
      
    • Functions typeIn performs character input of the text specified in the text parameter into elements with the INPUT or TEXTAREA tags, and also selects the value specified in the text parameter from the SELECT drop-down list.
      The typeIn (text) function is designed to work with the current active element on the page. For example, with a text field that was previously clicked.
      The typeIn (formName, elementName, text, callback, timeout) function is designed to work with any valid element elements located in forms.
      The typeIn (tag, searchInfo, text, index, callback, timeout) function is designed to work with any valid elements.
      The typeIn (element, text, callback, timeout) function is designed to work with a valid passed element.
      The typeIn (selector, selectorData, text, callback, timeout) function is designed to work with any valid elements found by the selector.

      • formName - name (name attribute) or index of the form in which the element is located. A string or numeric value is allowed.
      • elementName is the name (name attribute) or index of the element on the form into which you want to enter text. A string or numeric value is allowed.
      • text - the text to be entered.
      • selector - a string containing the selector keyword , which determines the search for an element by the selector.
      • selectorData - a string containing one or more CSS selectors, separated by commas, required to search for a text field by selector.
      • tag - the tag of the element where you want to enter text. Valid values ​​are input , textarea, and select . String value.
      • searchInfo - a string value containing data for searching for an element by its attributes in the format attribute = attribute_value . Search by several attributes is possible, in this case attribute-value pairs must be separated by two exclamation marks ( !! ): attribute_A = value_attribute_A !! attribute_B = value_attribute_B .
      • index (optional) - the ordinal number of the element among those found (if not specified, the element with index 0 is selected). Numerical value.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Search in Yandex 
      navigate ( 'http://ya.ru/' ); 
      wait ( 30,000 ); // enter text into the search string 
      typeIn ( 0 , 'text' , 'forum.webisida.com' ); 
      wait ( 5000 ); 
      submit ( 0 );
        
      
      // 2. Search in Google 
      navigate ( 'https://www.google.ru/' ) 
      wait ( 30000 ); // enter text into the search string 
      typeIn ( 'input' , 'name = q' , 'forum.webisida.com' ); 
      submit ();	
        
      
      // 3. Search in Google, enter in the element selected by the script 
      activateTab ( 0 ); 
      navigate ( 'https://www.google.ru/' ); 
      wait ( 30,000 ); var q = document . getElementsByName ( 'q' ). item ( 0 ); if ( q ) { // enter text into the search string q 
      	typeIn ( q , 'forum.webisida.com' ); 
      	submit (); }
      
       
      	 
      
      
      // 4. Search in Google, enter text into the active 
      navigate element ( 'https://www.google.ru/' ); 
      wait ( 30,000 ); // click makes the search bar active 
      click ( 'input' , 'name' , 'q' ); 
      wait ( 5000 ); // enter text into the search bar 
      typeIn ( 'forum.webisida.com' ); 
      wait ( 1000 ); 
      click ( 'button' , 'number' , '0' );
        
        
      
    • Functions setFile perform file selection for the input [type = file] element.
      setFile (searchInfo, [index], fileUrl, extension)
      setFile (element, fileUrl, extension)
      • searchInfo - a string value containing data for searching for an element by its attributes in the format attribute = attribute_value . Search by several attributes is possible, in this case attribute-value pairs must be separated by two exclamation marks ( !! ): attribute_A = value_attribute_A !! attribute_B = value_attribute_B .
      • index (optional) - the ordinal number of the element among those found (if not specified, the element with index 0 is selected). Numerical value.
      • element - an object, previously found HTML-element with the INPUT tag and file type ( file selection field) for which you want to install the file.
      • fileUrl is a string value containing a link to a file up to 5 megabytes in size. Links starting with HTTP: // or HTTPS: // are allowed.
      • extension (optional) - a string value containing the file extension (for example: jpg , png , gif ). The extensions exe , lnk , com , cmd , bat , dll , pif are not allowed and will be ignored.
      Returned value: true - if the file was selected, false - if the file was not selected.

      Call examples:

      // 1. Uploading a banner to RGhost 
      navigate ( 'http://rghost.ru/' ); 
      wait ( 15000 ); var imgUrl = 'http://static.webisida.com/files/webisida-468x60-005.gif' ; if ( setFile ( 'type = file' , imgUrl , 'gif' )) { print ( 'Picture selected' ); } else { print ( 'No picture selected' ); } 
      wait ( 5000 ); 
      submit ();
       
        
      	
        
      	
      
      
      // 2. Uploading a banner to RGhost 
      navigate ( 'http://rghost.ru/' ); 
      wait ( 15000 ); var imgUrl = 'http://static.webisida.com/files/webisida-468x60-005.gif' ; if ( setFile ( 'type = file' , 0 , imgUrl , 'gif' )) { print ( 'Picture selected' ); } else { print ( 'No picture selected' ); } 
      wait ( 5000 ); 
      submit ();
       
         
      	
        
      	
      
      
      // 3. Loading the banner on RGhost 
      navigate ( 'http://rghost.ru/' ); 
      wait ( 15000 ); var imgUrl = 'http://static.webisida.com/files/webisida-468x60-005.gif' ; var input = document . querySelector ( 'input [type = file]' ); if ( setFile ( input , imgUrl , 'gif' )) { print ( 'Picture is selected' ); } else { print ( 'No picture selected' ); } 
      wait ( 5000 ); 
      submit ();
       
        
        
      	
        
      	
      
    • Functions check mark the checkbox (input [type = checkbox]) or radio button (input [type = radio]) on the page in the active tab.
      check (form, element, newState, callback, timeout)
      check (tag, searchInfo, newState, callback, timeout)
      check (selectorKey, selectorData, newState, callback, timeout)
      Analogue of the "Check box" command in a static presentation.
      • form - name (name attribute) or index of the form in which the element is located. A string or numeric value is allowed.
      • element - the name (name attribute) or index of the element in the form into which you want to enter text. A string or numeric value is allowed.
      • tag - the name of the tag. Only the input tag is allowed .
      • searchInfo - a string value containing data for searching for an element by its attributes in the format attribute = attribute_value . Search by several attributes is possible, in this case attribute-value pairs must be separated by two exclamation marks ( !! ): attribute_A = value_attribute_A !! attribute_B = value_attribute_B .
      • selectorKey is a string containing the selector keyword . Specifies the search for a checkbox or radio button for a CSS selector.
      • selectorData is a string containing a valid CSS selector to find the element.
      • newState - the new state. Boolean value: true - if you want to check the item, false - if you need to uncheck the item.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Autologin on the 
      navigate forum ( 'http://webisida.com/?refid=403838ucp.php?mode=login' ); 
      wait ( 10000 ); 
      check ( 1 , 'autologin' , true ); 
      wait ( 10000 ); // <input name = "autologin" type = "checkbox" /> 
      check ( 'input' , 'name = autologin' , false );  
        
    • Function submit (form, callback, timeout) submits the form located on the page in the active tab. Similar to the Submit Form command in a static presentation.
      • form (optional) - The name (value of the name attribute ) or index of the form to be submitted. A string or numeric value is allowed. If the form parameter is not specified or the keyword = LAST = is specified , then the last form that the program worked with will be sent.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Search in Yandex 
      navigate ( 'http://ya.ru/' ); 
      wait ( 30,000 ); 
      setText ( 0 , 'text' , 'webisida.com' ); 
      submit ( '= LAST =' );  
      
      // 2. Search in Yandex 
      navigate ( 'http://ya.ru/' ); 
      wait ( 30,000 ); 
      setText ( 0 , 'text' , 'webisida.com' ); 
      submit ();  
    • Functions sendEvents searches for an element on the page loaded in the active tab and dispatches the specified events to it.
      sendEvents (tag, searchKey, data, events, index, callback, timeout)
      sendEvents (element, events, callback, timeout)
      Analogue of the Send Events command in a static presentation.
      • tag - the name of the tag of the element being searched for. String value.
      • searchKey - search key, a string that can take one of the following values:
        • id  - search for an element by ID, then the data parameter is the required identifier or part of it, depending on the current type of search .
        • link  - search for a link by its part, then the tag parameter should be a tag denoting a link (i.e. 'A'), and data - a part of the desired link. All types of search are available .
        • number  - search for an element by its ordinal number in the document, data - sequential number, starting from zero. Note: the data parameter must be specified as a string containing a number. For example, a call to the sendEvents ('a', 'number', '2' , 'click') function ; will cause the program to skip the first 2 links it finds and send a click event on the third. Whereas the call to the sendEvents ('a', 'number', 2, 'click'); will throw an exception with a message about an invalid data parameter .
        • text  - search for an object by part of the text contained in the innerHTML property, data  - part of the search text. All types of search are available .
        • name  - search for an object by its name (name attribute), data  - part of the element name. All types of search are available .
        • last  - selection of the last element found earlier by the text , check or sendEvents functions , the data parameter is ignored, but its input is required.
        • selector  - search for an element by a CSS selector, the data parameter must be a valid CSS selector. For example, calling sendEvents ('input', 'selector', 'div.row [name = text]', 'click') will send a click event to a text field named text located inside a div with class row , like this: <div class = "row"> ... <input type = "text" name = "text" /> ... </div> .
        • custom  - search for an object by attributes for which no separate commands have been created (for example, title, class, etc.), the data parameter is entered as a string in the format name = value , where name is the name of the attribute, value is part of the value of this parameter. Search by several attributes is possible, in this case the data parameter is specified as name1 = value1 !! name2 = value2 !! name3 = value3 ... (separated by !! by two exclamation marks). For example, calling sendEvents ('input', 'custom', 'class = btn !! type = button', 'click') will send a click event to a button like this: <input type = "button" class = "btn" value = "button" /> . All types of search are available .
      • data - string value: the data by which the search is performed. Depends on the searchKey parameter .
      • events - a string value: a valid event for the element, such as click, mousedown, keydown, etc. If you want to send multiple events, they must be separated by two exclamation marks ( !! ), for example, sendEvents ('a', 'link', 'http', 'mousedown !! mouseup !! click' ) .
      • index (optional) - numeric value: specifies the zero-based index of the element (among those matching the search criteria) to which events will be sent. If this parameter is missing, the event will be dispatched to the first item that matches the search criteria. If the value of this parameter is set to a negative value, one random object will be selected from the found objects.
      • element  is the previously found HTML element to dispatch the event to.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Sending a click event to a random forum link // containing the word viewtopic 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 30,000 ); 
      sendEvents ( 'a' , 'link' , 'viewtopic' , 'click' , - 1 );
          
      
      // 2. Dispatch a click event on a link Instructions 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 30,000 ); var links = document . getElementsByTagName ( 'a' ); for ( var i = links . length - 1 ; i > = 0 ; i -) { var a = links [ i ]; if ( a . innerHTML == 'Instructions' ) { 
      		sendEvents ( a , 'click' ); break ; } }
      
          
      	
      	    
      		
      	
      
    • Function clearStorage (storageType, domain, domain, ...) clears stored identity data: cookie, Flash LSO storage, IndexedDB, cache, history. Analogous to the "Clear Cookies" command in a static presentation.
      • storageType (optional) - string value, type of storage being cleared. Allowed values ​​(comma-separated list is possible):
        • all - all storages. Used as the default.
        • cookie - cookies.
        • flash - Flash LSO.
        • indexedDB - IndexedDB.
        • cache - cache.
        • history - history.
      • domain (optional) - the domain to be cleaned up. By default, data for all domains is deleted.
      Returned value: undefined .

      Call examples:

      // 1. Clearing all data. 
      clearStorage ();
      
      // 2. Clearing all data. 
      clearStorage ( 'all' );
      
      // 3. Clearing cookies, cache and history 
      clearStorage ( 'cookie, cache, history' );
      
      // 4. Remove cookies and Flash LSO content for example.com 
      clearStorage ( 'cookie, flash' , 'example.com' ); 
      
      // 5. Removing cookies and Flash LSO content for sites example.com and site.ru 
      clearStorage ( 'cookie, flash' , 'example.com' , 'site.ru' );  
    • Function post (url, data, referrer, callback, timeout) loads the active tab of the page at the address specified in the url parameter , using the POST method to transfer the data data to this page in application / x-www-form-urlencoded encoding . Analogue of the "Go to POST" command in a static presentation.
      • url is a string value, the address of the page to which the data will be sent and the transition will be made.
      • data - a string value, URI-encoded data to send. You can use the encodeURIComponent function to encode pieces of data .
      • referrer (optional) - the address of the referrer page. To pass the address of the current page as a referrer, specify the CURRENT keyword. If the value is absent, then a direct jump will be performed.
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      / * 1. Simulate form submission
      * <form method = "post" action = "http://www.site.ru/login.php">
      * <input name = "user" value = "Admin" />
      * <input name = "pass" value = "123" type = "password" />
      * <input type = "submit" />
      * </form>
      ************************************************ / // create data var data = 'user =' + encodeURIComponent ( 'Admin' ) + '& pass =' + encodeURIComponent ( '123' ); // send them and wait 30 seconds for the page to load 
      post ( 'http://example.com/' , data ); 
      wait ( 30,000 ); print ( 'data sent, page loaded' );
      
         
      			  
      
      
    • Functions click perform clicks on an object using operating system functions.
      click (tag, searchKey, data, index, clickRectangle, moveClickTime, target, callback, timeout)
      click (element, clickRectangle, moveClickTime, target, callback, timeout)
      click (viewport, searchKey, data, callback, timeout) - click on coordinates ...
      The object perceives the click as coming from the user and performs the appropriate action, such as following a link or submitting a form. The function is executed asynchronously, it takes about 4-5 seconds to simulate moving the mouse from a random point and then click it (the time can be changed). Analogue of the "Click" command in a static presentation.
      • tag - the name of the tag of the element being searched for. String value.
      • searchKey - search key, a string that can take one of the following values:
        • id  - search for an element by ID, then the data parameter is the required identifier or part of it, depending on the current type of search .
        • link  - search for a link by its part, then the tag parameter should be a tag denoting a link (i.e. 'A'), and data - a part of the desired link. All types of search are available .
        • number  - search for an element by its ordinal number in the document, data - sequential number, starting from zero. Note: the data parameter must be specified as a string containing a number. For example, a call to the function click ('a', 'number', '2' ); will make the program skip the first 2 links it finds and click on the third one. Whereas the function call click ('a', 'number', 2); will throw an exception with a message about an invalid data parameter .
        • text  - search for an object by part of the text contained in the innerHTML property, data  - part of the search text. All types of search are available .
        • name  - search for an object by its name (name attribute), data  - part of the element name. All types of search are available .
        • last  - selection of the last element found earlier by the text , check or sendEvents functions , the data parameter is ignored, but its input is required.
        • selector  - search for an element by a CSS selector, the data parameter must be a valid CSS selector. For example, calling click ('input', 'selector', 'div.row input.button') will click on an element with an input tag and a button class located inside a div with class row , like this: <div class = "row"> ... <input type = "submit" class = "button" /> ... </div> .
        • custom  - search for an object by attributes for which no separate commands have been created (for example, title, class, etc.), the data parameter is entered as a string in the format name = value , where name is the name of the attribute, value is part of the value of this parameter. Search by several attributes is possible, in this case the data parameter is specified as name1 = value1 !! name2 = value2 !! name3 = value3 ... (separated by !! by two exclamation marks). For example, when you call click ('input', 'custom', 'class = btn !! type = button'), the click will be made on the following button: <input type = "button" class = "btn" value = "button" / > . All types of search are available .
      • data - string value: the data by which the search is performed. Depends on the searchKey parameter .
      • index (optional) - numeric value: specifies the zero-based index of the element (among those matching the search criteria) to which events will be sent. If this parameter is missing, the event will be dispatched to the first item that matches the search criteria. If the value of this parameter is set to a negative value, one random object will be selected from the found objects.
      • clickRectangle (optional) - string value, specifies the rectangle in the searched object, within which the click will be made. It is required if it matters at what point of the object a click should be made (for example, to start playing a flash movie, you need to press the Play button). The absence of a value determines a click at any point in the object. It is entered in the format x: y: width: height , where x and y denote the coordinate of the starting point of the rectangle within which the click should be made, width and height are the width and height of the rectangle. The values ​​are entered in pixels. If you want to keep the default, enter null .
        For example, we need to click on the flash player, which is denoted by an HTML element with the embed tag , the id element attribute is movie_player , the flash player dimensions are 640x390 pixels, the upper left corner of the Play button is at point (0; 365), when counting down The X is on the left (0) and the Y is on top (365), and it is 55x25 pixels in size. Then the function can be called like this: click ('embed', 'id', 'movie_player', 0, '0: 365: 55: 25' ); ...
      • moveClickTime (optional) - string value, click time parameters. Should be entered only if different from the accepted default values. It is entered in the format moveTime: clickTime , where moveTime (in milliseconds) is the time the mouse moves from a random point outside the browser to the clicked point in a given object (3000 ms by default), clickTime (in milliseconds) is the time from the end of the mouse movement until the left button is pressed , the default is a random value from 150 to 700 ms. If you want to keep the default, enter null .
        An example of input, 2.5 seconds (2500 ms) to move the mouse, and 0.8 seconds (800 ms) to click: click ('embed', 'id', 'movie_player', 0, null, '2500: 800' );
      • target (optional) - string value: the value by which the value of the target attribute of the link is replaced , by default - _top (to prevent trying to open the link in a new window). Enter the ORIGIN keyword to turn off autocorrect.
        Example 1: click ('a', 'link', 'http', 0, null, null, '_blank' );
        Example 2: click ('a', 'link', 'http', 0, null, null, 'ORIGIN' ); - do not change target of the link
      • element  is a previously found HTML element to be clicked on.
      • the viewport - the keyword the viewport , determining the coordinates of the click in the visible area of the window. The data parameter must be passed as a string in the xAlign: yAlign: width: height format, defining the clickable rectangle in the visible part of the page, where
        • xAlign - the X coordinate of the left edge of the rectangle, or one of the keywords that define the anchor of the rectangle along the X axis. Allowed keywords are left (anchor to the left), center (anchor to the center), right (anchor to the right).
        • yAlign - the Y coordinate of the top edge of the rectangle or one of the keywords that define the y-anchor of the rectangle. Allowed keywords are top (anchor to the top), center (anchor to the center), bottom (anchor to the bottom).
        • width - the width of the rectangle, or the width keyword to substitute a value equal to the width of the window. The value that determines the width of the rectangle must be at least 1 (one).
        • height - the height of the rectangle, or the height keyword to substitute a value equal to the height of the window. The value that determines the height of the rectangle must be at least 1 (unit).
      • callback (optional) - Continuation function .
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Click on the link on the forum 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 30,000 ); 
      click ( 'a' , 'link' , 'viewtopic' , - 1 ); 
      
      // 2. Click on the player on YouTube // go to the player 
      navigate ( 'http://www.youtube.com/' ); 
      wait ( 30,000 ); 
      loadLink ( 'link' , 'watch' , - 1 ); 
      wait ( 30,000 ); 
      click ( 'object' , 'id' , 'movie_player' , 0 , '0: 365: 55: 25' );
            
      
      // 3. Click on the previously found element - the player // go to the player 
      navigate ( 'http://www.youtube.com/' ); 
      wait ( 30,000 ); 
      loadLink ( 'link' , 'watch' , - 1 ); 
      wait ( 30,000 ); // find the player using JavaScript var player = document . getElementById ( 'movie_player' ); // click 
      click ( player , '0: 365: 55: 25' );
        
      
      
       
      
      // 4. Click on coordinates 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); 
      click ( 'viewport' , 'custom' , 'center: center: 1: 1' ); // in the center of the window 
      click ( 'viewport' , 'custom' , '100: 100: 1: 1' ); // at point (100; 100) 
      click ( 'viewport' , 'custom' , '0: 0: width: height' ); // anywhere 
      click ( 'viewport' , 'custom' , 'right: bottom: 100: 100' ); // bottom right            
    • Functions setFrame changes the frame in which to search for items on the page in the active tab.
      setFrame (data)
      setFrame (frameElement)
      By default, presentation functions work with the main loaded page (main frame). If the page contains nested frames, then, for example, the loadLink function will not find the link contained in the frame. This can be avoided by changing the frame with which the program is working.
      Analogue of the "Change Frame" command in a static presentation.
      List of functions whose execution depends on the current frame: loadLink , loadSiteLink , setText , check , submit , sendEvents , click .
      • frameElement is an element with a FRAME or IFRAME tag.
      • data - an integer or string value, the data on the basis of which the frame is selected.
        • TOP  is the main frame of the page (main document).
        • Frame identifiers. Specifying multiple IDs separated by !! (with two exclamation marks), allows access to nested frames, i.e. if the main document contains one frame, and this frame contains two more frames, of which we need the second, then the command parameter must be set to 0 !! 1 (the numbering of frames starts from zero).

          The identifier can take the following values:

          • Number  - the frame number (at the current nesting level), starting at zero. When the number is 5, the sixth frame of the document will be found . Call example: frame ('5');
          • url = URL , where instead of the URL you need to enter the part of the address that should be contained in the desired frame. When you enter the url = mysite.ru parameter , the following frame will be found, for example: <iframe src = " http://www.mysite.ru?12345 "> .
          • url == URL , where instead of URL you need to enter the exact address (matching for each character) of the claim frame. When you enter the url == http: //www.mysite.ru/ parameter , ONLY SUCH frame will be found : <iframe src = " http://site.com/ "> .
          • name = NAME , where instead of NAME you need to enter part of the name of the frame you are looking for. Entering the name = fra parameter will find, for example, the following frame: <iframe name = "mega fra me" src = "http://mysite.ru"> .
          • name == NAME , where instead of NAME you must enter the exact name of the frame. When you enter the name == megaframe parameter , ONLY a frame will be found: <iframe name = " megaframe " src = "http://mysite.ru/?12345">
          • selector; selectorData , where instead of selectorData you need to enter the value of the CSS selector by which you can find the frame. Calling setFrame ('selector; iframe [src * = example]') will select the frame into which the document is loaded, the address of which contains the word example . For example: <iframe src = "http://example.com"> </iframe>
          • custom; attributeName = attributeValue , iframe; attributeName = attributeValue , or frame; attributeName = attributeValue , where attributeName is the name of the attribute, attributeValue is the value of the attribute. For example, if you enter the parameter custom; id = frame12345 , the frame will be selected: <iframe id = " frame12345 " src = "">

          Usage example

          Objective: We need to call the link function to follow the link <a href="http://www. mysite .com" onclick="click_handler()"> Link </a> in the <iframe name = " frame2 "src =" http://mysite.ru/frame.php "> . We know for sure that we need a frame named frame2 or the URL http://site.com/frame.php . Which way to search for a frame to use is irrelevant in this example. Searching for name == frame2 and url = frame.php will work the same way.

          Search by frame name is preferred. Therefore, you need to write a similar JavaScript code:

          // 1. Changing a frame by its name 
          setFrame ( 'name == frame2' ); // 
          Follow the link loadLink ( 'link' , 'mysite' );
          
          
          // 2. Changing the frame to the one selected by the script var frame = window . getElementsByTagName ( 'iframe' ) [ 0 ]; 
          setFrame ( frame );
          

          Note 1 . When searching for frames, a case-insensitive data comparison is used.

          Note 2 . You can use tools such as a Firefox add-on called Firebug, built-in browser tools to explore the document's frame structure, or at the right time click on the Frames button in the presentation testing program and the results of the study of the frame structure will be written to the log window.

      Returned value: undefined .
    • Function clearTab (tabIndex) clears the specified tab.
      • tabIndex - numeric value, tab number. It can be 0, 1, 2, or 3.
      • callback (optional) - A continuation function that will be called after the specified tab is activated.
      • timeout (optional) - time in seconds after which the function passed in the callback parameter will be called .
      Returned value: undefined .

      Call examples:

      // 1. Go to Yandex and clear the tab 
      activateTab ( 0 ); 
      navigate ( 'http://ya.ru' ); 
      wait ( 30,000 ); 
      clearTab ( 0 );
      
      // 2. Go to Yandex, clean up, go to Google. 
      activateTab ( 0 ); 
      navigate ( 'http://ya.ru' ); 
      wait ( 30,000 ); 
      clearTab ( 0 ); 
      wait ( 5000 ); 
      navigate ( 'http://google.com' );
    • Functions getWindow returns a Window object - the context of the specified tab or frame.
      getWindow (tabIndex)
      getWindow (document)
      getWindow (frameElement)
      If a frame has been set for a tab by calling the setFrame function , then getWindow (tabIndex) will return that frame's context.
      Please note: during transitions, the context and all objects dependent on it can be destroyed. For further work with the tab, after any new page load into the tab, the Window object must be re-acquired, as well as all the objects dependent on it.
      • tabIndex (optional) - numeric value, tab number. It can be 0, 1, 2, or 3. If the tabIndex parameter is omitted, the Window object for the main (zero) tab is returned by default .
      • document - the document loaded into a tab or frame.
      • frameElement - the element with the FRAME or IFRAME tag for which you want to get the context.
      Returned value: an object of type Window - the context of the specified tab or frame.

      Call examples:

      // 1. Getting the context of the main tab var aWindow = getWindow ( 0 ); 
      aWindow . document . body . innerHTML = 'This text will be visible in the main tab' ;
       
      
      // 2. Get the context for the IFRAME element var frame = aWindow . document . getElementsByTagName ( 'iframe' ) [ 0 ]; var frameWindow = getWindow ( frame . contentDocument ); 
      frameWindow . document . body . innerHTML = 'This text will be visible inside the frame' ;
      
       
      
      // 3. Get the context for the IFRAME element var frame = aWindow . document . getElementsByTagName ( 'iframe' ) [ 0 ]; var frameWindow = getWindow ( frame ); 
      frameWindow . document . body . innerHTML = 'This text will be visible inside the frame' ;
      
       
      
      // 4. Retrieving context after transition var aWindow , document , count ; 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 15000 ); 
      aWindow = getWindow ( 0 ); 
      document = aWindow . document ; 
      count = aWindow . document . getElementsByTagName ( 'a' ). length ; print ( 'Links on the page:' + count ); 
      navigate ( 'http://ya.ru' ); 
      wait ( 15000 ); 
      aWindow = getWindow ( 0 ); 
      count = aWindow . document . getElementsByTagName ( 'a' ). length ; print ( 'Links on the page:' + count ); try { // executing this code will throw an error 
      	count = document . getElementsByTagName ( 'a' ). length ; print ( 'You will not find this inscription in the report' ); } catch ( e ) { print ( 'Here's an error like this:' + e ); }
      
       
       
       
      	
      	
        
      	 
      
    • Function print (message) prints the message message to the presentation execution log.
      • message (optional) - message. Can be any type of value. If not specified, an empty line is printed to the log.
      Returned value: undefined .

      Call examples:

      // 1. Outputting a message to the log print ( 'start of presentation' );
      
    • Function clearLog () clears the presentation execution log.
      Returned value: undefined .
    • Function pause (timeout, callback) adds the function passed in the callback parameter to the execution queue so that it will be called after the time interval passed in the timeout parameter and counted from the moment the pause function was called . If the callback parameter is not specified, the function will pause the execution of the current script code, similar to calling the wait (timeout * 1000) function .
      Please note: JavaScript is always executed in single-threaded mode, so the function passed in the callback parameter , in some cases, will start executing not strictly after the specified time interval, but somewhat later. The reason for this behavior is that at the time the interval expires, some other code may be executing in the thread of execution.
      • timeout is a positive integer specifying the time interval (in seconds) - a pause.
      • callback is a continuation function that will be called after a pause.
      Returned value: undefined .

      Call examples:

      // 1. Outputting a message to the log in 10 seconds. after the start print ( 'We are waiting for 10 seconds ...' ); 
      pause ( 10 , function ( aWindow ) { print ( ' At least 10 seconds have passed' ); }); print ( 'We can execute some more code ...' );
        
      	
      
      
      
      // 2. Outputting a message to the log in 10 seconds. after the start print ( 'We are waiting for 10 seconds ...' ); 
      pause ( 10 ); print ( 'At least 10 seconds have passed' );
      
      
    • Function stop (exit) stops the execution of the presentation.
      • exit (optional) - Boolean value. If you want to stop the execution of a dynamic presentation, but you want to continue browsing the site, pass false as a parameter or leave it blank, for example, stop (); ... If you want to stop the presentation and finish browsing the site, set the exit parameter to true .
        Attention: the minimum viewing time is 30 seconds, so the viewing will be instantly stopped only if more than 30 seconds have passed since the start of the presentation. Otherwise, despite the fact that the presentation will be stopped, the interruption of the viewing will be delayed and it will be interrupted after 30 seconds have passed since the beginning of the presentation.
        In case of interruption, payment for viewing will be charged for the actually used time, but not less than 30 seconds of viewing.
      Returned value: undefined .

      Call examples:

      // 1. Stop the execution of the presentation script print ( 'Stop the presentation' ); 
      stop (); print ( 'This text will not be in the log' );
      
      
      
      // 2. Stop the execution of the presentation script // and end the visit (for this example // to work correctly , set the presentation execution time // to no less than 45 seconds). The presentation will stop // immediately after the stop function is executed. 
      wait ( 35000 ); // wait 35 sec. print ( 'Stop the presentation' ); 
      stop ( true ); print ( 'This text will not be in the log' );
      
      
      
       
      
      
      
      // 3. Stop execution of the presentation script // and end viewing (for this example // to work correctly , set the presentation execution time // to no less than 45 seconds). Although // the code execution will stop after 15 seconds, // the preview will only end when 30 seconds have passed. // since the start of the presentation. 
      wait ( 15000 ); // wait 15 sec. print ( 'Stop the presentation' ); 
      stop ( true ); print ( 'This text will not be in the log' );
      
      
      
      
      
       
      
      
    • Functions screenshot creates a screenshot of an element or specified part of a page in the active tab.
      screenshot ()
      screenshot (x, y, width, height, format, saveToDisk)
      screenshot (element, format, saveToDisk)
      The generated image is encoded in BASE64 format and saved as a string to the vars.screenshot variable . When called without parameters, a screenshot of the part of the page that is visible at the time of calling, bounded by the window frames, will be created.
      • imageElement - an element with an IMG tag that contains an image to get a screenshot of.
      • x , y - coordinates of the upper left corner of the rectangle in the visible part of the page, within which the page snapshot should be taken.
      • width , height - the width and height of the rectangle within which the page snapshot should be taken.
      • format (optional) - string value, one of the following formats: gif , png , jpg , bmp . Default: jpg.
      • saveToDisk (optional) Boolean. If set to true, saves a copy of the screenshot in the folder with the testing program. Works only in test mode, in operating mode it is ignored. The screenshot is always saved in the screenshot.png file in PNG format, regardless of the format specified in the format parameter .
      Return value: string value containing the BASE64 encoded image .

      Call examples:

      // 1. Screenshot of the Google logo with saving to disk 
      navigate ( 'https://www.google.ru/search?q=test' ); 
      wait ( 10000 ); 
      screenshot ( 0 , 0 , 100 , 100 , null , true );     
      
      // 2. Screenshot of the Google logo in GIF format 
      navigate ( 'https://www.google.ru/search?q=test' ); 
      wait ( 10000 ); 
      screenshot ( 0 , 0 , 100 , 100 , 'gif' ); // output the logo encoded in BASE64 to the log print ( vars . screenshot );    
      
      
      
      // 3. Screenshot of the Google logo and displaying it in the 
      navigate log ( 'https://www.google.ru/search?q=test' ); 
      wait ( 10000 ); print ( screenshot ( 0 , 0 , 100 , 100 ));
         
    • Functions recognizing text in an image using services that support the Antigate API,
      recognize (element, key, callback)
      recognize (base64Image, key, callback)
      recognize (x, y, width, height, key, callback)
      recognize (element, params, callback)
      recognize (base64Image, params, callback)
      recognize (questionOrNull, params, callback)
      recognize (x, y, width, height, params, callback)
      send an image created based on the passed parameters to the text recognition service ( anti-captcha.com ( antigate.com) , ruCaptcha.com , Captcha24.com , Pixodrom.com , CaptchaBot.com , cptch.net or other supporting Antigate API). Upon completion of the recognition, the received text is saved into the vars.recognizedText variable and the function passed in the callback parameter is called. If the callback parameter is not specified, the script execution is suspended until a response is received from the service performing the recognition.
      • element - the element containing the image on which you want to recognize the text. If the captcha is recognized by Google ReCaptcha v2.0, a frame containing a set of images for selection can be passed as this argument.
      • base64Image is a string value containing a BASE64 encoded image.
      • questionOrNull is a string containing the keyword question , or null , which means that the question passed in the params.comment parameter should be sent to the recognition service .
      • x , y - coordinates of the upper left corner of the rectangle in the visible part of the page, within which a snapshot of the page should be taken to recognize the text in this screenshot.
      • width , height - the width and height of the rectangle within which the page snapshot should be taken to recognize the text in this screenshot.
      • key - access key to the recognition service.
      • params - an object that provides extended information about the image and settings for the recognition service.
        Format object the params (default):
        var params = { 
        	save : false , // saving the image to disk during testing 
        	format : 'jpg' , // the format of the saved image 
        	words : 0 , // the number of words (0 - unknown), 
        	minlen : 0 , // minimum text length on the image (0 - unknown) 
        	maxlen : 0 , // maximum text length on the image (0 - unknown) 
        	consistency : 0 , // text composition: 0 - any characters, 1 - only numbers, 2 - no numbers 
        	ignoreCase : false , // character case: true - not important, false - case sensitive 
        	expression : false , // a mathematical expression is shown: true - yes, false - no 
        	cyrillic : false , // presence of Cyrillic characters: true - yes, false - no 
        	submit : true , // auto-confirmation after captcha recognition Google ReCaptcha v2.0 
        	timeout : 600000 , // maximum recognition time in milliseconds 
        	service : 'http://antigate.com' , // address of the recognition service 
        	strictApi : false , // strict compliance Antigate API 
        	question : false , // a question was asked in the image, worker d You must write an answer (for ruCaptсha) 
        	comment : null , // explanatory text for captcha or a question 
        	key : '' // key of the recognition service };                                   
        
      • callback (optional) - A continuation function that will be called after receiving a response from the image recognition service.
      Return value: a string containing either a BASE64 encoded image if the callback parameter was specified, or the recognized text, or null if the callback parameter was not specified.

      Call examples (see also more examples at BitBucket.org ):

      // Google ReCaptcha v1.0 recognition var antigateKey = 'f90e012df680dbff0d5e8e2e8f0fc91d' ; // Service key
        
      
      navigate ( 'https://www.google.com/recaptcha/demo/' ); 
      wait ( 5000 ); var image = document . querySelector ( 'img [src * = recaptcha]' ); // search for captcha
       
      
      
      // 1. Synchronous recognition using the Antigate.com service var aText = recognize ( image , antigateKey ); if ( aText ) { print ( 'Text on captcha:' + aText ); 
      	setText ( document . querySelector ( 'input [name = recaptcha_response_field]' ), aText ); } else { print ( 'The text was not recognized!' ); }
      
       
      	 
        
      	
      
      
      // 2. Synchronous recognition using the ruCaptcha.com service var rucaptchaKey = 'f90e012df680dbff0d5e8e2e8f0fc91d' ; var aText = recognize ( image , { service : 'http://rucaptcha.com' , key : rucaptchaKey }); if ( aText ) { print ( 'Text on captcha:' + aText ); 
      	setText ( document . querySelector ( 'input [name = recaptcha_response_field]' ), aText ); } else { print ( 'The text was not recognized!' ); }
       
         
       
      	 
        
      	
      
      
      // 3. Synchronous recognition using the Сaptcha24.com service var captcha24Key = 'f90e012df680dbff0d5e8e2e8f0fc91d' ; var aText = recognize ( image , { service : 'http://captcha24.com' , key : captcha24Key }); if ( aText ) { print ( 'Text on captcha:' + aText ); 
      	setText ( document . querySelector ( 'input [name = recaptcha_response_field]' ), aText ); } else { print ( 'The text was not recognized!' ); }
       
         
       
      	 
        
      	
      
      
      // 4. Asynchronous recognition by Antigate.com service 
      Recognize ( image , antigateKey , function () { // If the service recognizes the text, vars.recognizedText contains the result of the if ( vars . RecognizedText ) { print ( "The text displayed in a CAPTCHA: ' + vars . recognizedText ); 
      		the setText ( document . querySelector ( 'input the [name = recaptcha_response_field]' ), vars . recognizedText ); } the else { print ( "The text was not recognized! ' ); } });   
      	
      	  
      		 
      	  
      		
      	
      
      
      // 5. Asynchronous recognition using the Pixodrom.com service var pixodromKey = 'f90e012df680dbff0d5e8e2e8f0fc91d' ; 
      Recognize ( image , { service, : 'http://pixodrom.com' , key : pixodromKey }, function () { // If the service recognizes the text, vars.recognizedText contains the result of the if ( vars . recognizedText ) { print ( 'The text on displayed in a CAPTCHA: ' + vars . recognizedText ); 
      		the setText ( doc all . querySelector ( ' input the [name = recaptcha_response_field] ' ), vars . recognizedText ); } the else { print ( "The text was not recognized!' ); } });
            
      	
      	  
      		 
      	  
      		
      	
      

      Note 1 . At the moment, recognition of the captcha "I am not a robot" is supported only when working with the services anti-captcha.com , ruCapctha.com and cptch.net . The element argument to recognize must be passed a frame or any block containing a set of images to select. After successful recognition, the program will try to automatically mark the selected images.

      An example of captcha recognition "I'm not a robot" (see also additional examples on BitBucket.org ):

      // Google Recaptcha v2.0 recognition var rucaptchaKey = 'f90e012df680dbff0d5e8e2e8f0fc91d' ; // Key of the ruCaptcha service
        
      
      navigate ( 'http://www.google.com/recaptcha/api2/demo' ); 
      wait ( 5 , 10 ); 
      
      setFrame ( 'selector; iframe [src * = recaptcha \\ / api2 \\ / anchor]' ); 
      click ( 'div' , 'selector' , 'div.recaptcha-checkbox-checkmark' );  
      
      var recaptcha2 = document . querySelector ( 'iframe [src * = recaptcha \\ / api2 \\ / frame]' ); if ( recaptcha2 ! = null ) { 
      	recognize ( recaptcha2 , { 
      		service : 'rucaptcha.com' , 
      		timeout : 60000 , // captcha is changing, there is no point in waiting for more than 60 seconds. 
      		key : rucaptchaKey
      	 }); }
             
      
    • Functions solutions of the captcha "I am not a robot" using the services anti-captcha.com , ruCapctha.com and cptch.net
      solveRecaptcha (element, key)
      solveRecaptcha (element, params)
      send the captcha key "I am not a robot" to the service for solving this type of captcha, and then they try to write the solution received from the service in a field named g-recaptcha-response, designed to transmit the verification code to the site.
      • element - an element containing the data-sitekey attribute in which the captcha key "I'm not a robot" is located. Allowed value is null - in this case the program will try to find the key for the captcha on its own in the data-sitekey attribute of the element containing the captcha. When passing a null value, the key can also be specified via the params.siteKey parameter .
      • key - access key to the recognition service.
      • params - an object that allows you to set advanced settings
        Format of the params object (with default values):
        var params = { 
        	service : 'antigate' , // recognition service 
        	timeout : 600000 , // maximum waiting time for a response in milliseconds 
        	copyToTextArea : true , // enter a response in the g-recaptcha-response field (true - enter, false - do not enter ) 
        	siteKey : '' , // key to create captcha (from the data-sitekey attribute) 
        	siteUrl : 'URL of the active frame' , // address of the page with captcha (required if siteKey is specified) 
        	secure : false , // use HTTPS for communication with the service for solving the captcha (true - yes, false - no) 
        	key : '' // key of the recognition service };                 
        

        Valid values ​​for params.service parameter :

      Returned value: a string containing the solution code, sent to the g-recaptcha-response field, or null if the captcha could not be resolved.

      An example of solving the captcha "I'm not a robot" (see also additional examples on BitBucket.org ):

      // 1. Solving the captcha 'I'm not a robot' var antigateKey = 'f90e012df680dbff0d5e8e2e8f0fc91d' ; // key for anti-captcha.com 
      navigate ( 'https://www.google.com/recaptcha/api2/demo' ); 
      wait ( 5000 ); var code = solveRecaptcha ( null , antigateKey ); if ( code ! = null ) { 
      	click ( 'input' , 'id' , 'recaptcha-demo-submit' ); } else { print ( 'Captcha failed' ); }
        
      
           
        
      	
      
      
      // 2. Solving the captcha 'I'm not a robot' var antigateKey = 'f90e012df680dbff0d5e8e2e8f0fc91d' ; // key for anti-captcha.com 
      navigate ( 'https://www.google.com/recaptcha/api2/demo' ); 
      wait ( 5000 ); var code = solveRecaptcha ( null , { 
      	key : antigateKey , 
      	timeout : 60000 , // 1 minute 
      	siteKey : '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-' , 
      	siteUrl : 'https://www.google.com/' }); if ( code ! = null ) { 
      	click ( 'input' , 'id' , 'recaptcha-demo-submit' ); } else { print ( 'Captcha failed' ); }
        
           
      
           
        
      	
      
      		

      It is also possible to solve the invisible captcha from Google. However, in this case, you must independently call the callback function, which is executed after passing the captcha, or submit the appropriate form.

      // Walkthrough Invisible reCAPTCHA 
      navigate ( 'https://www.google.com/recaptcha/api2/demo?invisible=true' ); 
      wait ( 5000 ); var code = solveRecaptcha ( null , { 
      	service : 'rucaptcha' , 
      	key : 'f90e012df680dbff0d5e8e2e8f0fc91d' // key for rucaptcha.com }); if ( code ! = null ) { 
      	executeJavaScript ( "onSuccess ('" + code + "')" ); } else { print ( 'Captcha failed' ); }
          
      
           
        
      	
      
      		
    • Function get (key) returns the value of the presentation state variable.
      • key - string value, name of the state variable. Can be one of the following values:
        • time - the remaining viewing time.
        • ip - the visitor's IP address.
        • referer - referrer sent from the system server.
        • tab - the number of the active tab.
        • search is the current search method .
        • log - the contents of the execution log.
        • test - Returns true if the script is executed in the testing program.
        • land - the two-letter country code (ISO 3166-1 alpha-2 standard), which owns the visitor's IP according to the system version, or XX, if the system could not determine the country to which the IP address belongs, or the presentation is performed in the testing program.
        • version - the version of the program in which the script is executed.
        • totalmemory - the amount of RAM installed on the computer, in megabytes.
        • memory - the amount of available RAM on the computer in megabytes.
        • totalvirtualmemory The total amount of virtual memory on the computer, in megabytes.
        • virtualmemory The amount of available virtual memory on the computer, in megabytes.
      Return value: string or number, depending on the key parameter .

      Call examples:

      print ( 'There are:' + get ( 'time' ) + 'seconds' left to complete the presentation ); print ( 'Visitor IP:' + get ( 'ip' )); print ( 'Active tab number:' + get ( 'tab' ));    
        
        
    • Function set (key, value [, key2, value2, ...]) sets the value of the presentation state variable.
      • key - string value, name of the state variable. Can be one of the following string values:
        • search - a way to compare when searching for items. Then the value parameter is a string and can take the following values:
          • std is a full-text search method. Finds an element only if the search value exactly matches the given data (case-insensitive only when searching for a URL).
          • index - uses the partial search method, enabled by default. Finds an element only if part of the lookup value matches the given data (case-insensitive only for URL lookups).
          • regexp - search for a match by regular expression. Regular expressions are specified as / pattern / flags. Allowed flags are i, m, s, n, x (more about flags).
          Lasts until overridden by a new value.
        • hidden - determines whether the program should ignore links and other elements with the display: none style when searching .
          Then the value parameter is boolean. To include hidden items in search results - true , to ignore - false .
        • log - Forces the program, after the show is executed, to send the contents of the presentation execution log to the specified address using the POST method in application / x-www-form-urlencoded format in UTF-8 encoding.
          The value parameter is a string and is entered in the following format: PASSWORD: URL or URL , where URL is the address starting with http: // or https: // to which the report will be sent, and PASSWORD (optional) is the password you invented that will be sent along with the rest of the data.

          Transmitted data:

          • id - ID of the advertising platform (site)
          • ip - visitor's IP address
          • log - the contents of the log
          • password - password, if specified by you.

          Sample reporting scripts (PHP): log-examples.7z

        • js - enable / disable JavaScript in the active tab.
          Then the value parameter is boolean. To enable JavaScript - true , to disable - false .
        • img - enable / disable loading images in the active tab.
          Then the value parameter is boolean. To enable images - true , to disable - false .
        • java - disable Java detection via navigator.javaEnabled (). Valid value is false .
        • popup - open new / pop-up windows. When you click on some elements such as flash banners, or on links, clicks on which are processed by JavaScript, the pages may open in a new window and it is difficult or impossible to influence it. But since all pop-ups are blocked by the SecureSurf browser by default, the desired page opening in a new window will be blocked. This option allows you to allow such pages to open either in the current window or in an additional window.
          Then the value parameter is an integer - the allowed number of redirects to pop-up windows. An example of a call to allow the opening of 5 consecutive pop-up windows, while the contents of the fifth window can replace the contents of previous windows (instead of 5, there can be any value greater than zero): set ('popup', 5); ...
          Prevent pop-ups from opening: set ('popup', 0);
        • openwin allow / disallow work with an additional window

          By default, links that have the target = "_blank" attribute and try to open in a new browser window (tab) are redirected to the main site window. This setting overrides this behavior and, depending on the state of this option, the content of the page to which the link points can be loaded into an additionally hidden browser window, thereby preventing the replacement of content in the main window.

          Then the value parameter can take values ​​0 and 1.
          • 1  - allow loading content into an additional hidden window.
          • 0  - prohibit loading content into an additional hidden window.

          Note : when using this option, it is recommended to also allow opening N-number of pop-up windows by calling set ('popup', N) ( see above ).

        • popuptab sets the number of the tab that pop-ups / new windows will be redirected to.

          By default, links that have the target = "_blank" attribute and try to open in a new browser window (tab) are redirected to the main working tab. This setting overrides this behavior and, depending on the state of this option, the content of the page to which the link points can be loaded into one of the additional tabs of the browser, thereby preventing the replacement of content in the main window.

          Then the value parameter can take an integer from 0 to 3 (tab number) or next and prev strings . To prevent the switch operating tab can be added to the value value keyword NOFOCUS , for example, set ( 'popuptab', '1, NOFOCUS') .
          • 0, 1, 2, 3  - allows loading content in the tab with the number 0, 1, 2 or 3, respectively.
          • next  - Allows to the next tab.
          • prev  - Allows to the previous tab.

          Note : when using this option, it is recommended to also allow opening N-number of pop-up windows by calling set ('popup', N) ( see above ).

        • retarget - enable / disable the replacement of the target property of links when clicking on them using the click function .
          Then the value parameter is boolean. To enable the override - true , to disable - false .
        • recaptchalng - change the language of the tip text for captcha reCAPTCHA v2.
          The value parameter is a string containing the code of the language in which the hint text for the captcha loaded later should be, or the default keyword for automatic selection of the captcha language. Valid language codes are listed in the developer documentation .
        • recaptchafallback - switch reCAPTCHA v2 captcha to simplified display mode.
          The value parameter is a boolean value: true - to enable display in a simplified form, false - display based on browser settings (display in standard form).
        • promptvalue - Sets the return value for the window.prompt () function .
          The value parameter is a string containing the return value.
        • errmode - setting the response mode for unhandled exceptions.
          By default, the program runs in mode No. 2 (presentation is interrupted).
          • 0  - interrupt presentation and wait until the time allotted for execution expires.
          • 2  - stop presentation.
        • preclick - control of a preliminary click when typing text by character using the typeIn function .
          The value parameter is a boolean value that determines the possibility of a preliminary click in the input field to set the cursor ( true - click is allowed, false - click is prohibited), or an integer value not exceeding 5000, which determines the pause between the click and the beginning of text input. Setting it to a negative value is equivalent to setting it to false (denies clicking).
      Returned value: undefined .

      Call examples:

      // 1. Disable images in the current tab and enable sending log set ( 'img' , false , 'log' , 'password: http: //site.ru/log.php' );
         
      
      // 2. Disable images in the current tab set ( 'img' , false );
       
      
      // 3. Permission to open the forum in the first 
      navigate tab ( 'http://webisida.com' ); 
      wait ( 20000 ); set ( 'popup' , 1 , 'openwin' , 1 ); 
      click ( 'a' , 'link' , 'forum' , 0 , null , null , 'ORIGIN' );
               
      
      // 4. Displaying the text of reCAPTCHA V2 in English set ( 'recaptchalng' , 'en' ); 
      navigate ( 'http://www.google.com/recaptcha/api2/demo' );
       
    • Function run (timeout, callback) starts a call chain by returning an object of type CallChain .
      • timeout - time in seconds after which the next function in the chain will be called.
      • callback is a continuation function , the first function in the call chain.
      You can also call the run () function without parameters.
      Returned value: object of type CallChain

      Call examples:

      // 1. Go to Yandex, Google, Rambler // We sit for 5 seconds on each site 
      run ( 5 , function ( aWindow ) { 
      	navigate ( 'http://ya.ru' ); }). next ( 5 , function ( aWindow ) { 
      	navigate ( 'http://google.com' ); }). next ( 5 , function () { 
      	navigate ( 'http://rambler.ru' ); }). next ( 0 , function () { print ( 'Everyone !!!' ); });
        
        
        
        
      	
      
      
      
      // 2. Go to Yandex, Google, Rambler // We sit for 5 seconds on each site 
      run (). next ( 5 , function ( aWindow ) { 
      	navigate ( 'http://ya.ru' ); }). next ( 5 , function ( aWindow ) { 
      	navigate ( 'http://google.com' ); }). next ( 5 , function () { 
      	navigate ( 'http://rambler.ru' ); }). next ( 0 , function () { print ( 'Everyone !!!' ); });
        
        
        
        
      	
      
    • Functions random return a random integer in the specified range.
      random (min, max)
      random (max)
      • min (integer value) - the included lower limit of the returned random number.
      • max (integer value) - The excluded upper limit of the returned random number.
      Returned value: a random number from the range [min; max) .

      Call examples:

      // 1. Set the rnd variable to 2 or 3 
      vars . rnd = random ( 2 , 4 ); // 2. Set the rnd variable to 0, 1, 2 or 3 
      vars . rnd = random ( 4 ); 
      
    • Functions wheel scrolls the current page by the specified number of mouse wheel clicks, or to the specified element.
      wheel (count)
      wheel (element)
      • count (integer) - The number of clicks of the mouse wheel to scroll the page.
      • element - the element of the page that should become visible as a result of scrolling the page.
      Returned value: undefined .

      Call examples:

      // 1. Scrolling to the heading "operating principle" on the wikipedia page 
      navigate ( 'http://ru.wikipedia.org/wiki/Computer_Mouse' ); 
      wait (); // find the heading "how it works" var elem = document . querySelectorAll ( 'h2' ) [ 1 ]; // Scroll 
      wheel ( elem ); print ( 'page scrolled on' + window . scrollY + 'px' );
      
      
      
        
    • Functions move simulate the movement of the mouse pointer to the specified point or to the specified element.
      move (timeout, x, y)
      move (timeout, x, y, startX, startY)
      move (timeout, element)
      • timeout - time in milliseconds (1 msec. = 0.001 sec.) during which the mouse movement should be simulated.
        Valid values ​​for moving along coordinates are from 300 to 1500 milliseconds, for moving to an object - from 300 to 15000 milliseconds.
      • x - abscissa (coordinate along the X axis) of the point to which the mouse pointer should be moved (end point).
      • y - ordinate (Y-coordinate) of the point to which the mouse pointer should be moved (end point).
      • startX - abscissa (coordinate along the X axis) of the point from which the mouse pointer should be moved (starting point).
      • startY - ordinate (Y-coordinate) of the point from which the mouse pointer should be moved (starting point).
      • element - the page element to which the mouse should be moved. If the element is out of sight, then first the page is scrolled to the specified element, and then the movement is simulated.
      Returned value: undefined .

      Call examples:

      // 1. Move the mouse on the wikipedia page 
      activateTab ( 0 ); 
      navigate ( 'http://ru.wikipedia.org/wiki/Computer_Mouse' ); 
      wait ( 30,000 ); // Move the mouse to point (100, 100) in 1.5 seconds. 
      move ( 1500 , 100 , 100 ); 
      wait ( 5000 ); // Move the mouse to point (10, 10) // from point (200, 300) in 1 second. 
      move ( 1000 , 10 , 10 , 200 , 300 ); 
      wait ( 5000 ); var elem = document . querySelectorAll ( 'h2' ) [ 1 ]; // Move the mouse to the heading "operating principle" in 8 seconds. 
      move ( 8000 , elem );
        
      
          
      
      
    • Function setCookie (host, name, value, isSecure, httpOnly, path) sets the cookie for the specified host.
      • host is a string value containing the hostname.
      • name is a string value containing the name of the cookie.
      • value is a string value containing the value of the cookie.
      • isSecure (optional) - boolean value: true if the cookie should be set for the HTTPS protocol, false (default value) for the HTTP protocol. The default is false.
      • httpOnly (optional) - a boolean value that prevents JavaScript from receiving cookies. Value false , if the cookie can be obtained from JavaScript; true if receiving cookies from client-side JavaScript is prohibited. The default is false.
      • path (optional) - A string value identifying the subset of addresses for which the cookie value is valid. By default - the path to the root directory: /.
      Returned value: undefined .

      Call examples:

      // 1. Setting a cookie username to the site http://example.com 
      setCookie ( 'example.com' , 'username' , 'vasya' );  
      
      // 2. Setting username cookies for sites http://example.com and its subdomains // (for example, http://www.example.com, http://subdomain.example.com, etc.)   
      setCookie ( '.example.com' , 'username' , 'vasya' );
        
      
      // 3. Setting the cookie username to the site https://example.com 
      setCookie ( 'example.com' , 'username' , 'vasya' , true );   
    • Functions getCookie returns an array of Cookie objects containing the cookies for the specified host.
      getCookie (host)
      getCookie (host, name)
      • host - hostname.
      • name - the name of the cookie.
      Return value: an array of objects containing cookies for the specified host .

      Call examples:

      // 1. Getting cookies for forum.webisida.com 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 5000 ); var cookies = getCookie ( 'forum.webisida.com' ); print ( 'All cookies:' + cookies ); print ( 'Number of records:' + cookies . length ); if ( cookies . length > 0 ) { var cookie = cookies [ random ( cookies . length )]; print ( 'Random entry:' + cookie ); print ( 'Cookie name:' + cookie . name ); print ( 'Cookie value:' + cookie . value ); print ( 'Set for' + cookie . domain ); print ( 'Available for scripts:' + ( cookie . httpOnly ? 'no' : 'yes' )); print ( 'For a secure connection:' + ( cookie . secure ? 'no' : 'yes' )); print ( 'Destroyed when session ends:' + ( cookie . session ? 'yes' : 'no' )); }
      
       
       
        
      	
      	 
      	 
      	 
      	 
      	     
      	     
      	     
      
    • Function deleteCookie (host, name) deletes the cookie specified for the specified host.
      • host - hostname.
      • name (optional) - The name of the cookie to be deleted. If not specified, all cookies set for the host are deleted.
      Returned value: undefined .

      Call examples:

      // 1. Delete all forum cookies 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); print ( 'Before deletion:' + getCookie ( '.forum.webisida.com' )); 
      deleteCookie ( '.forum.webisida.com' ); print ( 'After removal:' + getCookie ( '.forum.webisida.com' ));
       
       
      
      // 2. Delete cookies by name 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); print ( 'Before deletion:' + getCookie ( '.forum.webisida.com' )); 
      deleteCookie ( '.forum.webisida.com' , 'phpbb3_rqxxd_sid' ); print ( 'After removal:' + getCookie ( '.forum.webisida.com' ));
        
       
    • Function generateReferrer (key, searchPhrase, siteUrl, pageIndex) generates a link similar to the address of one of the search engine results pages, which can later be used to replace HTTP_REFERER.
      • key is a string value, a keyword that matches a search engine or ad network. It can take the following values:
        • Google  - to generate a search referrer similar to Google's referrer.
        • Yandex  - to generate a search referrer similar to the referrer from Yandex.
        • Yahoo  - to generate a search referrer similar to the referrer from Yahoo.
        • Rambler  - to generate a search referrer similar to the referrer from the Rambler.com portal.
        • Bing  - to generate a search referrer similar to the Bing referrer.
        • MailRu  - to generate a search referrer similar to the referrer from the Mail.ru portal.
        • GoogleAdsense  - to generate a referrer similar to the Google Adsense referrer.
        • YandexDirect  - to generate a referrer similar to the referrer from Yandex.Direct.
      • searchPhrase - a word or phrase to generate a link.
      • siteUrl - a string value, a link to the site page that the generated referrer should point to.
      • pageIndex (optional) - the issue page number.
      Returned value: a string value containing a link .

      Call examples:

      // 1. Getting a referrer- like link from Google var referrer = generateReferrer ( 'Google' , 'generating search engine links' , ' http://webisida.com/?refid=403838viewtopic.php?f=21&t=95&start=30 ' ); // 2. Getting a Google link from the 2nd issue page var referrer = generateReferrer ( 'Google' , 'generating search engine links' , 'http://webisida.com/?refid=403838viewtopic.php?f=21&t=95&start=30' , 2 ); // 3. Getting a Yandex link for the page http://example.com/ var referrer = generateReferrer ( 'Yandex' , 'generating search engine links' , 'http://example.com/' );
        
      
         
      
        
      
      // example of using 
      vars . referrer = generateReferrer ( 'Yandex' , 'generating search engine links' , 'http://webisida.com/?refid=403838viewtopic.php?f=21&t=95&start=30' ); 
      navigate ( 'http://webisida.com/?refid=403838viewtopic.php?f=21&t=95&start=30' , vars . referrer );  
    • Function generateAccount (lang, sex, loginSize, passwordSize); generates an object containing information about the user.
      • lang - a string containing the alphabetical code of the user's language:
        • ru  - Russian
        • en  - English
      • sex (optional) - a string containing the user's gender (default is random):
        • w  - female
        • m  - male
      • loginSize (optional) - a number from 1 to 16 specifying the length of the login. The default is 4 - 6 characters. It is acceptable to pass 0 to select the default.
      • passwordSize (optional) - A number from 1 to 32 specifying the length of the password. The default is 8 - 10 characters. It is acceptable to pass 0 to select the default.
      Returned value: an object containing account data in the properties name (first name), surname (last name), patronymic (middle name or middle name), sex (gender), login (login) and password (password) .

      Call examples:

      // 1. Generation of a Russian-language account var account = generateAccount ( 'ru' ); print ( 'Name:' + account . name ); print ( 'Name:' + account . surname ); print ( 'Middle name:' + account . patronymic ); print ( 'Gender:' + account . sex ); print ( 'Login:' + account . login ); print ( 'Password:' + account . password );
      
       
       
       
       
       
       
      
      // 2. Generation of an English-language account var account = generateAccount ( 'en' ); print ( 'Name:' + account . name ); print ( 'Middle name:' + account . patronymic ); print ( 'Name:' + account . surname ); print ( 'Gender:' + account . sex ); print ( 'Login:' + account . login ); print ( 'Password:' + account . password );
      
       
       
       
       
       
       
      
      // 3. Generation of Russian female account var account = generateAccount ( 'ru' , 'w' ); print ( account . surname + '' + account . name + '' + account . patronymic );
       
          
      
      // 4. Generation of an English male account var account = generateAccount ( 'en' , 'm' ); print ( account . name + '' + account . patronymic + '' + account . surname );
       
          
    • Function generateLogin (length) generates a login of the specified length.
      • length (optional) - a positive number from 1 to 32 specifying the length of the login. The default is 4 - 6 characters.
      Returned value: string value containing login .

      Call examples:

      // 1. Generation of the login 
      vars . login = generateLogin (); print ( 'Login:' + vars . login );
       
    • Function generatePassword (length, alphabet) generates a random string of the specified length from the characters of the specified alphabet.
      • length (optional) - A positive number that specifies the length of the returned string. The default is 6 - 8 characters.
      • alphabet (optional) - a string containing the characters from which to generate the result. If this parameter is not specified, the string will be generated from characters ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .

        There are also a number of preset alphabets (i.e. you do not need to enter abc where ..., but instead you can enter only #r):

        • #n  - numbers from 0 to 9
        • #c  - Latin letters from a to z
        • #C  - Latin letters from A to Z
        • #r  - Russian letters from a to z
        • #R  - Russian letters from A to Z
        • #!  - special characters ~ `@ # $% ^ & * ();" ': /? <>., [] {} | \ -_ +! =
        • #s  - symbol ; (semicolon)
        • #d  - character : (colon)
        • #p  is the character ) (round closing parenthesis)
      Returned value: a string value of the specified length containing a random sequence of characters from the specified alphabet .

      Call examples:

      // 1. Generate a password with a length of 8 characters 
      vars . password = generatePassword ( 8 ); print ( 'Password:' + vars . password );
       
      
      // 2. Generate a password from 6-character digits 
      vars . password = generatePassword ( 6 , '#n' ); print ( 'Password:' + vars . password ); 
       
      
      // 3. Generate a string similar to the md5 hash 
      vars . md5 = generatePassword ( 32 , '#nabcdef' ) print ( 'MD5:' + vars . md5 ); 
       
    • Function wait pauses further script execution for the specified time.
      wait () - suspends the execution of the script, waiting for the completion of loading the HTML document into the active tab.
      wait (timeout)
      wait (minTimeout, maxTimeout)
      • timeout is an integer value, the time in milliseconds that defines the time to pause the script execution.
      • minTimeout - integer value, time in seconds, specifying the minimum value of the interval of time to suspend the script execution.
      • maxTimeout is an integer value, time in seconds, which defines the maximum value of the interval of time to suspend the script execution.
      Returned value: undefined .

      Call examples:

      // example of using print ( 'execution started' ); 
      wait ( 5000 ); print ( '5 seconds have passed' );
      
      
    • Function closeTab (tabIndex) closes the tab with index tabIndex . If there are tabs with an index greater than the tabIndex value , then after the tab is closed, their indices will be decreased by 1 (one).
      • tabIndex - an integer value, the number of the tab that you want to close. It can be 0, 1, 2, or 3.
      Returned value: undefined .

      Call examples:

      // 1. Loading the forum into tab # 1 and closing it after 10 seconds. 
      activateTab ( 1 ); 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); 
      closeTab ( 1 );
    • Function getActiveTabIndex () returns the sequential number of the active tab.

      Returned value: index of the active tab .

      Call examples:

      // 1. Getting the index of the tab after opening the link in a new tab 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); set ( 'popuptab' , 'next' ); 
      click ( 'a' , 'link' , 'viewforum' , - 1 , null , null , '_blank' ); 
      wait ( 10000 ); print ( 'Tab # is active' + getActiveTabIndex ());
             
       
    • Function getTabs () returns an array containing the contexts of all open tabs.

      Return Value: An array containing one top-level Window object for each tab .

      Call examples:

      // 1. Getting the addresses of the pages opened in the 
      navigate tabs ( 'http://forum.webisida.com' ); 
      activateTab ( 1 ); 
      navigate ( 'http://example.com' ); 
      wait ( 10000 ); var tabs = getTabs (); print ( 'Tabs open:' + tabs . length ); for ( var i = 0 ; i < tabs . length ; i ++) { print ( 'Tab' + i + ':' + tabs [ i ]. location . href ); }
      
       
        
      	   
      
    • Function findElements (tagName, seacrhkey, searchData, index) returns a DOM object or an array of DOM objects found according to the search key and data passed as arguments.
      • tagName - string value, name of the tag of the elements to be searched.
      • searchKey - search key, a string that can take one of the following values:
        • id  - search for elements by ID, then the data parameter is the required identifier or part of it, depending on the current type of search .
        • link  - search for links, images or frames by part of the address, then the data parameter is part of the address of the elements being searched for. All types of search are available .
        • text  - search for elements by the text contained inside, data  - part of the text. The search is done in the innerHTML property . All types of search are available .
        • name  - search for elements by their name, data  - part of the name of the searched elements. All types of search are available .
        • last  - search for the last element previously found by the text , check , sendEvents or click functions, the data parameter is ignored, but its input is required.
        • selector  - search for elements by CSS selector, the data parameter must be a valid CSS selector.
        • custom  - search for elements by attributes for which no separate commands have been created (for example, title, class, etc.), the data parameter is entered as a string in the format name = value , where name is the name of the attribute, value is part of the value of this parameter. All types of search are available .
      • index (optional) - an integer value, the number of the element among those found. If index is negative, the function will return a random element. If this argument was not passed, the function will return an array containing all elements found.
      Return value: the found DOM object, or null if the index argument was passed, or an array of found DOM objects if the index of the element to be searched for was not specified.

      Call examples:

      // 1. Getting links containing viewforum 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); var aLinks = findElements ( 'a' , 'link' , 'viewforum' ); print ( 'Links found:' + aLinks . length ); print ( 'Links: \ r \ n' + aLinks . join ( '\ r \ n' ));
        
       
       
      
      // 2. Getting a random link containing the viewforum 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); print ( 'Link:' + findElements ( 'a' , 'link' , 'viewforum' , - 1 ));
          
    • Functions getInternalLink fetches internal links from the page loaded in the active tab.
      getInternalLink (index) - returns an internal link or null if there are no internal links on the page or the link number passed in the index parameter is greater than the number of found links;
      getInternalLink (searchKey, searchData, index) - returns an internal link found according to the specified condition and ordinal number, or null if no links could be found or the link number passed in the index parameter is greater than the number of found links;
      getInternalLink (selectAll) - returns one or more internal links or null if there are no internal links on the page;
      getInternalLink (searchKey, data, selectAll) - returns one or more internal links found according to the specified condition and ordinal number, or null if the links could not be found or the link number passed in the index parameter is greater than the number of found links;
      • index (optional) - an integer value, the number of the link among the found, which you want to get. If index is negative, the function will return a random link.
      • selectAll (optional) - boolean value, true - to get an array containing all found links.
      • searchKey (optional) - search key, a string that can take one of the following values:
        • id  - search for a link by ID, then the data parameter is the required identifier or part of it, depending on the current type of search .
        • link  - search for a link by its part, then the data parameter is a part of the desired link. All types of search are available .
        • text  - search for a link by its text, data  - a part of the link text. The search is done in the innerHTML property . All types of search are available .
        • name  - search for a link by its name, data  - part of the link name. All types of search are available .
        • selector  - search for a link by a CSS selector, the data parameter must be a valid CSS selector.
        • custom  - search for a link by attributes for which no separate commands have been created (for example, title, class, etc.), the data parameter is entered as a string in the format name = value , where name is the name of the attribute, value is part of the value of this parameter. All types of search are available .
      Return value: link (element with A tag), an array of links, or null if there are no matching internal links on the page .

      Call examples:

      // 1. Getting an internal link from the forum 
      navigate ( 'http://forum.webisida.com' ); 
      wait ( 10000 ); print ( 'Random internal link:' + getInternalLink ()); print ( '-------------------------------' ); var aList = getInternalLink ( true ); print ( 'All internal links:' ); for ( var i = aList . length - 1 ; i > = 0 ; i -) { print ( aList [ i ]); } print ( '-------------------------------' ); print ( 'Random link containing the word viewtopic:' + getInternalLink ( 'link' , 'viewtopic' )); print ( '-------------------------------' ); print ( 'Number of links containing the word viewtopic:' + getInternalLink ( 'link' , 'viewtopic' , true ). length );
       
      
      
      
         
      	
      
      
        
      
         
    • Function encodeURIComponent (string) encodes a text string as a valid URI component ( more info ).
      • string - the string to be encoded.
      Returned value: string value containing the original text converted to URI-encoding .
    • Function decodeURIComponent (encodedURIString) gets the decoded version of the encoded URI component ( more info ).
      • encodedURIString The string to decode.
      Returned value: string value containing the decoded text .
    • Function encrypt (string, key) encrypts the string using the Rijndael-128 method with the key key .
      • string - the string to be encrypted.
      • key - string value, encryption key.
      Returned value: string value containing cipher text .
    • Function decrypt (encryptedString, key) decrypts the string encryptedString , encrypted function of the encrypt , using key key .
      • encryptedString is the string to be encrypted.
      • key - string value, encryption key.
      Return value: a string value containing the decrypted text, or null if the string could not be decrypted .
    • Function base64encode (value) returns a string containing Base64 encoded data for value .
      • value is the string to be encoded.
      Returned value: string value containing encoded text .
    • Function base64decode (value) decodes Base64 encoded data and returns a Unicode string (UTF-8) containing the original data.
      • value is the string to decode.
      Return value: string value containing decoded data, or null if the passed string contains invalid characters .
    • Function transliterate (string) transliterates a string containing Cyrillic characters into Latin characters.
      • string - the string to be converted.
      Returned value: a string containing the transliteration result .

      Call examples:

      // 1. Prints Ivan Ivanov print ( transliterate ( 'Ivan Ivanov' ));
      
    • Function escapeSelectorData (string) returns a string by adding an escape character (\) in front of the characters used in the description of CSS selectors.
      • string - the string to be converted.
      Returned value: string containing the result of the escaping .

      Call examples:

      // 1. Search for a link to the site iana.org 
      navigate ( 'http://example.com/' ); 
      wait (); var safeHost = escapeSelectorData ( 'www.iana.org' ); print ( safeHost ); print ( document . querySelector ( 'a [href * =' + safeHost + ']' ));
      
      
        
    • Function escapeRegex (string) returns string by adding an escape character (\) in front of the characters used in the regex description.
      • string - the string to be converted.
      Returned value: string containing the result of the escaping .
    • Function encodeToPunycode (domain) returns an ASCII string representing the IDNA encoded version of the Unicode string domain .
      • domain is the string to be converted to Punycode.
      Returned value: string containing the result of encoding into Punycode representation .

      Call examples:

      // 1. Converting the domain president.рф into punicode print ( encodeToPunycode ( 'president.рф' ));
      
    • Function getEmail receives from the specified mail server the contents of the letter, which contains the specified text, connecting to this mail server using the IMAP or POP3 protocol.
      getEmail (address, login, password, text)
      getEmail (address, login, password, params)
      • address - string value, mail server address.
        Recommended addresses for popular mail services:
        • imap.gmail.com - GMail (login - mail address); port 993 (SSL).
        • imap.yandex.ru - Yandex.Mail (login - mail address); ports 993 (SSL) or 143.
        • imap.mail.ru - Mail from Mail.Ru: mail.ru, inbox.ru, etc. (login - email address); ports 993 (SSL) or 143.
        • imap.rambler.ru , mail.rambler.ru - mail from Rambler: rambler.ru, lenta.ru, etc. (login - email address); ports 993 (SSL) or 143.

        Note : When connecting via IMAP, in most cases it takes less time to find the desired email.

      • login - string value, login from mailbox or full e-mail address.
      • password - string value, mailbox password.
      • text - the text that should be contained in the letter.
      • params is an object containing advanced settings for connecting to the mail server, as well as data for searching for a message.
        Format Object params default:
        var params = { 
        	text : '' , // text that should be contained in the letter from : undefined , // (optional) string, sender's address 
        	index : 0 , // (optional) integer, ordinal number of the message among those found 
        	drop : false , // (optional) true - delete the message after receiving, false - leave 
        	protocol : undefined , // (optional) a string defining the protocol: IMAP or POP3 
        	port : undefined , // (optional) an integer that defines the server port 
        	ssl : undefined // (optional) connection type: true - secure, false - not secure };     
        	            
        
      Returned value: an object containing information about the message or undefined if there is no message .
      Returned object format:
      • from - string value, sender's e-mail.
      • title - string value, subject of the letter.
      • text - a string value, the content of the letter (text, HTML, etc.).
      • contentType - string value, MIME-type of the message content.
      • links - an array of strings containing links from the email.
      • alternateViews is an array of objects, alternative forms of content presentation or undefined .
        The format of each object is:
        • title - string value, email subject, or empty string.
        • text - a string value, the content of the letter (text, HTML, etc.).
        • contentType is a string value, the MIME type of the content of this view.

      Call examples:

      // 1. Receiving an email sent from noreply@youtube.com // and containing the text 'Popular on YouTube' in the body or header var searchText = 'Popular on YouTube' ; var email = getEmail ( 'imap.gmail.com' , 'example@gmail.com' , 'password' , { 
      	text : searchText , from : 'noreply@youtube.com' }); if ( email ) { print ( 'Letter from' + email . from + '(' + email . contentType + '):' ) print ( email ); print ( '-----------------------------------------' ); print ( 'Links:' + email . links ); if ( email . links && email . links . length > 0 ) { print ( 'Link # 1:' + email . links [ 0 ]); } if ( email . alternateViews ) { print ( 'Number of alternate views:' + email . alternateViews . length ); for ( var i = 0 ; i < email . alternateViews . length ; i ++) { var view = email . alternateViews [ i ]; print ( '------------------------------------------' ); print ( 'View #' + i + '(' + view . contentType + '):' ); print ( view . text ); } } } else { print ( 'No email containing "' + searchText + '"' ); }
      
       
         
      	 
      
        
      	     
      	
      	
      	 
      	  
      		 
      	
      	 
      		 
      		   
      			
      			
      			    
      			
      		
      	
        
      	 
      
    • Functions pressKey emulates a key press in the active tab.
      pressKey (code)
      pressKey (code, isVirtualKey)
      • code is a positive integer value, character code, or virtual key code.
      • isVirtualKey - boolean value: true - the code parameter sets the VK_KEY code (virtual key code), false - the character code.
      Returned value: undefined .
    • Function pressDelKey (isDelKey) emulates pressing DEL or BACKSPACE.
      • isDelKey (optional) - boolean value: true for pressing DEL, false for pressing BACKSPACE. If the isDelKey parameter is absent or if the passed value is not logical, emulation of pressing which of these two keys will be performed is randomly selected.
      Returned value: undefined .
    • Function pressSelectAll () emulates the simultaneous pressing of the Ctrl and A keys, thereby forcing the program to select all the text on the page in the active tab. Returned value: undefined .
    • Function executeJavaScript (source, recursive, window) executes JavaScript in the context of the specified window or frame loaded in the active tab. If aAllFrames is true, then the code will be executed in all nested frames of the page once.
      • source is a string value, JavaScript code to be executed.
      • recursive (optional) - boolean value: true - to execute the code in the window context and in all nested frames, false - to execute the code only in the window context. The default is false .
      • window (optional) - an object of type Window, a global window or frame object in which to execute the script. If the parameter is not specified, the code will be executed in the currently selected frame of the active tab.
      Returned value: undefined .
      // 1. Execution of code in the active tab 
      executeJavaScript ( 'window.location = "http://ya.ru"' );
      
      // 2. Execution of code in a frame in the active tab 
      window . location = 'data: text / html, <html> <body> <iframe name = "myframe" src = "data: text / html, wiki" width = "300" height = "300"> </iframe> </ body> </html> ' ; 
      wait ( 5000 ); 
      setFrame ( 'name = myframe' ); 
      executeJavaScript ( 'window.location.href = "http://wikipedia.org"' ); 
      
      
      // 3. Execution of code in a frame in the active tab 
      window . location = 'data: text / html, <html> <body> <iframe src = "data: text / html, wiki" width = "300" height = "300"> </iframe> </body> </ html > ' ; 
      wait ( 5000 ); var frame = window . frames [ 0 ]; 
      executeJavaScript ( 'window.location.href = "http://wikipedia.org"' , false , frame ); 
       
      
      // 4. Execution of code in all frames 
      window . location = 'data: text / html, <html> <body> <iframe src = "data: text / html, <html> <body> wiki </body> </html>" width = "300" height = " 300 "> </iframe> </body> </html> ' ; 
      wait ( 5000 ); var script = 'window.document.body.style.background = "#" + (Math.random () * 0xFFFFFF << 0) .toString (16)' ; 
      executeJavaScript ( script , true ); 
        
    • Function setUserAgent (userAgent) changes the User-Agent header, which will be sent to the server in subsequent requests for site pages. Analogue of the Change UserAgent command .

      Note 1 . The program guarantees correct imitation of browsers only for predefined agents. In the case of an arbitrary agent, correct imitation is not guaranteed, and therefore this function should be called only when absolutely necessary.

      Note 2 . All cookies are cleared when the agent is changed.

      • userAgent - a string that must be substituted in the User-Agent header, either null or undefined to install a predefined agent selected by the program by default. It is also permissible to use the URL of an external file with a list of UserAgents. The content of the file must be in ASCII / UTF-8 encoding with a mime-type compatible with text / plain (no compression). Each UserAgent entry must start on a new line. The file size must be no more than 512KB.

        Note . The file containing the list of agents is loaded asynchronously for 5 seconds. Therefore, when using an external file, it is required to wait at least 6 seconds after calling the setUserAgent function . If the file is not downloaded successfully within 5 seconds, the agent installation will be ignored.

      Returned value: undefined .
    • Function getDocumentFileSize (window) returns the number of bytes transmitted by the server when loading a document open in the window or frame passed in the window parameter . This number is the same as the Content-Length HTTP header, if present in the server response.
      • window is a Window object.
      Returned value: a number equal to the number of bytes transferred from the server side, or -1 if information about the loaded document cannot be obtained.


    Working with variables

    Presentation mode allows you to create an unlimited number of variables using the standard var declaration. However, variables declared in this way will not appear in the Variables tab in the test program. In order for a variable to be visible on the "Variables" tab, it must be defined as a property of the vars object . The vars object is available in both the testing program and the surfing program.

    Examples:

    // setting the string variable login 
    vars . login = 'mylogin' ; // setting the vIndex variable 
    vars . vIndex = 5 ; // setting the vRect variable 
    vars . vRect = { x : 100 , y : 120 , width : 300 , height : 200 }; // set variable vIndex2 
    vars [ 'vIndex2' ] = 5 ; // get the variable print ( 'width:' + vars . vRect . width ); 
     
           
      
    
     


    Working with jQuery

    • The jQueryDef (window) function returns the jQuery function defined in the context of window . If the jQuery library has not been loaded into the window context , then jQuery 2.1.1 is automatically loaded into it.
      • window is the context for which to get the jQuery object.

      Return value: jQuery object (function)

      Call examples:

      // 1. Search in Yandex with jQuery 
      navigate ( 'http://ya.ru' ); 
      wait ( 10000 ); var $ = jQueryDef ( window ); 
      $ ( '#text' ). val ( 'search phrase' ); 
      wait ( 5000 ); 
      click ( 'input' , 'custom' , 'type = submit' ); 
      wait ( 10000 ); // we need to call jQueryDef again here, because new page loaded 
      $ = jQueryDef ( window ); // text 2 of the log 
      output link vars . serp2_title = $ ( '.b-serp-item__title-link' ). eq ( 1 ). text () print ( 'Second link in the output:' + vars . serp2_title );
        
      
      
       

    Networking

    • The resolveAddress (hostname) function returns a list of IP addresses for the specified host.
      • hostname is a string containing the hostname.

      Returned value: string array containing IP addresses.

      Call examples:

      // 1. Getting Yandex IP addresses var ips = resolveAddress ( 'yandex.ru' ); for ( var i = ips . length - 1 ; i > = 0 ; i -) { print ( ips [ i ]); }
      
         
      	
      
    • An object http provides synchronous and asynchronous functions to communicate with server-side scripts. Asynchronous functions are as close as possible to similar functions from the jQuery library.
      • The http.postSync (url, data, dataType) function makes a synchronous POST request to the specified URL and waits for a response from it.
        • url is a string containing the URL to which the request should be sent.
        • data (optional) - An object containing data to be passed to the server when making a request.
        • dataType (optional) - the data type expected from the server: plain, html, json, xml, etc.

        Return value: the transformed response from the given URL - a string or object , depending on the value of the dataType parameter or the Content-Type header in the response, or undefined if an error occurred.

        Call examples:

        // 1. Sending a notification to the script var result = http . postSync ( 'http://example.com' , { name : 'Bob' }); print ( 'POST completed' + ( result ? '' : 'not' ) + 'successful.' );
           
                
      • The http.getSync (url, data, dataType) function makes a synchronous GET request to the given URL and waits for a response from it.
        • url is a string containing the URL to which the request should be sent.
        • data (optional) - An object containing data to be passed to the server when making a request.
        • dataType (optional) - the data type expected from the server: plain, html, json, xml, etc.

        Return value: the transformed response from the given URL - a string or object , depending on the value of the dataType parameter or the Content-Type header in the response, or undefined if an error occurred.

        Call examples:

        // 1. Getting the content of the page http://example.com var url = 'http://example.com' ; var result = http . getSync ( url ); print ( 'Reply from' + url + ':' + result );
         
        
           
        
        // 2. Getting the content of the page http://example.com?name=Bob var url = 'http://example.com' ; var result = http . getSync ( url , { name : 'Bob' }); print ( 'Reply from' + url + ':' + result );
         
           
            
      • The http.getJSONSync (url, data) function makes a synchronous GET request to a given URL that responds with JSON data, downloads the response, and converts it to a JavaScript object.
        • url is a string containing the URL of the script that returns JSON data in response.
        • data (optional) - An object containing data to be passed to the server when making a request.

        Return value: an object obtained by transforming the response from the given URL, or undefined if an error occurred.

        Call examples:

        // 1. Getting data from a script on the server var result = http . getJSONSync ( 'http://example.com' ); if ( result && result . name ) { print ( 'name:' + result . name ); } else { print ( 'An error occurred while executing the request!' ); }
        
         
        	 
          
        	
        
        
        // Sample PHP script responding at http://example.com <? php
        
        header ( 'Content-Type: application / json; charset = utf-8' ); 
        echo json_encode ( array ( 'ok' => true , 'name' => 'Vasya' ));     
      • The http.postJSONSync (url, data) function makes a synchronous POST request to a given URL that responds with JSON data, downloads the response, and converts it to a JavaScript object.
        • url is a string containing the URL of the script that returns JSON data in response.
        • data (optional) - A JSON object or string containing data to be passed to the server when making a request. The data is passed to the server as content with the MIME type application / json.

        Return value: an object obtained by transforming the response from the given URL, or undefined if an error occurred.

        Call examples:

        // 1. Sending and receiving data in JSON format var result = http . postJSONSync ( 'http://example.com' , { a : 1 , b : "qwerty" }); if ( result && result . name ) { print ( 'name:' + result . name ); } else { print ( 'An error occurred while executing the request!' ); }
            
         
        	 
          
        	
        
        
        // Sample PHP script responding at http://example.com <? php
        
        header ( 'Content-Type: application / json; charset = utf-8' ); 
        echo json_encode ( array ( 'ok' => true , 'name' => 'Vasya' ));     
      • The http.ajax (url, settings) or http.ajax (settings) function makes an asynchronous HTTP (Ajax) request to the specified URL.
        • url is a string containing the URL to which the request should be sent.
        • settings - an object containing settings and data for the request.

        Return value: XHR object

        Call examples:

        // 1. Sending a notification to the 
        http script . ajax ( 'http://example.com?notify' , { type : 'GET' }) . done ( function ( data ) { print ( 'Request completed successfully!' ); }). fail ( function () { print ( 'An error occurred while executing the request!' ); });   
          
        	
         
        	
        
      • The http.post (url, data, successCallback, dataType) function performs an asynchronous POST to the given URL.
        • url is a string containing the URL to which the request should be sent.
        • data (optional) - An object containing data to be passed to the server when making a request.
        • successCallback (optional) - a function to be called when the request is successful (see done ).
        • dataType (optional) - the data type expected from the server: plain, html, json, xml, etc.

        Return value: XHR object

        Call examples:

        // 1. Sending a notification to the 
        http script . post ( 'http://example.com' , { name : 'Bob' }, function ( data ) { print ( 'POST request succeeded!' ); }). fail ( function () { print ( 'An error occurred while executing the request!' ); });      
        	
         
        	
        
      • Function http.get (url, successCallback, dataType) - performs an asynchronous GET to the given URL.
        • url is a string containing the URL to which the request should be sent.
        • successCallback (optional) - a function to be called when the request is successful (see done ).
        • dataType (optional) - the data type expected from the server: plain, html, json, xml, etc.

        Return value: XHR object

        Call examples:

        // 1. Sending a notification to the 
        http script . get ( 'http://example.com' , function ( data ) { print ( 'GET request succeeded!' ); print ( data ); }). fail ( function () { print ( 'An error occurred while executing the request!' ); });   
        	
        	
         
        	
        
      • The http.getJSON (url, data, successCallback) or http.getJSON (url, successCallback) function makes an asynchronous GET request to the specified URL that responds with JSON data, downloads the response, and converts the response to a JavaScript object.
        • url is a string containing the URL of the script that returns JSON data in response.
        • data (optional) - An object containing data to be passed to the server when making a request.
        • successCallback (optional) - a function to be called when the request is successful (see done ).

        Return value: XHR object

        Call examples:

        // 1. Getting data from a script on the 
        http server . getJSON ( 'http://example.com' , function ( data ) { if ( data && data . ok ) { print ( 'name:' + data . name ); } }). fail ( function () { print ( 'An error occurred while executing the request!' ); });   
        	 
        		 
        	
         
        	
        
        
        // Sample PHP script responding at http://example.com <? php
        
        header ( 'Content-Type: application / json; charset = utf-8' ); 
        echo json_encode ( array ( 'ok' => true , 'name' => 'Vasya' ));     

      An object XHR contains the status of the request. For each returned XHR object, an optional completion handler can be installed:
      • The done (successCallback) function sets the function successCallback (data, textStatus, clrXHR) {} handler , which will be called upon successful completion of the request.
        • data - data received from the server as a result of the request.
        • textStatus is a string containing the status of the request as a string.
        • clrXHR - The CLRWebRequest object instance that made the request.

        Return value: XHR object

        An example of installing a handler:

        // 1. Installing the 
        http handler . get ( 'http://example.com' ) . done ( function () { print ( 'Request completed successfully!' ); });
         
        	
        
      • The fail (errorCallback) function - sets the function errorCallback (http, textStatus, exception) {} handler , which will be called if an error occurs while executing the request.
        • data - data received from the server as a result of the request.
        • textStatus is a string containing the status of the request as a string.
        • exception is an object providing information about the error.

        Return value: XHR object

        An example of installing a handler:

        // 1. Installing the 
        http handler . get ( 'http://example.com' ) . fail ( function () { print ( 'An error occurred while executing the request!' ); });
         
        	
        
      • The always (callback) function sets up a function callback () {} handler that will be called when the request completes, regardless of success.

        Return value: XHR object

        An example of installing a handler:

        // 1. Installing the 
        http handler . get ( 'http://example.com' ) . always ( function () { print ( 'Query completed!' ); });
         
        	
        


    Adding a dynamic presentation to surfing

    To add a dynamic presentation to surfing, insert the address of the dynamic presentation script instead of the site address and in the settings check the options "Show site only in the program" and "Dynamic presentation".



    Testing a dynamic presentation

    Presentation mode offers you very flexible customization of how your sites are displayed. It is, however, a very complex tool, so for best results we recommend that you test the settings you have made. For you, we have prepared a special program that will show you the entire presentation process exactly the way visitors will see it.
    • Download the offline installer and install the bundle it provides.
    • Run the SecureSurf.Tester.exe program. The program needs network access to receive presentation data.
    • Click on the picture Presentation testin the list of sites for the site you need. (This picture appears only when Presentation Mode is on.)
    • Copy the code obtained on the page into the program text window (near which it says "Enter the code to start the test") and click the "Start" button.

    For testing while writing the script, you can insert the address of your dynamic presentation script instead of the page address in the configuration mode in the testing program and select the "dynamic presentation" type from the list.



    Sample dynamic presentation script

    You can download a sample dynamic presentation script from here .



    Video card earnings
     
     
    You don't have any notifications.

    Original text