mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2024-12-22 16:12:13 +01:00
Fetch or save domain into extension storage (#1)
This commit is contained in:
parent
c7bf456a06
commit
652150d70c
@ -61,6 +61,32 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
|
||||
|
||||
return MessageResponse.ASYNCHRONOUS;
|
||||
}
|
||||
|
||||
if (topic === 'domain:fetch-is-manipulateDOM') {
|
||||
|
||||
let manipulateDOMRecord = requestAnalyzer.domainsManipulateDOMlist[value];
|
||||
sendResponse({'value': Boolean(manipulateDOMRecord)});
|
||||
|
||||
return MessageResponse.SYNCHRONOUS;
|
||||
}
|
||||
|
||||
if (topic === 'manipulateDOM:add-domain') {
|
||||
|
||||
stateManager.addDomainToManipulateDOMlist(value).then(function () {
|
||||
sendResponse({'value': true});
|
||||
});
|
||||
|
||||
return MessageResponse.ASYNCHRONOUS;
|
||||
}
|
||||
|
||||
if (topic === 'manipulateDOM:remove-domain') {
|
||||
|
||||
stateManager.removeDomainFromManipulateDOMlist(value).then(function () {
|
||||
sendResponse({'value': true});
|
||||
});
|
||||
|
||||
return MessageResponse.ASYNCHRONOUS;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -172,6 +172,12 @@ requestAnalyzer._applyWhitelistedDomains = function () {
|
||||
requestAnalyzer.whitelistedDomains = items.whitelistedDomains || {};
|
||||
});
|
||||
};
|
||||
requestAnalyzer._applyManipulateDOMDomains = function () {
|
||||
|
||||
chrome.storage.local.get(Setting.DOMAINS_MANIPULATE_DOM, function (items) {
|
||||
requestAnalyzer.manipulateDOMDomains = items.manipulateDOMDomains || {};
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializations
|
||||
@ -180,8 +186,11 @@ requestAnalyzer._applyWhitelistedDomains = function () {
|
||||
requestAnalyzer.whitelistedDomains = {};
|
||||
requestAnalyzer._applyWhitelistedDomains();
|
||||
|
||||
requestAnalyzer.domainsManipulateDOMlist = {};
|
||||
requestAnalyzer._applyManipulateDOMDomains();
|
||||
/**
|
||||
* Event Handlers
|
||||
*/
|
||||
|
||||
chrome.storage.onChanged.addListener(requestAnalyzer._applyWhitelistedDomains);
|
||||
chrome.storage.onChanged.addListener(requestAnalyzer._applyManipulateDOMDomains);
|
||||
|
@ -135,6 +135,29 @@ stateManager.removeDomainFromWhitelist = function (domain) {
|
||||
});
|
||||
};
|
||||
|
||||
stateManager.addDomainToManipulateDOMlist = function (domain) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
||||
let domainsManipulateDOM = requestAnalyzer.domainsManipulateDOMlist;
|
||||
domainsManipulateDOM[domain] = true;
|
||||
|
||||
chrome.storage.local.set({domainsManipulateDOM}, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
stateManager.removeDomainFromManipulateDOMlist = function (domain) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
||||
let domainsManipulateDOM = requestAnalyzer.domainsManipulateDOMlist;
|
||||
delete domainsManipulateDOM[domain];
|
||||
|
||||
chrome.storage.local.set({domainsManipulateDOM}, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Private Methods
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user