Last active
November 18, 2020 15:10
-
-
Save jsEveryDay/38e1994d772d3aac5b697cd6627b5ade to your computer and use it in GitHub Desktop.
Overwrite Google Analytics
This file contains hidden or 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
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