Created
July 31, 2024 14:33
-
-
Save moeriki/335689d4eacb2cd500c564f6b231bd2b to your computer and use it in GitHub Desktop.
Global Pollution
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
<script> | |
const PROPERTIES = [ | |
// { names: ['$', 'jQuery'], getVersion: (value) => value().jquery }, | |
{ names: ['_'], getVersion: (value) => value.version }, | |
]; | |
for (let { names, getVersion } of PROPERTIES) { | |
for (let name of names) { | |
let scopedValue; | |
Reflect.defineProperty(globalThis, name, { | |
configurable: true, | |
enumerable: true, | |
// writable: true, | |
// value: undefined, | |
get: () => scopedValue, | |
set(value) { | |
console.warn(`GTP::set ${name}`, value); | |
debugger; | |
scopedValue = value; | |
}, | |
}); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment