Skip to content
This repository has been archived by the owner on Jun 8, 2018. It is now read-only.

Hide web accessible resources from websites #258

Merged
merged 1 commit into from
May 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion core/interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ interceptor._handleMissingCandidate = function (requestUrl) {
requestUrl = requestUrlSegments.toString();

return {
'redirectUrl': requestUrl
'redirectUrl': requestUrl + interceptor.warSecret
};

} else {
Expand Down Expand Up @@ -147,3 +147,22 @@ chrome.storage.local.get([Setting.AMOUNT_INJECTED, Setting.BLOCK_MISSING], funct
*/

chrome.storage.onChanged.addListener(interceptor._handleStorageChanged);

/**
* Guard web accessible resources from direct access by web pages
*/

interceptor.warSecret = '?_=' +
Math.floor(Math.random() * 982451653 + 982451653).toString(36) +
Math.floor(Math.random() * 982451653 + 982451653).toString(36);

chrome.webRequest.onBeforeRequest.addListener(
function(requestDetails) {

if (!requestDetails.url.endsWith(interceptor.warSecret)) {
return { redirectUrl: chrome.runtime.getURL('/') };
}
},
{'urls': [chrome.runtime.getURL('/') + 'resources/*']},
[WebRequest.BLOCKING]
);