Skip to content

Instantly share code, notes, and snippets.

@bobsilverberg
Last active July 4, 2016 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobsilverberg/3df985bec01f3f2872f230be8621b0ff to your computer and use it in GitHub Desktop.
Save bobsilverberg/3df985bec01f3f2872f230be8621b0ff to your computer and use it in GitHub Desktop.
// Handle FEAT test requests from a companion extension
var communicate = require("communicate");
chrome.extension.onMessageExternal.addListener(
function (req, sender, sendResponse) {
'use strict';
if (req.type !== "Automation") {
return;
}
// our white-listed FEAT extension
if (sender.id !== "bngnhmnppadfcmpggglniifohlkmddfc") {
return;
}
chrome.tabs.sendMessage(
communicate.activeTab(),
{
panel_op : "test",
test_extension : 'to_html',
outputPath : req.path
}
);
}
);
function ExternalMessaging() {
function a(a) {
d = a
}
function b() {
if (!SAFARI) {
var a = function (a, b, e) {
return b && -1 !== c.indexOf(b.id) ? (a.name && d[a.name] && d[a.name](a, b, e), e ? !0 : void 0) : void log.warn("Got ExternalMessaging request from unexpected sender " + b.id)
};
chrome.runtime.onMessageExternal.addListener(a)
}
}
var c = ["aclkapcoggpdiggeimkkckamndpdcfeb", "ncnnnfnlpehkpkgfcggbkdogjgmihimk"], d = {};
this.setMessageHandlers = a, Object.preventExtensions(this), b()
}
}, O = function (a, b, c) {
if ("false" === p.allowCrossExtensionHistory || "false" === p.storeHistory || !a || !a.getHistory)return !1;
chrome.storage.local.get("word-history", function (a) {
c(a["word-history"])
});
return !0
},
...
}, Q = function () {
var a = window.localStorage.options, b = {};
a && (b = JSON.parse(a));
p = N(b);
window.localStorage.options = JSON.stringify(p);
chrome.storage.local.get("word-history", function (a) {
a["word-history"] || chrome.storage.local.set({"word-history": {}})
});
chrome.runtime.onMessage.addListener(A);
chrome.runtime.onMessage.addListener(B);
chrome.runtime.onMessage.addListener(C);
chrome.runtime.onMessage.addListener(G);
chrome.runtime.onMessageExternal.addListener(O)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment