mirror of
https://github.com/tlsnotary/PageSigner.git
synced 2026-01-09 14:48:07 -05:00
use pure js notification bar in firefox without css
This commit is contained in:
1
bootstrap.js
vendored
1
bootstrap.js
vendored
@@ -206,6 +206,7 @@ function loadjs(){
|
||||
include(addon, "jsbn2.js");
|
||||
include(addon, "pako.js");
|
||||
include(addon, "tlsn.js");
|
||||
include(addon, "notification_bar.js");
|
||||
include(addon, "testing/testing.js");
|
||||
include(addon, "testing/manager_test.js");
|
||||
include(addon, "verifychain/buffer.js2");
|
||||
|
||||
@@ -402,12 +402,12 @@ function openTabs(sdir){
|
||||
chrome.tabs.reload(id, {bypassCache:true}, function(){
|
||||
//this callback triggers too early sometimes. Wait to make sure page reloaded
|
||||
setTimeout(function(){
|
||||
chrome.tabs.insertCSS(id, {file: 'content/chrome/injectbar.css'}, function(a){
|
||||
chrome.tabs.executeScript(id, {file: 'content/chrome/injectbar.js'}, function(a){
|
||||
chrome.tabs.executeScript(id, {code:
|
||||
'document.getElementById("domainName").textContent="' + commonName.toString() + '";' +
|
||||
'var sdir ="' + dirname.toString() + '";'});
|
||||
});
|
||||
chrome.tabs.executeScript(id, {file: 'content/notification_bar.js'}, function(a){
|
||||
chrome.tabs.executeScript(id, {code:
|
||||
'viewTabDocument = document;' +
|
||||
'install_bar();' +
|
||||
'document.getElementById("domainName").textContent="' + commonName.toString() + '";' +
|
||||
'document["pagesigner-session-dir"]="' + dirname.toString() + '";'});
|
||||
});
|
||||
}, 500);
|
||||
});
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
.visible {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
-webkit-transition: opacity 2s linear;
|
||||
}
|
||||
.hidden {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
-webkit-transition: visibility 0s 2s, opacity 2s linear;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
var table = document.createElement("table");
|
||||
table.style.position = "fixed";
|
||||
table.style.top = "0px";
|
||||
table.style.left = "100px";
|
||||
table.style.background = "rgba(242, 241, 240, 0.9)";
|
||||
table.style.width = "80%";
|
||||
table.style.height = "32px";
|
||||
table.className = "hidden";
|
||||
var row = document.createElement("tr");
|
||||
var cell1 = document.createElement("td");
|
||||
var cell2 = document.createElement("td");
|
||||
var cell3 = document.createElement("td");
|
||||
cell3.style.align = "right";
|
||||
var img = document.createElement("img");
|
||||
img.src = "icon16.png";
|
||||
var text = document.createElement("text");
|
||||
text.textContent = "PageSigner successfully verified that the webpage below was received from ";
|
||||
var domain = document.createElement("text");
|
||||
domain.id = "domainName";
|
||||
var button = document.createElement("button");
|
||||
button.id = "viewRaw";
|
||||
button.textContent = "View raw data with HTTP headers";
|
||||
button.style.MozBorderRadius = "4px";
|
||||
button.style.WebkitBorderRadius = "4px";
|
||||
button.style.borderRadius = "4px";
|
||||
button.onclick = function(){
|
||||
chrome.runtime.sendMessage({destination:'extension', message:'viewraw', args:{dir:sdir}});
|
||||
}
|
||||
cell3.appendChild(button)
|
||||
cell2.appendChild(text);
|
||||
cell2.appendChild(domain);
|
||||
cell1.appendChild(img);
|
||||
row.appendChild(cell1);
|
||||
row.appendChild(cell2);
|
||||
row.appendChild(cell3);
|
||||
table.appendChild(row);
|
||||
document.body.appendChild(table);
|
||||
|
||||
setTimeout(function(){
|
||||
//make a transition to visible
|
||||
table.className = "visible";
|
||||
}, 0);
|
||||
@@ -184,6 +184,7 @@ function browser_specific_init(){
|
||||
var cross = OS.Path.fromFileURI(thisaddon.getResourceURI('content/cross.png').spec);
|
||||
var swalcss = OS.Path.fromFileURI(thisaddon.getResourceURI('content/sweetalert.css').spec);
|
||||
var swaljs = OS.Path.fromFileURI(thisaddon.getResourceURI('content/sweetalert.min.js2').spec);
|
||||
var icon = OS.Path.fromFileURI(thisaddon.getResourceURI('content/icon16.png').spec);
|
||||
|
||||
var dest_html = OS.Path.join(fsRootPath, "manager.html");
|
||||
var dest_js = OS.Path.join(fsRootPath, "manager.js2");
|
||||
@@ -192,6 +193,7 @@ function browser_specific_init(){
|
||||
var dest_cross = OS.Path.join(fsRootPath, "cross.png");
|
||||
var dest_swalcss = OS.Path.join(fsRootPath, "sweetalert.css");
|
||||
var dest_swaljs = OS.Path.join(fsRootPath, "sweetalert.min.js2");
|
||||
var dest_icon = OS.Path.join(fsRootPath, "icon16.png");
|
||||
|
||||
OS.File.makeDir(fsRootPath, {ignoreExisting:true})
|
||||
.then(function(){
|
||||
@@ -214,6 +216,9 @@ function browser_specific_init(){
|
||||
})
|
||||
.then(function(){
|
||||
OS.File.copy(swaljs, dest_swaljs);
|
||||
})
|
||||
.then(function(){
|
||||
OS.File.copy(icon, dest_icon);
|
||||
});
|
||||
|
||||
init();
|
||||
@@ -629,13 +634,40 @@ function openTabs(sdir){
|
||||
.then(function(data){
|
||||
var name = ba2str(data);
|
||||
var data_path = OS.Path.join(fsRootPath, sdir, name);
|
||||
var dataFileURI = OS.Path.toFileURI(data_path);
|
||||
block_urls.push(data_path);
|
||||
var t = gBrowser.addTab(data_path);
|
||||
gBrowser.selectedTab = t;
|
||||
setTimeout(function(){
|
||||
|
||||
var readyListener = function(e){
|
||||
console.log('in readyListener');
|
||||
//may trigger prematurely when href is about:blank
|
||||
if (gBrowser.getBrowserForTab(e.target).contentWindow.location.href !== dataFileURI){
|
||||
return;
|
||||
}
|
||||
//t.removeEventListener('load', readyListener);
|
||||
viewTabDocument = gBrowser.getBrowserForTab(e.target).contentWindow.document;
|
||||
//even though .document is immediately available, its .body property may not be
|
||||
function wait_for_body(){
|
||||
if (viewTabDocument.body === null){
|
||||
console.log('body not available, waiting');
|
||||
setTimeout(function(){wait_for_body()}, 100);
|
||||
}
|
||||
else {
|
||||
console.log('viewTabDocument is ', viewTabDocument);
|
||||
console.log('body is ', viewTabDocument.body);
|
||||
install_bar();
|
||||
viewTabDocument.getElementById("domainName").textContent = commonName;
|
||||
viewTabDocument['pagesigner-session-dir'] = sdir;
|
||||
}
|
||||
};
|
||||
wait_for_body();
|
||||
};
|
||||
|
||||
gBrowser.getBrowserForTab(t).reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
|
||||
}, 500);
|
||||
install_notification(t, commonName, raw_path);
|
||||
t.addEventListener('load', readyListener);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
68
content/notification_bar.js
Normal file
68
content/notification_bar.js
Normal file
@@ -0,0 +1,68 @@
|
||||
var viewTabDocument;
|
||||
|
||||
function install_bar(){
|
||||
//when running from Firefox, the var gBrowser is available
|
||||
var using_chrome = typeof(gBrowser) === 'undefined';
|
||||
var using_firefox = typeof(gBrowser) !== 'undefined';
|
||||
var document = viewTabDocument;
|
||||
var table = document.createElement("table");
|
||||
table.style.position = "fixed";
|
||||
table.style.top = "0px";
|
||||
table.style.left = "100px";
|
||||
table.style.background = "rgba(242, 241, 240, 0.9)";
|
||||
table.style.width = "80%";
|
||||
table.style.height = "32px";
|
||||
table.style.visibility = 'hidden';
|
||||
table.style.opacity = '0';
|
||||
table.style.webkitTransition = 'visibility 0s 2s, opacity 2s linear';
|
||||
table.style.transition = 'visibility 0s 2s, opacity 2s linear';
|
||||
var row = document.createElement("tr");
|
||||
var cell1 = document.createElement("td");
|
||||
var cell2 = document.createElement("td");
|
||||
var cell3 = document.createElement("td");
|
||||
cell3.style.align = "right";
|
||||
var img = document.createElement("img");
|
||||
img.src = using_chrome ? "icon16.png" : "../icon16.png";
|
||||
var text = document.createElement("text");
|
||||
text.textContent = "PageSigner verified that this page was received from ";
|
||||
var domain = document.createElement("text");
|
||||
domain.id = "domainName";
|
||||
var sdir = document.createElement("text");
|
||||
sdir.id = "sdir";
|
||||
var button = document.createElement("button");
|
||||
button.id = "viewRaw";
|
||||
button.textContent = "View raw data with HTTP headers";
|
||||
button.style.MozBorderRadius = "4px";
|
||||
button.style.WebkitBorderRadius = "4px";
|
||||
button.style.borderRadius = "4px";
|
||||
button.onclick = function(){
|
||||
var dir = document['pagesigner-session-dir'];
|
||||
if (using_chrome){
|
||||
chrome.runtime.sendMessage({destination:'extension', message:'viewraw', args:{dir:dir}});
|
||||
}
|
||||
else if (using_firefox){
|
||||
var path = OS.Path.join(fsRootPath, dir, 'raw.txt');
|
||||
gBrowser.selectedTab = gBrowser.addTab(path);
|
||||
}
|
||||
};
|
||||
cell3.appendChild(button)
|
||||
cell2.appendChild(text);
|
||||
cell2.appendChild(domain);
|
||||
cell1.appendChild(img);
|
||||
row.appendChild(cell1);
|
||||
row.appendChild(cell2);
|
||||
row.appendChild(cell3);
|
||||
table.appendChild(row);
|
||||
table.appendChild(sdir);
|
||||
document.body.appendChild(table);
|
||||
document['pagesigner-session-dir'] = sdir;
|
||||
|
||||
setTimeout(function(){
|
||||
//make a transition to visible
|
||||
table.style.visibility = 'visible';
|
||||
table.style.opacity = '1';
|
||||
table.style.webkitTransition = 'opacity 2s linear';
|
||||
table.style.transition = 'opacity 2s linear';
|
||||
}, 0);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user