Error in my script

Hi,

I can’t fix the error of this script at the line:
tell window 1 to make new tab with properties {URL:theUrl}

tell application "Google Chrome"
activate
set theUrl to (make new window)
set the URL of tab 1 of theUrl to "https://www.youtube.com"
set bounds of theUrl to {1, 1, 1440, 1440}
if (count every window) = 0 then
	make new window
end if

set found to false
set theTabIndex to -1
repeat with theWindow in every window
	set theTabIndex to 0
	repeat with theTab in every tab of theWindow
		set theTabIndex to theTabIndex + 1
		if theTab's URL = theUrl then
			set found to true
			exit repeat
		end if
	end repeat
	
	if found then
		exit repeat
	end if
end repeat

    if found then
	 tell theTab to reload
	 set theWindow's active tab index to theTabIndex
	 set index of theWindow to 1
    else
	 tell window 1 to make new tab with properties {URL:theUrl}
    end if
end tell

can you correct it?

thanks

# Make variable theURL an actual URL instead of a window reference.
set theURL to "https://www.youtube.com"

tell application "Google Chrome"
   
   set newWindow to (make new window)
   set the URL of tab 1 of newWindow to theURL
   set bounds of newWindow to {1, 23, 1440, 900}
   
   # This will never be true due to the previous code block.
   # if (count every window) = 0 then
   # 	make new window
   # end if
   
   set found to false
   set theTabIndex to -1
   
   repeat with theWindow in every window
      set theTabIndex to 0
      repeat with theTab in every tab of theWindow
         set theTabIndex to theTabIndex + 1
         if theTab's URL = theURL then
            set found to true
            exit repeat
         end if
      end repeat
      
      if found then
         exit repeat
      end if
   end repeat
   
   if found then
      tell theTab to reload
      set theWindow's active tab index to theTabIndex
      set index of theWindow to 1
   else
      tell window 1
         make new tab with properties {URL:theURL}
      end tell
   end if
   
end tell
1 Like