2020-03-05 23:25:08 -05:00
|
|
|
function blankContent(id) {
|
|
|
|
let infoTitle = document.getElementById(id);
|
|
|
|
if (infoTitle === null) {
|
2020-06-22 21:49:14 -04:00
|
|
|
console.log('content error', id);
|
2020-03-05 23:25:08 -05:00
|
|
|
return;
|
|
|
|
}
|
2020-06-22 21:49:14 -04:00
|
|
|
infoTitle.textContent = '';
|
2020-03-05 23:25:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function contentUpdateById(id, message) {
|
|
|
|
let infoTitle = document.getElementById(id);
|
|
|
|
let messageContent = chrome.i18n.getMessage(message);
|
|
|
|
if (infoTitle === null) {
|
2020-06-22 21:49:14 -04:00
|
|
|
console.log('content error', id, messageContent);
|
2020-03-05 23:25:08 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
infoTitle.textContent = messageContent;
|
|
|
|
}
|
|
|
|
|
2020-06-22 21:49:14 -04:00
|
|
|
contentUpdateById('TypeLabel', 'siteLabel');
|
2020-03-05 23:25:08 -05:00
|
|
|
|
2020-06-22 21:49:14 -04:00
|
|
|
contentUpdateById('CertLabel', 'certLabel');
|
2020-03-05 23:25:08 -05:00
|
|
|
|
|
|
|
function tabCheck(tabInfo) {
|
|
|
|
// Information Section
|
2020-06-22 21:49:14 -04:00
|
|
|
console.log('(cert) checking tab');
|
|
|
|
var host = tabInfo[0].url.split('.i2p')[0] + '.i2p';
|
2020-03-05 23:25:08 -05:00
|
|
|
if (host.length < 51) {
|
2020-06-22 21:49:14 -04:00
|
|
|
contentUpdateById('AddressInfo', 'isHostName');
|
2020-03-05 23:25:08 -05:00
|
|
|
} else {
|
2020-06-22 21:49:14 -04:00
|
|
|
if (host.endsWith('b32.i2p')) {
|
|
|
|
contentUpdateById('AddressInfo', 'isBase32');
|
2020-03-05 23:25:08 -05:00
|
|
|
}
|
|
|
|
}
|
2020-06-22 21:49:14 -04:00
|
|
|
if (host.startsWith('https')) {
|
|
|
|
contentUpdateById('AddressCertInfo', 'certPresent');
|
|
|
|
console.log('(cert) initiating request to check server cert');
|
2020-11-10 21:48:08 -05:00
|
|
|
fetch(host).then((response) => {
|
2020-06-22 21:49:14 -04:00
|
|
|
console.log('Updating cert information', response);
|
2020-03-05 23:25:08 -05:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
contentUpdateById("AddressCertInfo", "certAbsent");
|
|
|
|
blankContent("SignedLabel");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function tabError(error) {
|
|
|
|
console.log(`Error: ${error}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const gettingCurrent = browser.tabs.query({ active: true });
|
|
|
|
gettingCurrent.then(tabCheck, tabError);
|