storage improvement

The command pattern has been implemented so that ClearURLs also works in private mode.
See also: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage
This commit is contained in:
Kevin Röbert
2019-02-13 18:02:08 +01:00
parent 03cdcbb38a
commit 81bc71de5e
9 changed files with 687 additions and 469 deletions

View File

@@ -0,0 +1,24 @@
/*jshint esversion: 6 */
/*
* This script is responsible for the communication between background and content_scripts.
*/
/**
* [handleMessage description]
* @param request The message itself. This is a JSON-ifiable object.
* @param sender A runtime.MessageSender object representing the sender of the message.
* @param sendResponse A function to call, at most once, to send a response to the message. The function takes a single argument, which may be any JSON-ifiable object. This argument is passed back to the message sender.
*/
function handleMessage(request, sender, sendResponse)
{
var fn = window[request.function];
if(typeof fn === "function")
{
var response = fn.apply(null, request.params);
sendResponse({response});
}
}
browser.runtime.onMessage.addListener(handleMessage);