To make fewer moving parts, you may create eg. "bootstrap.html" with iframe pointing to snap.html directory.
The project XML is loaded with standard inter-frame comm api.
<!DOCTYPE html>
<html>
<head>
<script>
window.addEventListener(
"load"
, function(){
let project ="escape project XML here at https://jsfiddle.net/y0wsp57n/4/ ";
document.getElementById("snap").contentWindow.postMessage( { selector :"loadProjectXML", params :[ unescape( project)]}, "*");
}
);
</script>
</head>
<body>
<iframe id="snap" src="snap.html" style="position:absolute; top:0; left:0; width:100%; height:100%; border:0"></iframe>
</body>
</html>
This way, you can create multiple bootstrap html with different projects, using a single instance.
Strings embedded in HTML should be encoded
If you want/can lift the restrictions with eg.
"path_to_chrome\chrome.exe" --user-data-dir=/tmp/unsafe --allow-file-access-from-files file:///d:/work/snapmaster.v8/bootstrap.html
it can be further streamlined to
<!DOCTYPE html>
<html>
<head>
<script>
window.addEventListener(
"load"
, function(){
let project = document.getElementById("project").contentDocument.documentElement.outerHTML;
document.getElementById("snap").contentWindow.postMessage( { selector :"loadProjectXML", params :[ project]}, "*");
}
);
</script>
</head>
<body>
<iframe id="project" src="Examples/animal-game.xml" hidden></iframe>
<iframe id="snap" src="snap.html" style="position:absolute; top:0; left:0; width:100%; height:100%; border:0"></iframe>
</body>
</html>