1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-02 02:14:52 +12:00

minor code review

This commit is contained in:
gorhill 2017-12-09 10:45:37 -05:00
parent 1e9f728a3b
commit ff5789d4ac
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 9 additions and 8 deletions

View file

@ -67,7 +67,6 @@ vAPI.contentscriptEndInjected = true;
if ( mustRemove ) {
window.localStorage.clear();
window.sessionStorage.clear();
// console.debug('HTTP Switchboard > found and removed non-empty localStorage');
}
};
@ -76,12 +75,14 @@ vAPI.contentscriptEndInjected = true;
// to site data is disabled.
// https://github.com/gorhill/httpswitchboard/issues/215
try {
var hasLocalStorage = window.localStorage && window.localStorage.length;
var hasSessionStorage = window.sessionStorage && window.sessionStorage.length;
var hasLocalStorage =
window.localStorage && window.localStorage.length !== 0;
var hasSessionStorage =
window.sessionStorage && window.sessionStorage.length !== 0;
if ( hasLocalStorage || hasSessionStorage ) {
vAPI.messaging.send('contentscript.js', {
what: 'contentScriptHasLocalStorage',
url: window.location.href
originURL: window.location.origin
}, localStorageHandler);
}

View file

@ -426,19 +426,19 @@ var contentScriptSummaryHandler = function(tabId, details) {
/******************************************************************************/
var contentScriptLocalStorageHandler = function(tabId, pageURL) {
var contentScriptLocalStorageHandler = function(tabId, originURL) {
var tabContext = µm.tabContextManager.lookup(tabId);
if ( tabContext === null ) { return; }
var blocked = µm.mustBlock(
tabContext.rootHostname,
µm.URI.hostnameFromURI(pageURL),
µm.URI.hostnameFromURI(originURL),
'cookie'
);
var pageStore = µm.pageStoreFromTabId(tabId);
if ( pageStore !== null ) {
var requestURL = µm.URI.originFromURI(pageURL) + '/{localStorage}';
var requestURL = originURL + '/{localStorage}';
pageStore.recordRequest('cookie', requestURL, blocked);
µm.logger.writeOne(tabId, 'net', tabContext.rootHostname, requestURL, 'cookie', blocked);
}
@ -520,7 +520,7 @@ var onMessage = function(request, sender, callback) {
switch ( request.what ) {
case 'contentScriptHasLocalStorage':
response = contentScriptLocalStorageHandler(tabId, request.url);
response = contentScriptLocalStorageHandler(tabId, request.originURL);
break;
case 'contentScriptSummary':