Avoid global scope conflicts and rewrites
Background
As discussed in https://gitlab.com/eyeo/adblockplus/adblockpluscore/merge_requests/145, we are currently placing our snippets on the global scope, causing the following potential issues:
- we overwrite our own snippets each time
- we potentially obscure otherwise globally available variables, such as
trace
,log
, or any other snippet function name - we are incapable of securing within a closure our own code
- we indirectly setup the execution context as
strict
What to change
Makes the injection based on a single closure, so that all pain points will be gone in a single shot, and no script can detect our snippets landing on the global scope.
Edited by Andrea Giammarchi