Skip to content

Instantly share code, notes, and snippets.

@jsEveryDay
Last active November 18, 2020 15:10
Show Gist options
  • Save jsEveryDay/38e1994d772d3aac5b697cd6627b5ade to your computer and use it in GitHub Desktop.
Save jsEveryDay/38e1994d772d3aac5b697cd6627b5ade to your computer and use it in GitHub Desktop.
Overwrite Google Analytics
function random() {
return Math.floor(Math.random() * (9 - 2) + 2);
}
function fukWithGogle(cookie, domain) {
let ga = cookie.split('.')
ga[3] = (parseInt(ga[3]) + random()).toString()
ga[2] = (parseInt(ga[2]) + random()).toString()
ga = ga.join('.');
const newCookie = {
url: 'http://' + domain.slice(1),
domain: domain,
name: '_ga',
value: ga
};
return newCookie;
};
chrome.cookies.getAll(
{
name: '_ga',
session: false
},
v => {
v.forEach(e => {
console.log(e.domain + ' ' + e.domain)
const newCookie = fukWithGogle(e.value, e.domain);
chrome.cookies.set(newCookie, c => {
if (!c) {
console.log('Error: ' + e.domain);
} else {
console.log('done');
}
});
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment