Jump to content
Tuts 4 You

How to use JavaScript debugger and scripts?


Recommended Posts

Hi guys,

so I was playing around with the browser debugger to debug scripts webpages do load and trying to find specific stuff.Normaly I don't much clue about the whole Java commands yet but I tried understand it a little to get some basics and also checking about the webpage "www.w3schools.com" to test examples on fly.Looks all pretty interesting but of course I have many questions where you could  maybe help a little.

About Debugger in browser (FF / Chrome).I was trying to set breakpoints into scripts and mostly it works to set BPs on any lines of the script but in some script it dosent work to set BPs on some lines and the script pointer just does jump to other line in same script where I can set a BP but right there I dont wanna set a BP.Just dont check whats the reason for this.So the debugger did stop = EIP and right there I wanna set a BP etc but dont work.Does anyone know why this happens and whats the reason for this?

The good thing is that I also can set BPs on Event Listener commands to break on diffrent operations XY like Mouse.Click or Meda.Play / Pause to break right when it happens.Now I can debug that script locations to see whats going on and I also can modify values in Scope window.So the main question I have now is how I can patch and keep patches without to change anything just in debug mode?You know what I mean right.Similar like changing any commands in Olly to NOP or RET etc.So how to do that?The only thing what came in my mind was using extensions lile Tampermonkey and writre a script what does check for X and does patch it to Y (anyhow) or maybe using uBO extension to make some script command injections or something etc.Maybe you can give some adivces how to manage that.

Maybe some Example:

On internet I always find sometimes pages who trying to prevent debugging their pages and I get trouble or fails when having the browser console open and the debugger just stops etc by using "Debugger" command inside of script or inside html with script / mixed.Lets have a look on this example page...


...you can see inside of "script" the debugger command which tells debugger to stop when execution it and it does when I have open the browser debugger.Good so far.Now I wanna just try to disable that debugger command to keep the open browser console running to prevet a stop.How to do that?I tried using uBO extension using that command...


...but dosen't work.The uBO logger also dosent show any info about that I wrote.The question why.If I see it right then this command is still valid...


....the part of the pagesource would look like this...



<p id="demo"></p>

<p>With the debugger turned on, the code below should stop executing before it executes the third line.</p>

var x = 15 * 5;
document.getElementById("demo").innerHTML = x;


....and if I check that right then the command I made for uBO should remove or disable or overwrite that command right?

Just would like to know what I can do to disable commands / functions etc / inject own code etc you know.Some pages having strange behaviors and using Java script who doing this or that (static settings) I dont like and have to use it like it is.Some webpages for example checking what you are doing with your mouse in browser etc.I found a page what using a media player where it just stops playing when you change the tab for example.Thats pretty stupid specially when just hearing the audio track and browing go on with a other tab.So I as normal user can not disable that.Now in debugger mode I found the player script what does the action for that media / pause issue on tab switch and debuggr stops but how to change that now / patch it you know.So for this I need some infos what I can do to make patches and how let then execute when the script/s gets loaded.Some infos about would be very welcome for me.Thank you.


Edited by LCF-AT
Changed title
Link to comment
Share on other sites

Your title is a bit misleading because Java and Javascript are 2 very different programming languages 😀

Have you tried using greasemonkey to change javascript? Ive never tried it myself but know it is possible as I have seen a few tuts on the subject


  • Like 1
Link to comment
Share on other sites


ah ok my fault. :) Sorry.Yes I mean that scripting languages.Not using GM or TM to make own script codes yet.At the moment I try to use those uBO extension with those script commands anyhow and checking out some commands of filters etc.



Maybe this could also help to make some working js commands.Found no tutorials yet about that and just trying around at the moment.


Link to comment
Share on other sites

dont know any way to mod a JS by default. What I can think, but I dont know if is possible, is to mod the JS on browser cache level, but again the most companies add a timestamp is the end of JS call, ex.


but they call it 

so when updating the lib.js, make sure the clients will get the latest, and not run with the old one.


what u can do to modify the variable values for JS alerady loaded in a page is to use :

1) bookmarklet


2) browser addon


:: in detail ::


here you can see that manipulate the DOM and the same is working for any JS loaded (tested&working)


see the

  • View Hidden Password
  • Enable Text Selection
  • Enable Right-Click

@ online-tech-tips.com/cool-websites/the-12-best-bookmarklets-every-browser-should-have/


write and debug the script will manipulate the page @ 


then later u doing it bookmarklet or addon. more : 



I think, you can see how this can be achieved @



