forked from Stock-control-supervisors/public-docs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.min.js.download
1 lines (1 loc) · 2.55 KB
/
main.min.js.download
1
window.$eval=eval;var sizeChangeReportingIntervalId=0;function loadMessage(){var decodedOptions=getDecodedQueryParam('options');if(!decodedOptions)return;try {var options=JSON.parse(decodedOptions);if(options.properties?.gist?.encodedMessageHtml){var encodedMessageHtml=options.properties.gist.encodedMessageHtml,messageId=options.messageId,instanceId=options.instanceId;embedMessageIntoBody(encodedMessageHtml,instanceId,messageId)}else addDartRendererJs()} catch (error) {console.error('Parsing error:',error)}}function addDartRendererJs(){var script=getScriptElement();script.src='main.dart.js';script.async=!0;document.head.appendChild(script)}function loadScriptWithCallback(scriptName,callback){var script=getScriptElement();script.src=scriptName;script.onreadystatechange=callback;script.onload=callback;document.head.appendChild(script)}function embedMessageIntoBody(encodedMessageHtml,instanceId,messageId){var binaryString=atob(encodedMessageHtml),charData=binaryString.split('').map(x=>x.charCodeAt(0));var binData=new Uint8Array(charData);loadScriptWithCallback('pako_inflate.min.js',function(){loadHTMLMessage(new TextDecoder('utf-8').decode(pako.inflate(binData)),instanceId,messageId)})}function loadHTMLMessage(messageHtml,instanceId,messageId){var parser=new DOMParser();var doc=parser.parseFromString(messageHtml,'text/html');document.head.innerHTML+=doc.head.innerHTML;document.body.innerHTML=doc.body.innerHTML;loadScriptWithCallback('bridge.min.js',function(){messageLoaded(instanceId,messageId);keepReportingSizeChanges();reportTitleChange(document.title||'Message')});executeInlineScripts()}function keepReportingSizeChanges(){clearInterval(sizeChangeReportingIntervalId);sizeChangeReportingIntervalId=setInterval(reportMessageSize,1000)}function executeInlineScripts(){var scripts=document.body.getElementsByTagName('script');for(var i=0;i<scripts.length;i++)if(scripts[i].src){var tag=document.createElement('script');tag.src=scripts[i].src;document.head.appendChild(tag)}else window.$eval(scripts[i].innerText)}function getDecodedQueryParam(param){var queryString=window.location.search.substring(1);var urlParams=new URLSearchParams(queryString);let encodedValue=urlParams.get(param);if(encodedValue){encodedValue=encodedValue.replace(/-/g,'+').replace(/_/g,'/');try {return atob(encodedValue)} catch (e) {console.error('There was an error decoding the parameter:',e)}}else console.warn('Parameter not found:',param);return null}function getScriptElement(){var scriptElement=document.createElement('script');scriptElement.type='text/javascript';return scriptElement}loadMessage();