10 Replies - 754 Views - Last Post: 20 May 2019 - 10:13 AM

#1 robgeek   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 15-January 13

Changing the javascript code of a website with Chromium.

Posted 18 May 2019 - 09:06 PM

So, I'm using Chromium v.71.0.3578.98 and I would like to change a little bit the javascript code from a website for study purposes. To do that I access this website and in "Developer tools->Network" I search for the ".js" file. Then I click on it with the right button of mouse and "Open in Sources Panel". There I try to edit the file. To test I would like to put an "alert("is just a test");" but when I save it with "ctrl+s" (here I got the message "changes to this file were not saved to file system") nothing happens when I click on the button. Actually is a div.

If I upload the website with f5 chromium will download the js file again! How can I do what I want? I can use Firefox to if is necessary.

Here the code:
//more code here but not important
}, BridgeJsAs.prototype.bindEvents = function() {
	var e = this,
	t = $("body");
	t.on("click", "#startShowButton", function(t) {
		alert("is just a test"); // I tried to put here the alert but nothing happens when I click on startShowButton.
		t.stopPropagation(), t.preventDefault(), e.isPaused || e.onstartPaidChat()
	})
//more code here but not important


Is This A Good Question/Topic? 0
  • +

Replies To: Changing the javascript code of a website with Chromium.

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15109
  • View blog
  • Posts: 60,436
  • Joined: 12-June 08

Re: Changing the javascript code of a website with Chromium.

Posted 18 May 2019 - 09:20 PM

If you are viewing a live site.. yeah.. you can't edit it and assume the page will use it when you refresh. The client still gets it from the server. You would have to save it to your desktop.. but thne again that's only the client side rendered code.. so.. there's that.

If it worked that way then pages would be a lot more hackable.
Was This Post Helpful? 1
  • +
  • -

#3 robgeek   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 15-January 13

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 10:36 AM

View Postmodi123_1, on 18 May 2019 - 09:20 PM, said:

If you are viewing a live site.. yeah.. you can't edit it and assume the page will use it when you refresh. The client still gets it from the server. You would have to save it to your desktop.. but thne again that's only the client side rendered code.. so.. there's that.

If it worked that way then pages would be a lot more hackable.



But I don't want to refresh the page I did that just to test. I know when I do that I get another original .js file from the server, I think. I was trying to edit and save(ctrl+s) but is not working.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15109
  • View blog
  • Posts: 60,436
  • Joined: 12-June 08

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 10:41 AM

Again, unless the page is local you cannot have changes work when editing in f12.
Was This Post Helpful? 1
  • +
  • -

#5 robgeek   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 15-January 13

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 10:57 AM

So this js file is in my computer but I cant access and edit it? Because I can see the it and the code.

This post has been edited by robgeek: 19 May 2019 - 10:58 AM

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15109
  • View blog
  • Posts: 60,436
  • Joined: 12-June 08

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 11:12 AM

Loading a site in a browser puts the content in a protected temporary cache of sorts. Again, you would need to do a control+s to save the entire page down... well.. the client side of it.
Was This Post Helpful? 1
  • +
  • -

#7 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 11:37 AM

It sounds like you're looking for some type of Jquery/ajax script? Where so; content on the page can be changed without refreshing. This is not possible nor should it be possible by manipulating interpretations sent from a web server through a local clients dev tools. If that was the case, you could hack the values of any remote webpage and for the reason already stated, this won't work. If you want the desired effect, you need access to the server providing the content.
Was This Post Helpful? 1
  • +
  • -

#8 robgeek   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 15-January 13

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 12:36 PM

View Postmodi123_1, on 19 May 2019 - 11:12 AM, said:

Loading a site in a browser puts the content in a protected temporary cache of sorts. Again, you would need to do a control+s to save the entire page down... well.. the client side of it.


Is these files in here:
/home/rob/.cache/mozilla/firefox/e1res8ue.default/cache2

Because I found it there but I think is the one I edit with f12
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15109
  • View blog
  • Posts: 60,436
  • Joined: 12-June 08

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 12:42 PM

That's the cache I was talking about. You need to save (control-s) to a desktop or folder OUTSIDE of the cache..
Was This Post Helpful? 1
  • +
  • -

#10 kutchbhi   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 5
  • Joined: 18-December 10

Re: Changing the javascript code of a website with Chromium.

Posted 19 May 2019 - 12:54 PM

You should be able to inject another JS script. Like a browser extension or write a userscript. That JS script may be able to override some functions, maybe. You can also add events from that injected JS.

Also note the restriction of not being able to edit JS is a browser extension. So its possible, but very difficult and an overkill to modify the chromium code and compile..
Was This Post Helpful? 1
  • +
  • -

#11 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2334
  • View blog
  • Posts: 7,111
  • Joined: 15-January 14

Re: Changing the javascript code of a website with Chromium.

Posted 20 May 2019 - 10:13 AM

You can paste whatever code you want to execute in the console tab if you want to do that. So, if you're talking about this part:

	t = $("body");
	t.on("click", "#startShowButton", function(t) {
		alert("is just a test"); // I tried to put here the alert but nothing happens when I click on startShowButton.
		t.stopPropagation(), t.preventDefault(), e.isPaused || e.onstartPaidChat()
	})

Then you can write code to remove the click handler from the body and then add your own, paste that into the console and run it, and it will execute on the page and do whatever you want. That's really just educational though, again if the page refreshes it's going to use the site's code. You can run whatever you want in the console to test things but it's not permanent.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1