From 54e8867ce7a4c9b397d36463526ff27222ccb82f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 29 Dec 2016 18:35:41 -0500 Subject: [PATCH] notification bar context script/page --- src/background.js | 6 +++ src/content/notificationBar.js | 44 ++++++++++++++++++++ src/manifest.json | 9 +++- src/notification/bar.html | 76 ++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 src/content/notificationBar.js create mode 100644 src/notification/bar.html diff --git a/src/background.js b/src/background.js index 5d45e0023d..573ed40054 100644 --- a/src/background.js +++ b/src/background.js @@ -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 }); diff --git a/src/content/notificationBar.js b/src/content/notificationBar.js new file mode 100644 index 0000000000..f518893c6e --- /dev/null +++ b/src/content/notificationBar.js @@ -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); + } + } +})(); diff --git a/src/manifest.json b/src/manifest.json index 445eae2de1..ea319f9cb6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -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" ] } \ No newline at end of file diff --git a/src/notification/bar.html b/src/notification/bar.html new file mode 100644 index 0000000000..feefa448bd --- /dev/null +++ b/src/notification/bar.html @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + +
+ + + This is the notification bar + + + X + +
+ +