diff --git a/src/background.js b/src/background.js index ecbee027..2c64c7c7 100644 --- a/src/background.js +++ b/src/background.js @@ -136,6 +136,32 @@ chrome.contextMenus.onClicked.addListener(function (info, tab) { } }); +function messageCurrentTab(command, data) { + chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { + var tabId = null; + if (tabs.length > 0) { + tabId = tabs[0].id; + } + else { + return; + } + + if (!tabId) { + return; + } + + var obj = { + command: command + }; + + if (data) { + obj['data'] = data; + } + + chrome.tabs.sendMessage(tabId, obj); + }); +} + function autofillPage(site) { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { var tabId = null; diff --git a/src/content/overlay.js b/src/content/overlay.js new file mode 100644 index 00000000..caa590e2 --- /dev/null +++ b/src/content/overlay.js @@ -0,0 +1,34 @@ +!(function () { + chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { + if (msg.command === 'openOverlayPopup') { + openPopup(msg.data); + sendResponse(); + return true; + } + else if (msg.command === 'closeOverlayPopup') { + closePopup(); + sendResponse(); + return true; + } + }); + + function openPopup(data) { + var left = 0, + top = 0; + + if (data && data.position) { + left = data.position.left || 0; + top = data.position.top || 0; + } + + var iframe = document.createElement('iframe'); + iframe.src = chrome.extension.getURL('overlay/popup.html'); + iframe.style.cssText = 'height: 200px; width: 250px; border: 2px solid #000;; position: absolute; visibility: visible; left: ' + left + '; top: ' + top + '; z-index: 999999999;'; + iframe.id = 'bit-overlay-popup'; + document.body.insertBefore(iframe, document.body.lastChild); + } + + function closePopup() { + document.getElementById('bit-overlay-popup').remove(); + } +})(); diff --git a/src/manifest.json b/src/manifest.json index a8b3a54a..74b09124 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -16,6 +16,11 @@ "js": [ "content/autoFill.js" ], "matches": [ "http://*/*", "https://*/*", "file:///*" ], "run_at": "document_start" + }, + { + "js": [ "content/overlay.js" ], + "matches": [ "http://*/*", "https://*/*", "file:///*" ], + "run_at": "document_start" } ], "background": { @@ -62,5 +67,8 @@ "webRequestBlocking", "http://*/*", "https://*/*" + ], + "web_accessible_resources": [ + "overlay/popup.html" ] } \ No newline at end of file diff --git a/src/overlay/popup.html b/src/overlay/popup.html new file mode 100644 index 00000000..506ca82c --- /dev/null +++ b/src/overlay/popup.html @@ -0,0 +1,10 @@ + + + + + + + + This is the popup!!! + +