how to show/hide touchbar button via apple script

for example i have something like

tell application "BetterTouchTool"
    if tabUrl starts with "https://www.youtube.com" then
        update_trigger "D529D06E-A207-4A4D-BDDE-161BF181E194" json "{\"BTTEnabled2\" : 1}"
    else
        update_trigger "D529D06E-A207-4A4D-BDDE-161BF181E194" json "{\"BTTEnabled2\" : 0}"
    end if
end tell

but sadly once the button is hidden/disabled, i cant enable it back, so does anyone knows a solution for that ?

u can either use

  1. on the button it self

    update_trigger "3F50F20A-C5C4-43EC-81B8-EF1FDFA5378C" json "{\"BTTTriggerConfig\": {\"BTTTouchBarButtonWidth\" : 0, \"BTTTouchBarButtonUseFixedWidth\": 1}}"
    
  2. create a script to enable/disable the actual button ex.

    // ...
    
    tell application "BetterTouchTool"
        if condition then
            update_trigger "9E4ED37B-AB71-43A9-B642-E6248D7340FF" json "{\"BTTEnabled2\": 1}"
        else
            update_trigger "9E4ED37B-AB71-43A9-B642-E6248D7340FF" json "{\"BTTEnabled2\": 0}"
        end if
    end tell