Can't execute JS in chrome or Safari

Describe the bug
Wanted to create a Touch Bar button that would execute JS in browser but can not get it working. I add new button and select "Run Apple Script" (have tried with both asyc and background) and use this code for Safari

tell application "Safari"
	open location ""
	do JavaScript "alert('lala')" in document 1
end tell

and this for Chrome

tell application "Google Chrome"
	open location ""
	execute javascript "alert('lala');"
end tell

However nothing happens. Have played around and tried every possible code snippet on the web but can not get to execute any JS.

Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):
Touch Bar


Device information:

  • Type of Mac: MacBook Pro (13-inch, 2016, Four Thunderbolt 3 Ports), 2,9 GHz Intel Core i5, 8 GB 2133 MHz LPDDR3
  • macOS version: 10.12.6 (16G1510)
  • BetterTouchTool version: 2.645

In Google Chrome you may first need to enable this:

Afterwards this works fine for me:

tell application "Google Chrome"
	execute active tab of front window javascript "alert('test')"
end tell

Thank you, it is working now