Skip to content

Commit 2416d82

Browse files
Start the process of custom favicon stuff for tabs
1 parent 65e33f0 commit 2416d82

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/public/js/controls.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ function popout() {
4747
win.focus();
4848
} catch (err) {};
4949
}
50+
function pageLoaded() {
51+
let currentTab = getCurrentTab();
52+
let iframe = document.querySelector(`[data-iframe-id="${currentTab}"]`);
53+
iframe.addEventListener('load', function() {
54+
let val = iframe.contentWindow.location.href;
55+
let currentProx = localStorage.getItem('proxy');
56+
//remove the https:// or http:// and the prefix
57+
val = val.replace(window.location.origin, '');
58+
if (currentProx === 'uv') {
59+
val = val.replace(__uv$config.prefix, '');
60+
val = __uv$config.decodeUrl(val);
61+
}
62+
if (currentProx === 'dynamic') {
63+
val = val.replace(__dynam$ic.prefix + 'route/?url=', '');
64+
val = __dynam$ic.decodeUrl(val);
65+
}
66+
updateSearch(val);
67+
});
68+
}
5069
function fullscreen() {
5170
//this has two options, fullscreen the page, and fullscreen the tab to the window (add later)
5271
let currentTab = getCurrentTab();
@@ -90,3 +109,7 @@ function searchBar(value) {
90109
i.value = value;
91110
f.dispatchEvent(new Event('submit'));
92111
}
112+
function updateSearch(value) {
113+
const s = document.getElementById('search-input');
114+
s.value = value;
115+
}

src/public/js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
form.addEventListener("submit", (event) => {
2020
event.preventDefault();
2121
const url = search(address.value, localStorage.getItem("searchEngine"));
22+
updateSearch(url);
2223
address.value = "";
2324
switch (localStorage.getItem("proxy")) {
2425
case "uv":

src/public/js/tabs.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ function handoffToTABS(url) {
7979
let tabId = chromeTabs.activeTabEl.getAttribute('data-tab-id');
8080
iframe.setAttribute('data-iframe-id', tabId);
8181
document.body.appendChild(iframe);
82+
pageLoaded();
83+
}
84+
function changeTabDetail(title, favicon) {
85+
let tabId = chromeTabs.activeTabEl
86+
//get the div chrome-tab-content
87+
let tabContent = tabId.querySelector('.chrome-tab-content');
88+
let tabTitle = tabContent.querySelector('.chrome-tab-title');
89+
let tabFavicon = tabContent.querySelector('.chrome-tab-favicon');
90+
tabTitle.innerHTML = title;
91+
//the tab favicon is set with a background image
92+
tabFavicon.style.backgroundImage = `url(${favicon})`;
8293
}
8394

8495
function restoreTabs() {

0 commit comments

Comments
 (0)