stubbing out some overlay framework

This commit is contained in:
Kyle Spearrin 2016-09-21 23:41:53 -04:00
parent b2eb7910ee
commit 714328d13a
4 changed files with 78 additions and 0 deletions

View File

@ -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) { function autofillPage(site) {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var tabId = null; var tabId = null;

34
src/content/overlay.js Normal file
View File

@ -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();
}
})();

View File

@ -16,6 +16,11 @@
"js": [ "content/autoFill.js" ], "js": [ "content/autoFill.js" ],
"matches": [ "http://*/*", "https://*/*", "file:///*" ], "matches": [ "http://*/*", "https://*/*", "file:///*" ],
"run_at": "document_start" "run_at": "document_start"
},
{
"js": [ "content/overlay.js" ],
"matches": [ "http://*/*", "https://*/*", "file:///*" ],
"run_at": "document_start"
} }
], ],
"background": { "background": {
@ -62,5 +67,8 @@
"webRequestBlocking", "webRequestBlocking",
"http://*/*", "http://*/*",
"https://*/*" "https://*/*"
],
"web_accessible_resources": [
"overlay/popup.html"
] ]
} }

10
src/overlay/popup.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body style="background-color: white;">
This is the popup!!!
</body>
</html>