Advanced Condition, Toggle Mute when browser is on Teams meeting.

What is the best way to import an advanced condition that is:

"While in teems meeting"
Like checking if mute button exists.

ChatGPT says to create a dynamic variable

(async () => {
    let value = "0";

    try {
        const result = await runAppleScript(`
            if application "Google Chrome" is not running then return "0"

            tell application "Google Chrome"
                if (count of windows) = 0 then return "0"

                return execute active tab of front window javascript "
                    (() => {
                        if (location.hostname !== 'teams.cloud.microsoft.mcas.ms')
                            return '0';

                        const b = document.getElementById('microphone-button');
                        return b && !b.disabled && b.getClientRects().length > 0
                            ? '1' : '0';
                    })()
                "
            end tell
        `);

        value = String(result).trim() === "1" ? "1" : "0";
    } catch (_) {
        value = "0";
    }

    returnVariableValue(value);
})();

is this a good way ?

Your approach should work, but you have to turn on Chrome's View > Developer > "Allow JavaScript from Apple Events". Also, that hostname check only matches the MCAS proxy URL, so plain teams.microsoft.com won't trigger it. Honestly it might be simpler to skip the "in meeting" check: a system-wide mic mute works in any app or tab, so it doesn't matter where Teams is running. I made a free open-source menu bar app that does exactly that (one hotkey + on-screen indicator): lockmic.com. Disclosure: I'm the dev.