diff --git a/core/constants.js b/core/constants.js index 9cccaa75..a80959e3 100644 --- a/core/constants.js +++ b/core/constants.js @@ -446,6 +446,7 @@ const LogString = { 'MISSING_RESOURCE': 'Missing resource:', 'EVIL_RESOURCE_BLOCKED': 'Evil resource blocked:', 'NON_GET_REQUEST_BLOCKED': 'Non-GET-Request blocked', + 'IFRAME': 'Possible iframe request:', }; // Supported charsets for TextDecoder() diff --git a/core/interceptor.js b/core/interceptor.js index 4fbf4c7d..a9671908 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -31,7 +31,14 @@ var interceptor = {}; */ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { - let validCandidate, targetDetails, targetDomain, isGoogleFont, isGoogleMaterialIcons, initiatorDomain, isListed; + let validCandidate, targetDetails, targetDomain, isGoogleFont, isGoogleMaterialIcons, initiatorDomain, isListed, + iframe; + + iframe = ''; + if (tab.url !== requestDetails.originUrl) { + console.log(`${LogString.PREFIX} ${LogString.IFRAME} ${tab.url} -> ${requestDetails.originUrl}`); + iframe = requestDetails.originUrl; + } if (requestDetails['type'] === WebRequestType.MAIN_FRAME && helpers.checkAllowlisted( @@ -57,7 +64,7 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { // Block POST, HEAD, PUT, DELETE, TRACE, OPTIONS if (BlockedRequestMethods[requestDetails.method]) { console.warn(`${LogString.PREFIX} ${LogString.NON_GET_REQUEST_BLOCKED}`); - log.append(tab.url, requestDetails.url, LogString.NON_GET_REQUEST_BLOCKED, true); + log.append(tab.url, requestDetails.url, LogString.NON_GET_REQUEST_BLOCKED, true, iframe); return { 'cancel': true }; @@ -72,7 +79,7 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { if (interceptor._isBadResource(requestDetails.url)) { console.log(`${LogString.PREFIX} ${LogString.EVIL_RESOURCE_BLOCKED} ${requestDetails.url}`); - log.append(tab.url, requestDetails.url, '-', true); + log.append(tab.url, requestDetails.url, '-', true, iframe); return { 'cancel': true }; @@ -105,7 +112,7 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { } console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${targetDetails.path}`); - log.append(tab.url, requestDetails.url, targetDetails.path, false); + log.append(tab.url, requestDetails.url, targetDetails.path, false, iframe); return { 'redirectUrl': chrome.runtime.getURL(targetDetails.path + fileGuard.secret) diff --git a/modules/internal/log.js b/modules/internal/log.js index bf946f80..d821f54e 100644 --- a/modules/internal/log.js +++ b/modules/internal/log.js @@ -21,10 +21,10 @@ var log = {}; -log.append = function (initiator, resource, target, highlight) { +log.append = function (initiator, resource, target, highlight, iframe = '') { storageManager.type.get(Setting.LOGGING, function (items) { if (items.enableLogging) { - log.data.push({initiator, resource, target, highlight}); + log.data.push({initiator, resource, target, highlight, iframe}); } }); }; diff --git a/pages/logging/logging.css b/pages/logging/logging.css index 960318af..b6218fc4 100644 --- a/pages/logging/logging.css +++ b/pages/logging/logging.css @@ -24,6 +24,7 @@ table td:first-child { td { padding: 2px 15px; + white-space: pre; } textarea { diff --git a/pages/logging/logging.html b/pages/logging/logging.html index 5e77b2bf..25dd8211 100644 --- a/pages/logging/logging.html +++ b/pages/logging/logging.html @@ -38,6 +38,12 @@ +
+

+ Legend +
+ (i) = A website includes this iframe. It's possible that the request is from there. +

diff --git a/pages/logging/logging.js b/pages/logging/logging.js index c127dbfa..6ac58210 100644 --- a/pages/logging/logging.js +++ b/pages/logging/logging.js @@ -40,7 +40,7 @@ logging._generateTable = function () { } for (let i = data.length - 1; i >= 0; i--) { - let tbody, row, cell, content, redirect; + let tbody, row, cell, content, redirect, initiator; tbody = document.getElementById('logging-content').getElementsByTagName('tbody')[0]; row = tbody.insertRow(); @@ -53,8 +53,14 @@ logging._generateTable = function () { content = document.createTextNode(i + 1); cell.appendChild(content); + if (Object.values(data[i])[4] === '') { + initiator = Object.values(data[i])[0]; + } else { + initiator = `${Object.values(data[i])[0]}\n(i) ${Object.values(data[i])[4]}`; + } + cell = row.insertCell(); - content = document.createTextNode(Object.values(data[i])[0]); + content = document.createTextNode(initiator); cell.appendChild(content); cell = row.insertCell(); diff --git a/pages/updates/updates.html b/pages/updates/updates.html index 79ccbc63..0247dacc 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -53,6 +53,7 @@

Improved