Finally I found the solution. I used an addon GreaseMonkey. It allowed me to insert my js code into iframe, so I am able to interact with code one my page using message API. Examples:
- Preventing from running code in parent window:
if (window.top == window.self) return;
- Recieving something from main window:
window.addEventListener('message', yourHandlerHere, false);
- Posting something to main window:
window.parent.postMessage(yourDataHere);