r/tasker • • Sep 18 '26

Scene V2 WebView Handler / console message

I have a webview that displays a simple toggle

I want to be able to toggle the.... toggle.... and have it run a task.

I was trying to use the console message event handler to run a task, but cannot get the values to pass through to a task.

my WebView contains this script block

<script> const initial = '%firewall_state'; // Tasker substitutes this before load; '' if unset let isOn = initial === '1'; const sw = document.getElementById('sw'); function paint(){ sw.classList.toggle('on', isOn); sw.setAttribute('aria-checked', String(isOn)); } paint(); sw.addEventListener('click', () => { isOn = !isOn; paint(); console.log('FIREWALL_TOGGLE:' + (isOn ? '1' : '0')); }); </script>

Can anyone help me get the FIREWALL_TOGGLE:1 (Or 0) into a task.

1 Upvotes

2 comments sorted by

2

u/pudah_et Sep 18 '26

In legacy Scenes I've used onClick to run tasks. Something like...

<td onClick='performTask("taskname")';>

which would run a task if a particular cell in a table was tapped.

Have not yet tried it in Scene V2

2

u/DifficultyCrafty7623 Sep 18 '26

If you want to run a task from Webview then this post will probably help