AutoControl Control your browser your way Forum               Install now from theChrome Web Store


Includes a local or remote Javascript or CSS file in the page the function is called from.
Script files are executed in the global scope of the script context, not the page context.
To execute code in the page context, you must use ACtl.runInPageCtx. To include code in the script's local scope, you may use ACtl.import or the example shown below.
ACtl.include(fileLocation[,fileType][,again]) fileLocation Type: string Either a URL, data URI, local path or UNC path pointing to a Javascript file or CSS file. It can be relative to the script's location (if there is one). It can also contain placeholders such as <desktop>, <documents> and others. fileType Type: string Default: undefined Either the string 'js' or 'css'. If omitted, the file type will be determined automatically from its name extension or MIME type. It can be omitted even if again is specified. again Type: boolean Default: false If false, the file will be included only if it hasn't been included in the script context already (by any AutoControl script).
If true, the file will always be included.
Returns Type: Promise Resolves to: boolean Returns immediately. The Promise will resolve with true once the file has been included and executed or false if the file wasn't included at all (according to the again argument). Throws Type: string Error description if fileLocation cannot be accessed.


Load jQuery in the script context. This will make the library available to all AutoControl scripts in the page, but will be independent from the jQuery version loaded by the page itself.

		await ACtl.include('') ;
		//Now jQuery is loaded in the page. Any AutoControl script can use it
		$('img').css({width: 'auto', height: 'auto'}) ;
	}catch( error ){
		alert( "Unable to load jQuery. The error was: " + error ) ;

To include code in the script's local scope, we can use ACtl.getFile plus eval().

		//Get the file content as text and eval it in this scope
		eval( await ACtl.getFile('C:/Projects/Time Machine/functions.js') ) ;
		//This function was defined by the file above
		//It's only visible by the current script
		timeJumpTo('yesterday') ;
	}catch( error ){
		alert( "Unable to load functions.js. The error was: " + error ) ;

We can apply a local CSS file to a webpage easily.

	//This script must run in the page we want to alter
	ACtl.include('<desktop>/myCustomStyles.css') ;
Scripting API Script Isolation Asynchronicity Backgrnd Scripts GUI vs API ACtl.include ACtl.import ACtl.getFile ACtl.saveFile ACtl.saveURL ACtl.openURL ACtl.closeTab ACtl.runInTab ACtl.runInFrames ACtl.runInPageCtx ACtl.getTabInfo ACtl.getTabIds ACtl.TAB_ID ACtl.setTabState ACtl.captureTab ACtl.execAction ACtl.runCommand ACtl.getClipboard ACtl.setClipboard ACtl.expand ACtl.switchState ACtl.var ACtl.pubVar ACtl.on ACtl.sleep ACtl.STOP_CHAIN ACtl.STOP_FULL_SEQ