Hi viking,
Well, I was waiting for you to once again answer your own question after a little more trial and error, but I see it's been awhile so I'll go ahead and tell you.
What you have in this situation is a string embedded within a string embedded within a string. The outermost string is the Javascript string that is assigned to the MyMacro variable:
MyMacro += " ... ";
Obviously, these quotes do not need to be escaped because they denote the outermost string.
The first embedded string defines the contents of the EVAL command, and therefore the quotes for the EVAL command need to be escaped as you have already correctly done:
MyMacro += "SET !VAR1 EVAL(
\"var x= ...
\")"
The second embedded string is contained within the EVAL command string where you assign the value of {{!EXTRACT}} to a Javascript variable. In order to use double-quotes correctly around this string, you need an additional level of nested escape characters:
MyMacro += "SET !VAR1 EVAL(\"var x=
\\\"{{!EXTRACT}}
\\\"; x;\")"+ jsLF;
Observe in this case that we're escaping the escape character itself, so that the end result that will end up being sent to the macro player is:
SET !VAR1 EVAL("var x=\"{{!EXTRACT}}\"; x;")
Of course using a set of single quotes avoids this extra level redirection and may even look "cleaner," but at least now your curiosity should be satisfied.