Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
inspect assignments to innerHTML
/* 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
You can’t perform that action at this time.