5

I want to stop execution of window.location as in below when a page loads:

<script type="text/javascript">
alert('Bid closed ');
window.location = '/index.html';
</script>

I'm able to bypass alert message by replacing alert function during document_start in the manifest.json. But unable to stop window.location from executing.

user5858
  • 1,082
  • 4
  • 39
  • 79

2 Answers2

2

window object is not writable, so you cannot change document and window objects check this link for more info

Community
  • 1
  • 1
Pranoy Sarkar
  • 1,965
  • 14
  • 31
0

The answer looks to me like that of a Math puzzle.

In the injected script I've just placed this code and it seems to work:

window.alert =
                function (msg)
                    {
                       throw Error('hello');
                    }

This exception is causing the browser to skip the next statement window.location=

user5858
  • 1,082
  • 4
  • 39
  • 79
  • For this to be the answer to the question please be specific in the question that you are wanting to stop the execution of that *exact* code. Currently the question reads as how to stop execution of setting `window.location` generally. Without knowing that you are wanting to stop that *exact* code, this does not appear to really answer the question. – Makyen Jun 26 '17 at 22:27
  • @Makyen this is the solution of what I've asked. I've tested with the code I've asked in the question. – user5858 Jun 27 '17 at 04:16