Script to Automatically Connect to Sidecar in Big Sur

I was using the following AppleScript on my iMac to automatically connect to an iPad using Sidecar.

set deviceName to "Michael’s iPad Pro 12.9"

tell application "System Events"
	tell process "SystemUIServer"
		click (menu bar item 1 of menu bar 1 whose description contains "Displays")
		set displaymenu to menu 1 of result
		if ((menu item 1 where its name starts with deviceName) of displaymenu) exists then
			-- Not connected, so click the name of the device to connect
			click ((menu item 1 where its name starts with deviceName) of displaymenu)
		else
			-- Connected, so click "Disconnect" to disconnect
			click ((menu item 1 where its name starts with "Disconnect") of displaymenu)
		end if
	end tell
end tell

However, this no longer works on Big Sur (macOS 11.0.1). Can anyone tell me how I can modify this script so it will work again?

Model: iMac Pro
AppleScript: 2.7
Browser: Safari 537.36
Operating System: macOS 10.14

Toggle Sidecar on/off
(You can change the iPadName to specific name)

Note: Displays must be visible in the menu bar


set iPadName to "iPad"

tell application "System Events"
	tell application process "ControlCenter"
		repeat with tElement in menu bar items of menu bar 1
			if (exists attribute "AXTitle" of tElement) then
				if value of attribute "AXTitle" of tElement contains "Display" then
					set theBar to tElement
					tell theBar
						click
					end tell
					set tElements to entire contents of window 1
					repeat with i from 1 to count of tElements
						set tElement to item i of tElements
						if (title of tElement contains iPadName) then
							tell tElement
								click
							end tell
							exit repeat
						end if
					end repeat
					tell theBar
						click
					end tell
					exit repeat
				end if
			end if
		end repeat
	end tell
end tell

Thanks so much. This works flawlessly!