Problems Opening Reddit URLs in Safari Using AppleScript

@Brian_Martin, since your question/problem is a different issue from the Topic in which you posted, I have moved your post to a new Topic so that you can attract better help and others can find it easier.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, to your problem:

Your script has two statements that won't even compile.
I've identified them by two "##" at the beginning of the statement.

set _win to false
tell application "Safari"
  set {idList, urlList} to {id, URL} of every tab of every window
end tell
set AppleScript's text item delimiters to return
if (urlList as text) contains "https://www.reddit.com" = true then
  set theWin to 1
  repeat with i in urlList
    set theTab to 1
    repeat with n in i
      if n starts with "https://www.reddit.com" then
        set {_win, _tab} to {theWin, theTab}
      end if
      set theTab to theTab + 1
    end repeat
    set theWin to theWin + 1
  end repeat
end if
if _win ≠ false then
  tell application "System Events"
    if quit delay ≠ 0 then set quit delay to 0
    tell process "Safari"
      perform action "AXRaise" of window _win
    end tell
  end tell
  tell application "Safari"
    
    ##  tell front window to set active tab index to _tab
    
  end tell
else
  tell application "Safari"
    set newWin to make new window
    
    ##  tell newWin to set URL of active tab to "https://www.reddit.com"
    
  end tell
end if

It appears that you are trying to use Google Chrome AppleScript commands with Safari, which do not work. It would be best for your to open the Safari Scripting Dictionary in Script Editor, or better, in Script Debugger 7.

When I have more time, I'll come back to offer some specific changes/solutions. In the meantime there are a number of Forum members who are experienced in AppleScript, and any of them may jump in with suggestions.

Also, in the future, please post your scripts using the Forum Code Block.