Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement suggestion for 2 userscripts #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions scripts/favicon_in_urlbar.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,28 @@ var FaviconInUrlbar = {
// update script every time tab attributes get modified (switch/open tabs/windows)
document.addEventListener("TabAttrModified", updateIcon, false);
document.addEventListener('TabSelect', updateIcon, false);
document.addEventListener('TabOpen', updateIcon, false);
document.addEventListener('TabClose', updateIcon, false);
document.addEventListener('load', updateIcon, false);
document.addEventListener("DOMContentLoaded", updateIcon, false);
// document.addEventListener('TabOpen', updateIcon, false);
// document.addEventListener('load', updateIcon, false);
// document.addEventListener("DOMContentLoaded", updateIcon, false);


function updateIcon(e) {
if (e && e.target.getAttribute('selected') !== 'true') return; // don't listen to non-selected tabs

function updateIcon() {
setTimeout(function(){ // timeout fixes wrong icon detection in some cases

setTimeout(function(){ // timeout fixes wrong icon detection in some cases

// get current tabs favicon
var favicon_in_urlbar = gBrowser.selectedTab.image;

// if current tab offers no icon, use selected icon (icon_for_pages_without_favicon)
if(!gBrowser.selectedTab.image || gBrowser.selectedTab.image == null)
if(!icon_for_pages_without_favicon) favicon_in_urlbar = brand;
else favicon_in_urlbar = icon_for_pages_without_favicon;

document.querySelector('#favimginurlbar').style.listStyleImage = "url("+favicon_in_urlbar+")";

},100);
// get current tabs favicon
var favicon_in_urlbar = gBrowser.selectedTab.image;

// if current tab offers no icon, use selected icon (icon_for_pages_without_favicon)
if(!gBrowser.selectedTab.image || gBrowser.selectedTab.image == null)
if(!icon_for_pages_without_favicon) favicon_in_urlbar = brand;
else favicon_in_urlbar = icon_for_pages_without_favicon;

document.querySelector('#favimginurlbar').style.listStyleImage = "url("+favicon_in_urlbar+")";

},100);

}

Expand Down
18 changes: 13 additions & 5 deletions scripts/tab_label_in_urlbar.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@
updateLabel();

// catch cases where tab title can change
document.addEventListener("TabAttrModified", updateLabel, false);
document.addEventListener('TabAttrModified', updateLabel, false);
document.addEventListener('TabSelect', updateLabel, false);
document.addEventListener('TabOpen', updateLabel, false);
document.addEventListener('TabClose', updateLabel, false);
document.addEventListener('load', updateLabel, false);
document.addEventListener("DOMContentLoaded", updateLabel, false);
// document.addEventListener('TabOpen', updateLabel, false);
// document.addEventListener('load', updateLabel, false);
// document.addEventListener("DOMContentLoaded", updateLabel, false);

function updateLabel() {
function updateLabel(e) {
if (e) {
if (e.target.getAttribute('selected') !== 'true') return; // don't listen to non-selected tabs

if (e.target._fullLabel || e.target.label) {
tablabel.setAttribute("value", e.target._fullLabel || e.target.label);
return;
}
}
tablabel.setAttribute("value",gBrowser.selectedBrowser.contentTitle);
}

Expand Down