💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 方式一: ``` function appendscript(src, text, reload, charset) { var id = hash(src + text); if (!reload && in_array(id, evalscripts)) return; if (reload && $(id)) { $(id).parentNode.removeChild($(id)); } evalscripts.push(id); var scriptNode = document.createElement("script"); scriptNode.type = "text/javascript"; scriptNode.id = id; scriptNode.charset = charset ? charset : BROWSER.firefox ? document.characterSet : document.charset; try { if (src) { scriptNode.src = src; scriptNode.onloadDone = false; scriptNode.onload = function() { scriptNode.onloadDone = true; JSLOADED[src] = 1; }; scriptNode.onreadystatechange = function() { if ( (scriptNode.readyState == "loaded" || scriptNode.readyState == "complete") && !scriptNode.onloadDone ) { scriptNode.onloadDone = true; JSLOADED[src] = 1; } }; } else if (text) { scriptNode.text = text; } document.getElementsByTagName("head")[0].appendChild(scriptNode); } catch (e) {} } ``` ## 方式二: ``` export const injectScript = (src) => { const s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = src; const t = document.getElementsByTagName('script')[0]; t.parentNode.insertBefore(s, t); } ```