diff --git a/javascript/index.js b/javascript/index.js index d28cb09..0e30bb0 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -1,4 +1,4 @@ -(() => { +;(() => { const html = ` @@ -16,34 +16,41 @@ ` const asyncCheck = async (getter, checkSize = 100, timeout = 1000) => { - return new Promise(x => { + return new Promise((x) => { const check = (num = 0) => { - const target = getter(); + const target = getter() if (target !== undefined && target !== null) { x(target) - } else if (num > timeout / checkSize) {// 超时 + } else if (num > timeout / checkSize) { + // 超时 x(target) } else { - setTimeout(() => check(++num), checkSize); + setTimeout(() => check(++num), checkSize) } - }; - check(); - }); + } + check() + }) } - // eslint-disable-next-line no-undef - asyncCheck(() => gradioApp().querySelector("#baidu_netdisk_container_wrapper"), 500, Infinity).then((el) => { + asyncCheck( + // eslint-disable-next-line no-undef + () => gradioApp().querySelector('#baidu_netdisk_container_wrapper'), + 500, + Infinity + ).then((el) => { /** * @type {HTMLDivElement} */ const wrap = el - wrap.childNodes.forEach(v => wrap.removeChild(v)) + wrap.childNodes.forEach((v) => wrap.removeChild(v)) const iframe = document.createElement('iframe') - iframe.srcdoc = html + iframe.srcdoc = html const updateHeight = () => { - iframe.style = `width:100%;height:${(window.innerHeight < 1024) ? '100vh' : (window.innerHeight - 128)}px` + iframe.style = `width:100%;height:${ + window.innerHeight < 1024 ? '100vh' : window.innerHeight - 128 + 'px' + }` } updateHeight() window.addEventListener('resize', updateHeight) wrap.appendChild(iframe) }) -})() \ No newline at end of file +})() diff --git a/vue/index.tpl.js b/vue/index.tpl.js index 45c450f..e705bee 100644 --- a/vue/index.tpl.js +++ b/vue/index.tpl.js @@ -1,34 +1,41 @@ -(() => { +;(() => { const html = `__built_html__` const asyncCheck = async (getter, checkSize = 100, timeout = 1000) => { - return new Promise(x => { + return new Promise((x) => { const check = (num = 0) => { - const target = getter(); + const target = getter() if (target !== undefined && target !== null) { x(target) - } else if (num > timeout / checkSize) {// 超时 + } else if (num > timeout / checkSize) { + // 超时 x(target) } else { - setTimeout(() => check(++num), checkSize); + setTimeout(() => check(++num), checkSize) } - }; - check(); - }); + } + check() + }) } - // eslint-disable-next-line no-undef - asyncCheck(() => gradioApp().querySelector("#baidu_netdisk_container_wrapper"), 500, Infinity).then((el) => { + asyncCheck( + // eslint-disable-next-line no-undef + () => gradioApp().querySelector('#baidu_netdisk_container_wrapper'), + 500, + Infinity + ).then((el) => { /** * @type {HTMLDivElement} */ const wrap = el - wrap.childNodes.forEach(v => wrap.removeChild(v)) + wrap.childNodes.forEach((v) => wrap.removeChild(v)) const iframe = document.createElement('iframe') - iframe.srcdoc = html + iframe.srcdoc = html const updateHeight = () => { - iframe.style = `width:100%;height:${(window.innerHeight < 1024) ? '100vh' : (window.innerHeight - 128)}px` + iframe.style = `width:100%;height:${ + window.innerHeight < 1024 ? '100vh' : window.innerHeight - 128 + 'px' + }` } updateHeight() window.addEventListener('resize', updateHeight) wrap.appendChild(iframe) }) -})() \ No newline at end of file +})()