-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4,353 changed files
with
1,184,519 additions
and
20,377 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { HTMLRewriter } from 'https://ghuc.cc/worker-tools/html-rewriter/index.ts'; | ||
|
||
export default async (request, context) => { | ||
const response = await context.next(); | ||
const hasGdpr = new Set([ | ||
'AT', | ||
'BE', | ||
'BG', | ||
'HR', | ||
'CY', | ||
'CZ', | ||
'DK', | ||
'EE', | ||
'FI', | ||
'FR', | ||
'DE', | ||
'GR', | ||
'HU', | ||
'IE', | ||
'IT', | ||
'LV', | ||
'LT', | ||
'LU', | ||
'MT', | ||
'NL', | ||
'PL', | ||
'PT', | ||
'RO', | ||
'SK', | ||
'SI', | ||
'ES', | ||
'SE', | ||
]).has(context.geo.country.code); | ||
|
||
if (hasGdpr) { | ||
return new HTMLRewriter() | ||
.on('script', { | ||
element(element) { | ||
const scriptSrc = element.getAttribute('src'); | ||
if ( | ||
typeof scriptSrc === 'string' && | ||
scriptSrc.startsWith('https://cmp.osano.com/') | ||
) { | ||
element.setAttribute( | ||
'src', | ||
scriptSrc.replace(/variant=one/gi, 'variant=two') | ||
); | ||
} | ||
}, | ||
}) | ||
.transform(response); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.