mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-15 21:55:36 +07:00
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:
24
core_js/message_handler.js
Normal file
24
core_js/message_handler.js
Normal 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);
|
||||
Reference in New Issue
Block a user