I've rewritten the script to meet your needs and tested it with my own contexts. I've gathered your @ contexts and actual contexts into lists at the beginning of the script with a third list that categorises them into top-level, sub-level and sub-sub-level contexts.
The script then gathers the actual contexts from OmniFocus and then tests the ShortContextList for the selected action in OmniFocus to determine the correct context to apply to it.
Code:
set TopContext to "URLs"
set SubSubContext1 to "Download"
set SubSubContext2 to "Watch"
set ShortContextList to {"@add2sys", "@blog", "@bm", "@dl-app", "@job", "@mail", "@notepad", "@optimism", "@parse", "@queue", "@read", "@rss", "@thinkabout", "@watch-long", "@watch-short"}
set FullContextList to {"Add to System", "Blog About", "Bookmark", "App", "Job Listing", "Mail to Someone", "Project Notepad", "Optimism", "Parse", "Queue (Add To)", "Read This", "RSS (Add To)", "Think About", "Long", "Short"}
set ContextTypeList to {"SubContext", "SubContext", "SubContext", "SubSubContext1", "SubContext", "SubContext", "SubContext", "SubContext", "SubContext", "SubContext", "SubContext", "SubContext", "SubContext", "SubSubContext2", "SubSubContext2"}
set OmniFocusContexts to {}
set i to 1
tell application "OmniFocus"
tell front document
-- Capture the top-level, sub-level and sub-sub-level contexts
repeat with theContext in FullContextList
if item i of ContextTypeList = "TopContext" then
set the end of OmniFocusContexts to context TopContext
else if item i of ContextTypeList = "SubContext" then
set the end of OmniFocusContexts to context theContext of context TopContext
else if item i of ContextTypeList = "SubSubContext1" then
set the end of OmniFocusContexts to context theContext of context SubSubContext1 of context TopContext
else if item i of ContextTypeList = "SubSubContext2" then
set the end of OmniFocusContexts to context theContext of context SubSubContext2 of context TopContext
end if
set i to i + 1
end repeat
tell content of document window 1
set theSelectedItems to value of every selected tree
if ((count of theSelectedItems) < 1) then
display alert "You must first select a single task." message "Select a single task before running this script." as warning
return
end if
if ((count of theSelectedItems) > 1) then
display alert "You must select only one task." message "Select a single task before running this script." as warning
return
end if
set i to 1
-- Test for the short context and apply the correct context to the action
repeat with anItem in theSelectedItems
repeat with AShortContext in ShortContextList
if the name of anItem contains AShortContext then set context of anItem to item i of OmniFocusContexts
set i to i + 1
end repeat
end repeat
end tell
tell document window 1
set selected view mode identifier to "project"
tell sidebar to select inbox
end tell
end tell
end tell