mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Bypass localtunnel on loading extension files
This commit is contained in:
@ -167,33 +167,49 @@ let extensions = [];
|
|||||||
addExtensionScript(extension);
|
addExtensionScript(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addExtensionStyle(extension) {
|
async function addExtensionStyle(extension) {
|
||||||
if (extension.metadata.css) {
|
if (extension.metadata.css) {
|
||||||
|
try {
|
||||||
url.pathname = `/api/style/${extension.name}`;
|
url.pathname = `/api/style/${extension.name}`;
|
||||||
const href = url.toString();
|
const link = url.toString();
|
||||||
|
|
||||||
if ($(`link[href="${href}"]`).length === 0) {
|
const result = await fetch(link, { method: 'GET', headers: { 'Bypass-Tunnel-Reminder': 'bypass' } });
|
||||||
const link = document.createElement('link');
|
const text = await result.text();
|
||||||
link.rel = 'stylesheet';
|
|
||||||
link.type = 'text/css';
|
if ($(`style[id="${link}"]`).length === 0) {
|
||||||
link.href = href;
|
const style = document.createElement('style');
|
||||||
$('head').append(link);
|
style.id = link;
|
||||||
|
style.innerHTML = text;
|
||||||
|
$('head').append(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addExtensionScript(extension) {
|
async function addExtensionScript(extension) {
|
||||||
if (extension.metadata.js) {
|
if (extension.metadata.js) {
|
||||||
|
try {
|
||||||
url.pathname = `/api/script/${extension.name}`;
|
url.pathname = `/api/script/${extension.name}`;
|
||||||
const src = url.toString();
|
const link = url.toString();
|
||||||
|
|
||||||
if ($(`script[src="${src}"]`).length === 0) {
|
const result = await fetch(link, { method: 'GET', headers: { 'Bypass-Tunnel-Reminder': 'bypass' } });
|
||||||
|
const text = await result.text();
|
||||||
|
|
||||||
|
if ($(`script[id="${link}"]`).length === 0) {
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
|
script.id = link;
|
||||||
script.type = 'module';
|
script.type = 'module';
|
||||||
script.src = src;
|
script.innerHTML = text;
|
||||||
$('body').append(script);
|
$('body').append(script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user