Last active
November 21, 2018 12:56
-
-
Save cmbuckley/855ef9b7a202472ad77ca289afa71744 to your computer and use it in GitHub Desktop.
JavaScript Cookie Trapper
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
// Use to detect calls to document.cookie="xxx" | |
(function (){ | |
var s = document.__lookupSetter__('cookie').bind(document), | |
g = document.__lookupGetter__('cookie').bind(document); | |
Object.defineProperty(document, 'cookie', { | |
get() { | |
return g(); | |
}, | |
set(n) { | |
console.error('Setting cookie:', n); | |
s(n); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment