stubbing out some overlay framework
This commit is contained in:
parent
b2eb7910ee
commit
714328d13a
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
})();
|
|
@ -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"
|
||||
]
|
||||
}
|
|
@ -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>
|
Loading…
Reference in New Issue