Edited by whoknows
  • Like 1
Link to comment
Share on other sites

ublock can block scripts but I don't think it replace a script or change parts of it

There is a simple example HERE which uses greasemonkey to replace an entire script which I just tested and is working

and to change parts of an exisitng script again using greasemonkey by using the eventlistener 'beforescriptexecute' there is an example HERE


  • Like 3
Link to comment
Share on other sites

Hi again,

thanks for the infos.Seems I have to check out more on the school page about JS.At the moment I can't do pretty much.

Infos: So before trying to start lerning JS more in detail I have still the uBO Extension I could use for specific tasks (maybe enough for me at the moment).In my first post a I told about a problem of some webpages who using own player scripts and they do update them with new code (I like or not etc) new version.In most cases the old resources are still present on their server like...



....and the latest version is used.Lets say I want the page loading the older version instead the latest default set version so how can I do that?I tried checking uBO about redirection function called (redirect / redirect-rule <--  no working good) but it seems not to work as I thought to redirect any script for example with any xy script url.The only thing I can do is using redirect links from uBO resources....


...and I cant use own urls to redirect to.I also dont know when I have to use any redirect script I can choose for any X situation.There is no details description about it to get more advanced using uBO you know.There is a script called "hd-main.js" (no description into script top).Now I tried to find any filters using that filter and found here something...


...what means to block the "s3.amazonaws.com/homad-global-configs.schneevonmorgen.com/hd-main.js" on all domains (listet right side) and redirect it to the uBO hd-main.js script resource.

So I think what wanna do to redirect to extern url sources (not belong to uBO) is not possible (see underline marks = not allowed).Thats bad.So would that be possible IF I would use GM / TM with any own script commands etc.So in words would be "catch URL A and redirect it with URL B"?As I said at the moment I wanna just try out some simple stuff to see whats working and what not you know.


Link to comment
Share on other sites

possible, u can use Telerik FiddlerScript (never tried) 



  • Like 2
Link to comment
Share on other sites

+1 for Fiddlerscript ( ignoring the obvious security implications of what you want to do by loading an external javascript file from a 3rd party site you have no control over )

I have used it quite a bit for various things

You can either redirect the request, something like this...

if (oSession.url=="www.site.com/javascript.js")
  oSession.url = "www.newsite.com/differentjavascript.js";

or do a search & replace on the html content from the response...

if (oSession.HostnameIs("www.site.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html"))


  • Like 1
Link to comment
Share on other sites

12 hours ago, LCF-AT said:

So I think what wanna do to redirect to extern url sources (not belong to uBO) is not possible

Should be possible, at least on Chrome. Google keyword: userResourcesLocation

  • Like 1
Link to comment
Share on other sites

uBlock is encyclopedia #LOL

what I read 

These are smallest/shortest/fastest to execute files. Should be used in network filters
as a parameter to $redirect option. They purpose is to ##mislead page to think that
real files have been served##.

Available resources
1x1.gif ↪
2x2.png ↪
3x2.png ↪
32x32.png ↪
Source code
noop.html ↪
noop.js ↪
noop.txt ↪
Media files
noop-0.1s.mp3 ↪
noop-1s.mp4 ↪


Keep in mind the resource library is completely under control of the uBO project, 
hence only javascript ##code vouched by uBO## can be inserted into web pages, through the use of a ##valid resource token##.


Edited by whoknows
  • Like 1
Link to comment
Share on other sites

Hi guys,

so I am just using Fiddler sometimes only.I am looking for a browser solution I can include (ON/OFF) like a filter.

So I tried out what you said about uBO koa and checking that option about userResourcesLocation.So I found it and did enter a URL instead of unset.Now the question is how to use it in my filters.I tried but not working.


So what I have to set at redirect paramter now?uBO said this...



Default: unset.

One or more space-separated URLs which content will be parsed as token-identified resources to be used for redirect or scriptlet-injection (+js(...)) purpose.

uBO expects valid content such as can be seen in resources.txt, anything else will lead to undefined results.

Any duplicate as per token will result in the previous resource being replaced by the latter one. The resource files are loaded in order of URL appearance, and uBO stock resource file is always loaded first.

Additional resources will be updated at the same time the built-in resource file is updated. Purging the cache of 'uBlock filters' will also purge the cache of the built-in resource file -- and hence force a reload of user-specified resources if any.

The setting was introduced in 1.12.0. Support for multiple URLs was introduced in 1.19.0.

I just need to add URL to lists (txt) or direct URL to scripts (js) seperated by spacees like this...

