Stop execution of Javascript function (client side) or tweak it

前端 未结 5 2073
别跟我提以往
别跟我提以往 2020-11-22 08:48

I want to stop the execution of one single line from a site, so that the whole page is read by the browser except that single line. Or the browser may simply skip the execut

5条回答
  •  面向向阳花
    2020-11-22 09:13

    The answer depends on details which were not provided (The exact page and line of code would be best), but here's how you do it in general:

    1. If the offending JS code does not fire right away (Fires after DOMContentLoaded), then you can use Greasemonkey to replace the offending code.   EG:

      var scriptNode          = document.createElement ("script");
      scriptNode.textContent  = "Your JS code here";
      document.head.appendChild (scriptNode);
      

      Done.

    2. If the JS code fires immediately, then it gets more complicated.
      First, grab a copy of the script and make the desired change to it. Save this locally.

    3. Is the offending script in a file or is it in the main page HTML (

提交回复
热议问题