0

I have a page which has like 5 scripts embedded into it. 1st one shows clock, 2nd one shows/verifies captcha, 3rd one processes POST request, 4th one verifies if its valid or not and the last 5th one verifies if it was called with a time period.

I want a way to stop 4th and 5th script to execute specifically, is there a way to do it? The step over, step into and step out is not working for me, pause script execution works but it only pauses the execution. I am confused. Help? Also, I am looking for way to stop scripts that are embedded inside the HTML file.

Example: I don't want to stop this: <script src="./js/jquery/jquery-ui.js"> </script> BUT what I want to stop is this:

<script> var str="AM";
    var count=0;
    function msToTime(duration) {
        var milliseconds = duration % 1000
        , seconds = Math.floor((duration / 1000) % 60)
        , minutes = Math.floor((duration / (60 * 1000)) % 60)+30
        , hours = Math.floor((duration/(1000*60*60))%24)+5+parseInt(minutes>59 ? "1" :"0" );  
</script>

Note: That I don't have access to the source code of the page, I am trying to perform this action inside a browser and not via editing the page source code. And disabling JavaScript site-wide is not an option.

2
  • "what I want to stop is this:" - that code doesn't seem to actually do anything. Where is msToTime called? Where are the str and count variables used? You still might prevent that, keeping the <script> that set them up as is.
    – Bergi
    Jun 9, 2021 at 11:19
  • This is just an example of what I want to stop i.e. a script that is embedded into the page rather than a script which gets called from a different url at the time of page load.
    – Rosa Roma
    Jun 10, 2021 at 14:10

2 Answers 2

0

You can create a local override in the devtools and edit the html in the source panel to remove the script before it executes. You don't need access to the server for that, you basically edit your own copy of the page. If the script already executed before you could edit the source, you can reload the page and the override will still apply. An alternative to removing the <script> tag from the html is to edit the javascript source to skip over the things you don't want it to run.

2
  • I will give it a try, thank you. Can the execution be controlled by the "step over, step in and step out" thing found in the source panel of devtools? Can it(execution) be skipped using the same?
    – Rosa Roma
    Jun 10, 2021 at 14:14
  • No, they refer only to where the next breakpoint is set when resuming execution, not to skip statements. You can however edit (assign) local variables using the console when stopped at a breakpoint, which sometimes allows you to change control flow in the way you want.
    – Bergi
    Jun 10, 2021 at 14:17
0

@Amos this is what I do for troubleshooting issues on my SimplicityBlocks.com website. If you are using Chrome Dev tools you can go to the network tab. Reload the page and you will see all of the files being requested. Select the script file that you want to prevent from running. Right click on it and select 'Block URL'. When you reload the page that script will be blocked from loading.

Firefox dev tools has a similar feature.

1
  • I have already tried that but that doesn't work for scripts embedded into/inside the HTML file. Your method works for scripts which loads from sub-directory (such as <script src="./js/jquery/jquery-ui.js">) but I want a way to stop script that is inside a <script></script>.
    – Rosa Roma
    Jun 9, 2021 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.