请帮我解决检测异步脚本何时加载的问题。实际上,我的网站上有一个异步加载的实时聊天按钮,这个小部件的脚本被混淆了。加载此脚本后,我需要在聊天按钮上设置一个事件监听器。Window.onload 在聊天按钮出现之前触发。请指教。
代码:
_shcp = [];
_shcp.push({
widget_id: xxxxxx,
widget: "Chat",
side: "left",
position: "center",
template: "orange",
title: "Live help",
text_layout: "trans",
track: 1
});
(function () {
var hcc = document.createElement("script");
hcc.type = "text/javascript";
hcc.async = true;
hcc.src = ("https:" == document.location.protocol ? "https" : "http") + "://widget.siteheart.com/apps/js/sh.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hcc, s.nextSibling);
})();