My extension has been successfully modifying some URLs. However, I now need to determine whether the modification feature is enabled in the settings.
chrome.webRequest.onBeforeRequest.addListener
(
modifyUrl,
{urls: ['http://somewebsite/*'], types: ['main_frame']},
['blocking']
);
The challenge lies in finding a way to wait for the value of the setting within the modifyUrl
function before proceeding. Is there a method to achieve this? In languages like C#, I would have utilized something like ManualResetEvent
after making the sync.get
call.
function modifyUrl(details)
{
chrome.storage.sync.get("someSetting",
function (data)
{
//I can access the setting here
}
);
//how can I check the setting at this point?
if(enabled in the setting)
{
return {redirectUrl: some different url};
}
}