Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
apply brave UA whitelist to first-party subresources
Browse files Browse the repository at this point in the history
fix #10800

Test Plan:
load adobe.com within Brave
open the developer tools via "option + command + I"
select the "Network" tab and reload adobe.com via "command + r"
select on the first resource and you'll notice the correct Brave Chrome/60.0.3112.101 UA
select another resource that's underneath the first one and is from Host:www.adobe.com
the Brave UA should be there
  • Loading branch information
diracdeltas committed Sep 11, 2017
1 parent 59d1627 commit e166b26
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/siteHacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ module.exports.init = () => {
}

Filtering.registerBeforeSendHeadersFilteringCB((details, isPrivate) => {
if (details.resourceType !== 'mainFrame') {
const mainFrameUrl = Filtering.getMainFrameUrl(details)
if (!mainFrameUrl) {
return {
resourceName
}
}

// This filter only applies to top-level requests, so details.url == mainFrameUrl
let domain = urlParse(details.url).hostname.split('.').slice(-2).join('.')
let hack = siteHacks[domain]
const domain = urlParse(mainFrameUrl).hostname.split('.').slice(-2).join('.')
const hack = siteHacks[domain]
let customCookie
let requestHeaders
let cancel
if (hack && hack.onBeforeSendHeaders) {
if (hack && hack.onBeforeSendHeaders &&
domain === urlParse(details.url).hostname.split('.').slice(-2).join('.')) {
const result = hack.onBeforeSendHeaders.call(this, details)
if (result) {
customCookie = result.customCookie
Expand Down

0 comments on commit e166b26

Please sign in to comment.