Add more logic to updateTopbarTitle, add bareURL option.

This commit is contained in:
wearrrrr 2024-03-28 10:29:18 -05:00
parent 4d6ab9ad4b
commit 551034179a
7 changed files with 34 additions and 5 deletions

View file

@ -201,7 +201,7 @@
let favicon =
iframe.contentDocument.querySelector("link[rel='icon']") ||
iframe.contentDocument.querySelector("link[rel*='icon']");
if (proxiedFavicon.src == favicon.href) return;
if(favicon) if (proxiedFavicon.src == favicon.href) return;
if (favicon) {
proxiedFavicon.src = favicon.href;
} else {
@ -215,6 +215,15 @@
}
function updateTopbarTitle(iframe) {
let topbarTitle = document.getElementById("url-text");
topbarTitle.innerText = iframe.contentDocument.title;
if (iframe.contentDocument.title == "") {
topbarTitle.innerText = iframe.src;
} else {
if (iframe.contentDocument.title.length > 65) {
topbarTitle.innerText = iframe.contentDocument.title.slice(0, 65) + "...";
return;
}
topbarTitle.innerText = iframe.contentDocument.title;
}
}
</script>

View file

@ -65,6 +65,10 @@ const transportsList = [
<label for="wisp-url-input" class="setting-label">{t("settings.proxy.wispURL")}</label>
<Input height="50px" inputName="wisp-url" defaultTextContent="wss://aluu.xyz/" />
</div>
<div class="setting__bare_url">
<label for="bare-url-input" class="setting-label">{t("settings.proxy.bareURL")}</label>
<Input height="50px" inputName="bare-url" defaultTextContent="https://aluu.xyz/bare/" />
</div>
<div class="setting__transport">
<label class="setting-label">{t("settings.proxy.transport")}</label>
<Dropdown

View file

@ -301,15 +301,27 @@ const t = useTranslations(lang);
let currentTransportDropdown = document.getElementById("dropdown__transport-menu");
let searxngUrlInput = document.getElementById("searxng-url-input");
let wispURLInput = document.getElementById("wisp-url-input");
let bareURLInput = document.getElementById("bare-url-input");
let savedSearxngUrl = localStorage.getItem("alu__searxngUrl");
if (savedSearxngUrl != undefined) {
if (savedSearxngUrl == "")
localStorage.setItem("alu__searxngUrl", "https://searxng.site/");
searxngUrlInput.value = localStorage.getItem("alu__searxngUrl");
}
let savedWispUrl = localStorage.getItem("alu__wispUrl");
if (savedWispUrl != undefined) {
if (savedWispUrl == "") localStorage.setItem("alu__wispUrl", "wss://aluu.xyz/");
wispURLInput.value = localStorage.getItem("alu__wispUrl");
}
let savedBareUrl = localStorage.getItem("alu__bareUrl");
if (savedBareUrl != undefined) {
if (savedBareUrl == "") localStorage.setItem("alu__bareUrl", "https://aluu.xyz/bare/");
bareURLInput.value = localStorage.getItem("alu__bareUrl");
}
// Proxy settings
applyInputListeners(searxngUrlInput, "alu__searxngUrl");
applyInputListeners(wispURLInput, "alu__wispUrl");
applyInputListeners(bareURLInput, "alu__bareUrl");
[selectedProxyDropdown, openWithDropdown, currentTransportDropdown].forEach((dropdown) => {
let dropdownButton = document.getElementById(dropdown.id.replace("-menu", ""));

View file

@ -41,7 +41,7 @@ export default class TransportManager {
let transportConfig: transportConfig = { wisp: wispURL };
if (this.transport == "BareMod.BareClient") {
transportConfig = window.location.origin + "/bare/";
transportConfig = localStorage.getItem("alu__bareURL") || window.location.origin + "/bare/";
}
SetTransport(this.transport, transportConfig);

View file

@ -43,6 +43,7 @@
"settings.proxy.searxngURL": "Searx URL",
"settings.proxy.transport": "Transport",
"settings.proxy.wispURL": "Wisp URL",
"settings.proxy.bareURL": "Bare URL",
"settings.customization": "Customization",
"settings.customization.theme": "Theme",

View file

@ -34,6 +34,7 @@
"settings.title": "設定",
"settings.proxy": "プロキシ",
"settings.proxy.auto": "自動",
"settings.proxy.selectedProxy": "選択されたプロキシ",
"settings.proxy.searchEngine": "検索エンジン",
"settings.proxy.openPageWith": "開く",
@ -42,6 +43,7 @@
"settings.proxy.searxngURL": "SearxのURL",
"settings.proxy.transport": "トランスポート",
"settings.proxy.wispURL": "ウィスプのURL",
"settings.proxy.bareURL": "BareのURL",
"settings.customization": "カスタマイズ",
"settings.customization.theme": "テーマ",

View file

@ -10,7 +10,8 @@ export function getLangFromUrl(url: URL) {
}
export function useTranslations(lang: keyof typeof ui) {
return function t(key: keyof (typeof ui)[typeof defaultLang]) {
return ui[lang][key] || ui[defaultLang][key];
return function t(translationKey: keyof (typeof ui)[typeof defaultLang]) {
if (ui[lang][translationKey]) return ui[lang][translationKey];
else return ui[defaultLang][translationKey];
};
}