mirror of https://github.com/IoTcat/docsify.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
698 B
25 lines
698 B
function handleExternalScript() { |
|
const container = Docsify.dom.getNode('#main') |
|
const scripts = Docsify.dom.findAll(container, 'script') |
|
|
|
for (let i = scripts.length; i--;) { |
|
const script = scripts[i] |
|
|
|
if (script && script.src) { |
|
const newScript = document.createElement('script') |
|
|
|
Array.prototype.slice.call(script.attributes).forEach(attribute => { |
|
newScript[attribute.name] = attribute.value |
|
}) |
|
|
|
script.parentNode.insertBefore(newScript, script) |
|
script.parentNode.removeChild(script) |
|
} |
|
} |
|
} |
|
|
|
const install = function (hook) { |
|
hook.doneEach(handleExternalScript) |
|
} |
|
|
|
window.$docsify.plugins = [].concat(install, window.$docsify.plugins)
|
|
|