Skip to content

Instantly share code, notes, and snippets.

@chrispage1
Created May 15, 2026 08:22
Show Gist options
  • Select an option

  • Save chrispage1/cee0b0beb73cedd7fce1633e466cb9d5 to your computer and use it in GitHub Desktop.

Select an option

Save chrispage1/cee0b0beb73cedd7fce1633e466cb9d5 to your computer and use it in GitHub Desktop.
Test Geolocation and OneTrust spoofing

Injecting script

On Google Chrome network tab within Inspector, once the page has loaded, right click and choose 'Override content'.

Inject the above code within <script></script> tags into the header.

From the sources tab, this page can now be manipulated and the script updated as necessary.

const gpcEnabled = false;
const stateCode = 'MD';
const countryCode = 'US';
Object.defineProperty(navigator, 'globalPrivacyControl', {
get: () => gpcEnabled,
set: () => {}
});
window.OneTrust = {
geolocationResponse: {
stateCode: stateCode,
countryCode: countryCode
}
};
console.log("OneTrust Spoof Active", 'GPC Enabled: ' + (gpcEnabled ? 'Yes' : 'No'), 'State Code: ' + stateCode, 'Country Code: ' + countryCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment