bail out when the header has already been detected and the pageaction is already set

This commit is contained in:
idk
2020-12-12 23:33:25 -05:00
parent 39eb695522
commit 88517a7b52
3 changed files with 22 additions and 22 deletions

View File

@@ -660,9 +660,6 @@ var coolheadersSetup = function(e) {
function gotPopup(p) {
console.log('(scrub) checking popup', p);
if (p.length != 0) return;
/*if (p != undefined){
return
}*/
let headers = e.responseHeaders.filter((word) =>
word.name.toUpperCase().includes('I2P')
);
@@ -670,20 +667,26 @@ var coolheadersSetup = function(e) {
let header = headers[i];
console.log('(scrub) checking header', header);
if (header.name.toUpperCase().endsWith('I2P-LOCATION')) {
let url = new URL(header.value);
browser.pageAction.setPopup({
tabId: e.tabId,
popup: 'location.html',
});
browser.pageAction.setIcon({
path: 'icons/i2plogo.png',
tabId: e.tabId,
});
browser.pageAction.setTitle({
tabId: e.tabId,
title: 'http://' + url.host,
});
browser.pageAction.show(e.tabId);
var tab = browser.tabs.get(e.tabId);
tab.then(altSrc);
function altSrc(tab) {
console.log('(scrub) X-I2P-LOCATION');
let url = new URL(header.value);
browser.pageAction.setPopup({
tabId: e.tabId,
popup: 'location.html',
});
browser.pageAction.setIcon({
path: 'icons/i2plogo.png',
tabId: e.tabId,
});
let eurl = new URL(tab.url);
browser.pageAction.setTitle({
tabId: e.tabId,
title: 'http://' + url.host + eurl.pathname,
});
browser.pageAction.show(e.tabId);
}
break;
} else {
if (header.name.toUpperCase().endsWith('I2P-TORRENTLOCATION')) {