mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
22 lines
583 B
JavaScript
22 lines
583 B
JavaScript
function handleExternalScript () {
|
|
const container = Docsify.dom.getNode('#main')
|
|
const script = Docsify.dom.find(container, 'script')
|
|
|
|
if (script && script.src) {
|
|
const newScript = document.createElement('script')
|
|
|
|
;['src', 'async', 'defer'].forEach(attribute => {
|
|
newScript[attribute] = script[attribute]
|
|
})
|
|
|
|
script.parentNode.insertBefore(newScript, script)
|
|
script.parentNode.removeChild(script)
|
|
}
|
|
}
|
|
|
|
const install = function (hook) {
|
|
hook.doneEach(handleExternalScript)
|
|
}
|
|
|
|
window.$docsify.plugins = [].concat(install, window.$docsify.plugins)
|