Skip to content

Commit a9a2300

Browse files
committed
update v5.2
1 parent 2331c79 commit a9a2300

File tree

1 file changed

+104
-2
lines changed

1 file changed

+104
-2
lines changed

King_Translator_AI.user.js

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name King Translator AI
33
// @namespace https://kingsmanvn.pages.dev
4-
// @version 5.1
4+
// @version 5.2
55
// @author King1x32
66
// @icon https://raw.githubusercontent.com/king1x32/King-Translator-AI/refs/heads/main/icon/kings.jpg
77
// @license GPL3
@@ -2608,6 +2608,11 @@ h2 {
26082608
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
26092609
grid-column: 1 / -1;
26102610
}
2611+
.settings-title-text {
2612+
flex-grow: 1;
2613+
text-align: center;
2614+
margin-right: 10px; /* Tạo khoảng cách với dropdown */
2615+
}
26112616
@keyframes text-shimmer {
26122617
0% {
26132618
background-position: -200% 0; /* Bắt đầu từ bên trái của gradient */
@@ -2738,7 +2743,9 @@ button:active {
27382743
styleElement.textContent = resetStyle;
27392744
container.appendChild(styleElement);
27402745
container.innerHTML += `
2741-
<h2 style="position: sticky; top: 0; background-color: ${theme.background}; padding: 20px; margin: 0; z-index: 2147483647; border-bottom: 1px solid ${theme.border}; border-radius: 15px 15px 0 0;">${this._("settings.title")}</h2>
2746+
<h2 id="settings-header" style="position: sticky; top: 0; background-color: ${theme.background}; padding: 20px; margin: 0; z-index: 2147483647; border-bottom: 1px solid ${theme.border}; border-radius: 15px 15px 0 0;">
2747+
<span class="settings-title-text">${this._("settings.title")}</span>
2748+
</h2>
27422749
<div style="margin-bottom: 15px;">
27432750
<h3>${this._("settings.interface_section")}</h3>
27442751
<span class="settings-label">${this._("settings.theme_mode")}</span>
@@ -3516,6 +3523,101 @@ ${this.renderSettingsUI(this.settings)}
35163523
</div>
35173524
`;
35183525
container.className = "translator-settings-container";
3526+
const header = container.querySelector('#settings-header');
3527+
const navContainer = document.createElement('div');
3528+
navContainer.className = 'custom-nav-container';
3529+
Object.assign(navContainer.style, {
3530+
position: 'relative',
3531+
marginLeft: '15px'
3532+
});
3533+
const navButton = document.createElement('button');
3534+
navButton.className = 'custom-nav-button';
3535+
navButton.innerHTML = `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAD4ElEQVR4nO2ZX2hbVRzHr6BBQXwRBj514GybmKZt2rTVJo19cX872powh7Tbqqtr7UMnWkEfurHW3qpY14mu0JqxSLeFNlttapKmtTA254P4INMHn71lqIjCxIGwj/wid8owkNwG5abnAx/I+XfP+Z6Em3sSTVMoFAqFQqFQKBQKxd+4wjjK+hnf2s/61n6wpX0YZf3okkUrlEf70Lf1QSkoWQregPJejIoXoeIwT2o2pbwXv2SQLAUPfrwXRM3mWM7heQFEs3x6Fexkrhx5430eRLO8vAR2MleOvPEdAlGzOZZzNB7AaDoIjYfwazal4SCBbIYDFm6C/i50fzeUiGMFb4ArjCPYhR7swgh2gU2VtVt7EFIoFJubcBhHR5jx9jDrHWGwpSGM9hC6ZCl4A0Ih9FAISsTCT4P7OjGe7YR9z9j3NLi/HX82Q6eFB6HnOkDUbI7lHN3tIJrld9fATubKkTc9e0E0y4tJsJO5cuTN4TYQNZtjOceRXRh9u6F/j31Pg0d2E5AMkqXgwQM70Qd2QSn40k4Lp8HhMI7B7eiDOzAGd4BNNSSDZCl4AxQKxeZmOIzjWCvjx1pZP94KtvQpjOOtFm+CJ4LoI0EoBU+08GbBGzDWgqG3wKifZs2mjLcQkAx6gO8LHvy2H0TN5ljOMdEMoll+7SpsxKEr/DR0lbeG17g315y9X3Lf0BXekb4bnS9XjryZfAJEszx6GYrkqVxzjlzm/WLNkytH3nzQBKJWJCZWaZn8jFsnV7l9ao09d7efXKFN2qTP5AqBYs1rOcdUA+tTDTBVX7yfxD7K8HIkA5EMP0STPGLWn02zJbLMDWmbyXC0WPN9WEezZDjts3AanK5nfMYHG7Ken6d9TMRcf30PA/fMp1iaT8F8krSUxbkUCambS7IsZekrY2Z8vCfX2Og6pustnAZjLhwRL/qZOowzdbBBI+Z102m2pJe4kf0ff5HBdIKj8jq9xI/Jf3wqZEwR5pW1j5lvwH9O1EtT1MvNqBeitfSY9Z9/Qtu1BW5/scAtUV5fu8TeO+Nq6cmO8XLzbB2Nmp2ZrWH/uRo4V83vsx5qzfrrFxn55iKI1+OMmvXnPbhnq/lNxpyvoVsrBWLVTMeq4YKH76INPGTWG3NUinf6uXgw5uFb6RvzMKWVCpEy7o+7+SpeBfNVXMjVL17Fx9k+br6ONfGAVkosOnnskptfF9yw4Gbg7napk7ZsHxfbtFIk4SK85IKEkz8STl6JV/KwmHDyqtRJ26cuQlopk3LyRsoJ/2bSyevaZmC5gu0rFWRWKvhFzJSzvFrJ0//3uhQKhULbbPwJfPNsE9o0QzgAAAAASUVORK5CYII=" alt="menu-list-down" style="width: 20px; height: 20px; display: block;">`;
3536+
Object.assign(navButton.style, {
3537+
backgroundColor: isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.05)',
3538+
border: `1px solid ${isDark ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.1)'}`,
3539+
borderRadius: '8px',
3540+
width: '38px',
3541+
height: '38px',
3542+
padding: '0',
3543+
display: 'flex',
3544+
alignItems: 'center',
3545+
justifyContent: 'center',
3546+
cursor: 'pointer',
3547+
transition: 'background-color 0.2s'
3548+
});
3549+
navButton.onmouseover = () => navButton.style.backgroundColor = isDark ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.1)';
3550+
navButton.onmouseout = () => navButton.style.backgroundColor = isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.05)';
3551+
const navMenu = document.createElement('div');
3552+
navMenu.className = 'custom-nav-menu';
3553+
Object.assign(navMenu.style, {
3554+
display: 'none',
3555+
position: 'absolute',
3556+
top: 'calc(100% + 5px)',
3557+
right: '0',
3558+
color: theme.text,
3559+
backgroundColor: theme.background,
3560+
borderRadius: '12px',
3561+
boxShadow: '0 4px 12px rgba(0,0,0,0.2)',
3562+
padding: '8px',
3563+
minWidth: '240px',
3564+
maxHeight: '400px',
3565+
overflowY: 'auto',
3566+
zIndex: '2147483648',
3567+
border: `1px solid ${theme.border}`
3568+
});
3569+
const sections = container.querySelectorAll('h3');
3570+
sections.forEach((section, index) => {
3571+
const title = section.textContent.trim();
3572+
if (title) {
3573+
if (!section.id) section.id = `settings-section-${index}`;
3574+
const menuItem = document.createElement('div');
3575+
menuItem.className = 'custom-nav-menu-item';
3576+
menuItem.textContent = title;
3577+
menuItem.dataset.targetId = section.id;
3578+
Object.assign(menuItem.style, {
3579+
display: 'flex',
3580+
alignItems: 'center',
3581+
gap: '10px',
3582+
marginBottom: '5px',
3583+
borderRadius: '10px',
3584+
padding: '10px 15px',
3585+
cursor: 'pointer',
3586+
border: `1px solid ${theme.border}`,
3587+
backgroundColor: theme.backgroundShadow,
3588+
transition: 'background-color 0.2s, color 0.2s',
3589+
whiteSpace: 'nowrap'
3590+
});
3591+
menuItem.onmouseover = () => menuItem.style.backgroundColor = theme.button.translate.background;
3592+
menuItem.onmouseout = () => menuItem.style.backgroundColor = 'transparent';
3593+
menuItem.addEventListener('click', () => {
3594+
const targetId = menuItem.dataset.targetId;
3595+
const targetElement = container.querySelector(`#${targetId}`);
3596+
if (targetElement) {
3597+
const headerHeight = header.offsetHeight;
3598+
const targetOffsetTop = targetElement.offsetTop;
3599+
container.scrollTo({
3600+
top: targetOffsetTop - headerHeight - 20,
3601+
behavior: 'smooth'
3602+
});
3603+
}
3604+
navMenu.style.display = 'none';
3605+
});
3606+
navMenu.appendChild(menuItem);
3607+
}
3608+
});
3609+
navButton.addEventListener('click', (e) => {
3610+
e.stopPropagation();
3611+
navMenu.style.display = navMenu.style.display === 'block' ? 'none' : 'block';
3612+
});
3613+
document.addEventListener('click', (e) => {
3614+
if (!navContainer.contains(e.target)) {
3615+
navMenu.style.display = 'none';
3616+
}
3617+
});
3618+
navContainer.appendChild(navButton);
3619+
navContainer.appendChild(navMenu);
3620+
header.appendChild(navContainer);
35193621
const providers = ['gemini', 'perplexity', 'claude', 'openai', 'mistral', 'puter', 'ollama'];
35203622
container.querySelectorAll('input[name="apiProvider"]').forEach(radio => {
35213623
radio.addEventListener('change', (e) => {

0 commit comments

Comments
 (0)