mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
notification bar context script/page
This commit is contained in:
parent
3b78c0c3ed
commit
54e8867ce7
@ -55,6 +55,12 @@ chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||
else if (msg.command === 'bgCloseOverlayPopup') {
|
||||
messageCurrentTab('closeOverlayPopup');
|
||||
}
|
||||
else if (msg.command === 'bgOpenNotificationBar') {
|
||||
messageCurrentTab('openNotificationBar');
|
||||
}
|
||||
else if (msg.command === 'bgCloseNotificationBar') {
|
||||
messageCurrentTab('closeNotificationBar');
|
||||
}
|
||||
else if (msg.command === 'collectPageDetailsResponse') {
|
||||
clearTimeout(autofillTimeout);
|
||||
pageDetailsToAutoFill.push({ frameId: sender.frameId, tabId: msg.tabId, details: msg.details });
|
||||
|
44
src/content/notificationBar.js
Normal file
44
src/content/notificationBar.js
Normal 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);
|
||||
}
|
||||
}
|
||||
})();
|
@ -20,6 +20,12 @@
|
||||
"js": [ "content/autofill.js" ],
|
||||
"matches": [ "http://*/*", "https://*/*", "file:///*" ],
|
||||
"run_at": "document_start"
|
||||
},
|
||||
{
|
||||
"all_frames": false,
|
||||
"js": [ "content/notificationBar.js" ],
|
||||
"matches": [ "http://*/*", "https://*/*", "file:///*" ],
|
||||
"run_at": "document_start"
|
||||
}
|
||||
],
|
||||
"background": {
|
||||
@ -82,6 +88,7 @@
|
||||
}
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
"overlay/popup.html"
|
||||
"overlay/popup.html",
|
||||
"notification/bar.html"
|
||||
]
|
||||
}
|
76
src/notification/bar.html
Normal file
76
src/notification/bar.html
Normal file
@ -0,0 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta charset="utf-8" />
|
||||
<style>
|
||||
body {
|
||||
background-color: #ffffff;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
color: #333333;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table td {
|
||||
height: 40px;
|
||||
padding: 0 0 0 10px;
|
||||
border-bottom: 1px solid #333333;
|
||||
}
|
||||
|
||||
table td:last-child {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#logo {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#content {
|
||||
}
|
||||
|
||||
#close {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
!(function () {
|
||||
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="24">
|
||||
<img id="logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAclBMVEUAAAAzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzOkbymMAAAAJXRSTlMAAQIICQsMGBkaKkJYWWl0dXeMjpWXm6WmtcXM0dPr7fH3+fv9KIjKuwAAAIRJREFUKM/dzUkCgkAMBdHfCArOIypBW4S6/xVdNCqDJ7BWSd4iknKG5ZIkMW4AdzMzs+cI1mG3f4N6ADfqMJR9cFAG2PVhDtsAWQ8igyyAzl3Yw6W9K/YfcAfw8RuUVS1MrlCl+pZ6gM3iAX6mbknR/ikS9XOrBmiWTqOmR05T/SzqLi/Z3CbrA3nnNwAAAABJRU5ErkJggg==" />
|
||||
</td>
|
||||
<td id="content">
|
||||
This is the notification bar
|
||||
</td>
|
||||
<td align="right" width="18">
|
||||
<a href="#" title="Close">
|
||||
<img id="close" alt="X" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAWlBMVEUAAAAzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMHgWvyAAAAHXRSTlMAAgMFCA4RLTE0NVlrbG97naCotbe5z+Lk5ujr/TBmF6UAAAB+SURBVBhXXc7JEsJQCETRm3l2ikZj0v//my7ol0rJBjhFAUB+X2oimnUEyF/SFtZKugKzZGslSSOlZAvRCpNtiKwGuLiOaOHPQs6WBB6W4ZA+Dfm/kxx2Elvnxvu2mmKPsk93F7K3Jf1yg+prCXtmQPXZO9+eNGcAZIUFSuAHidYU7gWlVOAAAAAASUVORK5CYII=" />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user