Automate Browser Extensions
abstract This section describes how to automate browser extensions using Sahi.
- Download the extension's source in a directory. One way to download the source is using the Chrome extension source viewer extension. After downloading the zip file, extract it to a new folder.
<script src="https://sahi.example.com/_s_/sprc/concat.js,common.js,listen.js,actions.js,touch.js,sfl.js,language_pack.js" id="_sahi_concat" ></script> <script src="https://sahi.example.com/_s_/dyn/SessionState_config/sahiconfig.js"></script>
- Open the
manifest.jsonfile of the extension. Add the following line to the end before the closing curly braces '}'.
,"content_security_policy": "script-src 'self' https://sahi.example.com 'unsafe-eval'; object-src 'self'"
- Start Sahi. Launch Chrome from Sahi Dashboard. Navigate to chrome://extensions/.
- Enable Developer mode. Click on the
Load unpackedbutton and select the extension source directory (downloaded and modified).
- Click on details for the newly added extension. Allow in incognito.
- Navigate to chrome://extensions/shortcuts. Set a shortcut to activate the extension e.g 'Ctrl + Q'. This shortcut key can be triggered on the HTML body using _keyPress API in Sahi script.
_keyPress(document.body, 'Q', "CTRL");
- Exit from Chrome and close Sahi.
- We have now added this extension to one Chrome profile folder in Sahi at
sahi_pro\userdata\browser\chrome\profiles\sahi0. We need to add these changes to other profile folders.
sahi0directory, delete all the other directories like
sahi2, and so on.
- Then recreate Chrome profile folders like
sahi2, and so on by duplicating the contents of the
warning This feature is experimental in nature. Above steps may not work for every browser extension.