Merge wrapper js

This commit is contained in:
shortcutme 2018-11-26 00:05:17 +01:00
parent 233e161327
commit cbefc5b81e
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -908,7 +908,7 @@ $.extend( $.easing,
};
Wrapper.prototype.onMessageWebsocket = function(e) {
var cmd, id, message, ref, type;
var cmd, id, message, ref, script_tag, type;
message = JSON.parse(e.data);
cmd = message.cmd;
if (cmd === "response") {
@ -955,8 +955,15 @@ $.extend( $.easing,
} else if (cmd === "updating") {
this.ws.ws.close();
return this.ws.onCloseWebsocket(null, 4000);
} else if (cmd === "redirect") {
return window.top.location = message.params;
} else if (cmd === "injectHtml") {
return $("body").append(message.params);
} else if (cmd === "injectScript") {
script_tag = $("<script>");
script_tag.attr("nonce", this.script_nonce);
script_tag.html(message.params);
return document.head.appendChild(script_tag[0]);
} else {
return this.sendInner(message);
}
@ -1475,8 +1482,11 @@ $.extend( $.easing,
};
Wrapper.prototype.onWrapperLoad = function() {
this.script_nonce = window.script_nonce;
this.wrapper_key = window.wrapper_key;
delete window.wrapper;
delete window.wrapper_key;
delete window.script_nonce;
return $("#script_init").remove();
};