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

Commit

Permalink
Merge pull request #258 from gorhill/experimental
Browse files Browse the repository at this point in the history
Hide web accessible resources from websites
  • Loading branch information
Synzvato authored May 14, 2018
2 parents 4c82625 + e6a5de1 commit 1a7f41e
Showing 1 changed file with 20 additions and 1 deletion.
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]
);

0 comments on commit 1a7f41e

Please sign in to comment.