You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
777 B
JavaScript
28 lines
777 B
JavaScript
// abstraction layer for Chrome Extension APIs
|
|
panelApp.value('chromeExtension', {
|
|
sendRequest: function (requestName, cb) {
|
|
chrome.extension.sendRequest({
|
|
script: requestName,
|
|
tab: chrome.devtools.inspectedWindow.tabId
|
|
}, cb || function () {});
|
|
},
|
|
|
|
// evaluates in the context of a window
|
|
//written because I don't like the API for chrome.devtools.inspectedWindow.eval;
|
|
// passing strings instead of functions are gross.
|
|
eval: function (fn, args, cb) {
|
|
// with two args
|
|
if (!cb && typeof args === 'function') {
|
|
cb = args;
|
|
args = {};
|
|
} else if (!args) {
|
|
args = {};
|
|
}
|
|
chrome.devtools.inspectedWindow.eval('(' +
|
|
fn.toString() +
|
|
'(window, ' +
|
|
JSON.stringify(args) +
|
|
'));', cb);
|
|
}
|
|
});
|