1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00

notification bar context script/page

This commit is contained in:
Kyle Spearrin
2016-12-29 18:35:41 -05:00
parent 3b78c0c3ed
commit 54e8867ce7
4 changed files with 134 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
!(function () {
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.command === 'openNotificationBar') {
closeBar();
openBar();
sendResponse();
return true;
}
else if (msg.command === 'closeNotificationBar') {
closeBar();
sendResponse();
return true;
}
});
function openBar() {
var iframe = document.createElement('iframe');
iframe.src = chrome.extension.getURL('notification/bar.html');
iframe.style.cssText = 'height: 41px; width: 100%; border: 0;';
var frameDiv = document.createElement('div');
frameDiv.id = 'bit-notification-bar';
frameDiv.style.cssText = 'height: 41px; width: 100%; top: 0; left: 0; padding: 0; position: fixed; z-index: 1000000099; visibility: visible;';
frameDiv.appendChild(iframe);
document.body.appendChild(frameDiv);
var spacer = document.createElement('div');
spacer.id = 'bit-notification-bar-spacer';
spacer.style.cssText = 'height: 41px;';
document.body.insertBefore(spacer, document.body.firstChild);
}
function closeBar() {
var el = document.getElementById('bit-notification-bar');
if (el) {
el.parentElement.removeChild(el);
}
el = document.getElementById('bit-notification-bar-spacer');
if (el) {
el.parentElement.removeChild(el);
}
}
})();