userResourcesLocation https://123.com https://abc.com https://xyz.com

...right.Now the question again is how to use them in my filters for redirect / scriptlet-injection paramters.I cant use something like that..

....script,important,redirect=userResourcesLocation  <--- fails
....script,important,redirect=https://123.com        <--- fails
....script,important,redirect=userResourcesLocation:1 <--- not tried

...so how to accees / set the right added script.I cant use array values or something.Lets say I wanna redirect to the 3 added URL (xyz.com) to redirect.How to do that?Dont check why the descriptions are again so low level for that feature.


So what about a JScript for TM / GM to do that?Possible?If so could you then just make a template (example) with any URL to check for and I can repleace with?


Link to comment
Share on other sites

At the mom I can inject JS code to a page specified to FILTERS tab.. 


on the userResourcesLocation you entering the place where your JS  file exists (a URL with the filename JS). 


take as ex
(with https) raw.githubusercontent.com/pixeltris/TwitchAdSolutions/master/notify-strip/notify-strip-ublock-origin.js

on the first line you declare the internal name of the script, in this case twitch-videoad.js (read the JS to c^)


@ filters tab



tested and working.


  • Like 1
Link to comment
Share on other sites


ok, so I tried your example with that twitch site like this....


...now in log window of uBO I can see this entry in yellow color used for DOM and thats all.Dont know what the script is doing to check whether it works or not etc.I tried same with redirect filter...


...but get still a underline = wrong also with () dosent work.So how to make that work?So my goal in that redirection / URL case is it to prevent loading a SET URL / Script and redirect it with any other URL / Script to load that instead.

Page X does load player script 1.1 and I wanna prevent loading it and redirect it to URL with player script version 1.0 to load that instead.Both URLs are on internet I can not modd.So in that case to set something like twitch-videoad at the top of the script to use it for uBO as name later.So I think I can not do that simple with uBO itself and maybe I really have to use / make any TM script for that etc.Has anyone some more ideas or examples?


Link to comment
Share on other sites

dn @ 

ref @

MyFilter @


  • Like 1
Link to comment
Share on other sites

Hi again,

thank you very much for the video you made whoknows. :) I tried those steps you did in your video and I get almost same results as you (only myjs script dosent get shown in console window / still root script after the example text to log) but in Network tab I can see the redirection.Good ok so far.So and now I can write some JS code inside that myjs.js script to handle my own redirection etc right?

(function() {
    'use strict';
	// console.log("Hi, by my script ABC!");
var page1 = 'https://123.com/...js'
var page2 = 'https://abc.com/...js'
var page3 = 'https://xyz.com/...js'

    if (oSession.url=="www.site.com/javascript.js")  // original URL I wanna RD
      oSession.url = page1  // my RD URL


Something like that?How would that code to be done?


Link to comment
Share on other sites

Hi again,

so what do you mean with @......? Sure I have choosen console window but on the right side I dont get the script logged myjs etc I used to redirect.Still the original script is there but the redirection did worked with right script myjs I can see into network tab.Thats strange.I also tried to download the player X script and renamed it into myjs to use it and it works (can see redirection again in network tab) but not in console tab and also not in uBO logger window.So there I can see it does log the player original script with a red line = blocked and then with a blue/purple line = redirected (right side still the original script logged here) and then comes the yellow line with myjsjs and also here on the right side is logged the original script URL.So I think uBO did logged it right so far.Only got the issue with console window tab.....


....you see left is my text which comes from root_library.js on right side =!?Ähhhmm!When I click on the root_ script then it does open the source tab....


...so why this?Instead of root_ it should have the myjs.js script inside or?Now on network tab you can see all right....


....root_lib.. script catched and redirected with myjs.js script.Seems that the console window and source tab still using / showing the initator script.Why?So in your video it does show it diffrent.But at the end the redirection did work so far.I have test it out also with that player X problem I got and did download the old player script using it to redirect with and it works. :) Thats good.Of course its a detour to do all those steps here and I hope that the uBO guys do add / manage that custom redirection anyhow else and easier to handle it etc.

Now I have another question how to manage those redirections with only one script.At the moment with this method I have to create for any new redirection a new edit = all same again another time.New myjs2 / 3 / 4 etc script / new entrys into resoureces script etc you know.Somehow it should be easier to handle when just editing the myjs script content with some JS code right?

PS: All in all thanks again for showing me that redirection example so far.So its already better than nothing. :) Another hints about that etc are also welcome.


  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...