mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-19 05:31:29 +08:00
75c72e917b
* chore: added new linter config * chore: linting fixes * chore: refactore in linting config and minor linting fixes
26 lines
709 B
JavaScript
26 lines
709 B
JavaScript
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);
|