Last active
November 6, 2019 08:55
-
-
Save mozfreddyb/a096627cc6b2e565a4c2 to your computer and use it in GitHub Desktop.
inspect assignments to innerHTML
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
/* inject via | |
ppmm.loadFrameScript("data:,<js source>", true); | |
(where ppmm is the message manager, e.g. in shell.js) | |
framescript documentation explains why this works[1] and | |
the message manager docs[2] explain that the parent process | |
manager defined as ppmm in shell.js[3] can be used. | |
[1] https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Frame_script_loading_and_lifetime | |
[2] https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview | |
[3] https://dxr.mozilla.org/mozilla-central/source/b2g/chrome/content/shell.js | |
*/ | |
(function () { | |
var setter = Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML').set; | |
Object.defineProperty(Element.prototype, 'innerHTML', { | |
set: function innerHTML_Setter(val) { | |
console.group(); | |
console.log('innerHTML on Object:', this, ); | |
console.log('Value:', JSON.stringify(val)); | |
var stack = new Error().stack; | |
// Remove this function from the stack: | |
stack = stack.trim().split('\n').slice(1).join(' <- ') | |
console.log('Stack: ', stack) | |
console.groupEnd(); | |
// call original innerHTML setter: | |
return setter.call(this, val) | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment