mirror of
https://github.com/lencx/ChatGPT.git
synced 2026-02-06 09:37:05 +00:00
79 lines
2.2 KiB
JavaScript
Vendored
79 lines
2.2 KiB
JavaScript
Vendored
// *** Core Script - Origin ***
|
|
|
|
function init() {
|
|
document.body.innerHTML = `<style>
|
|
body {
|
|
height: 100vh;
|
|
padding: 0;
|
|
margin: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-family: Söhne,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,Helvetica Neue,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;
|
|
}
|
|
h3 {
|
|
margin-bottom: 20px;
|
|
}
|
|
input {
|
|
all: unset;
|
|
width: 280px;
|
|
height: 30px;
|
|
margin-bottom: 10px;
|
|
padding: 0 5px;
|
|
border: solid 2px #d8d8d8;
|
|
background-color: #fff;
|
|
border-radius: 5px !important;
|
|
color: #4a4a4a;
|
|
}
|
|
button {
|
|
all: unset;
|
|
height: 30px;
|
|
font-size: 16px;
|
|
padding: 0 10px;
|
|
line-height: 30px;
|
|
margin: 0 5px;
|
|
color: #fff;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
}
|
|
#cancel {
|
|
background-color: #999;
|
|
}
|
|
#confirm {
|
|
background-color: #10a37f;
|
|
}
|
|
</style>
|
|
<h3>Switch Origin</h3>
|
|
<input id="input" type="text" autocapitalize="off" autocomplete="off" spellcheck="false" autofocus placeholder="https://chat.openai.com" />
|
|
<div class="btns">
|
|
<button id="cancel">Cancel</button>
|
|
<button id="confirm">Confirm</button>
|
|
</div>`;
|
|
|
|
const srcipt = document.createElement('script');
|
|
srcipt.innerHTML = `const input = document.getElementById('input');
|
|
const cancelBtn = document.getElementById('cancel');
|
|
const confirmBtn = document.getElementById('confirm');
|
|
cancelBtn.addEventListener('click', () => {
|
|
window.invoke('form_cancel', { label: 'origin', title: 'Switch Origin', msg: 'Are you sure you want to cancel editing?' });
|
|
})
|
|
confirmBtn.addEventListener('click', () => {
|
|
if (/^https?:\\/\\//.test(input.value)) {
|
|
window.invoke('form_confirm', { data: { origin: input.value } });
|
|
} else {
|
|
window.invoke('form_msg', { label: 'origin', title: 'Switch Origin', msg: 'Invalid URL!' });
|
|
}
|
|
})`;
|
|
document.head.appendChild(srcipt);
|
|
}
|
|
|
|
// run init
|
|
if (
|
|
document.readyState === "complete" ||
|
|
document.readyState === "interactive"
|
|
) {
|
|
init();
|
|
} else {
|
|
document.addEventListener("DOMContentLoaded", init);
|
|
} |