Is it possible to add Javascript code to a loaded webpage using the Google Chrome inspect element feature?
I know you can "inject" HTML code, but what about javascript?
This is what I'm trying to accomplish:
1. Create a new <div> or <p> who displays a value which is currently available directly in the source that I can see with inspect element.
Example:
I see one portion like this:
<div class="num" id="value1">5614513.08</div>
and the other like this:
<div class="num" id="value2">705770.24</div>
I want to inject a new <div> or <p> that contains the value you get from dividing value2 by value1.
So:
<div class="newclass" id="result">$result=value2/value1</div>
And I want to shove the above right into the HTML.
Any ideas?
Hacking is illegal.
Use grease monkey, or it's chrome equivalent.
>>60267651
>I know you can "inject" HTML code, but what about javascript?
Why don't you try it yorself in the browser?
>>60267651
You can execute javascript from the console that will manipulate the dom.
Here's the javascript api you'll need:
https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction
>>60267724
I have before posting. Sadly I'm not a JavaScript guy and don't even know if the code I wrote would work normally.
>>60267651
You can theoretically do this using a MITM attack, and then inject javascript that way. One way that I've tried is by using mitmf to arp spoof the target, and then you can specify javascript that you would like to be put into the web page. I don't think it specifies where in the page it will go, but it is useful for injecting beef hooks. Maybe look into it.
Why do you want to do it?
Chrome supports userscripts if you want to add a feature to a webpage.
>>60267651
I do this every day on my web apps.
You can run JS in the console and you can also edit the DOM.
Same in Firefox.
>>60267736
I've figured it out for the most part using the console. I created a function that takes the values in those divs then gets the ratio of the two which is really all I needed.
>>60268168
You sound like you know your stuff. Do you know of a way to cancel a function executing in the console?
Ideally, instead of creating a function like:
CalculateRatio(){
while(true){
console.log(value1/value2);
}
}
I would ideally do:
while(console command != "hello world"){
console.log(value1/value2);
}
Possible?
>>60267651
yes, you can write a userscript and load it with something like tampermonkey from chrome. It's super easy.
press f12, go to console, write javascript there. it has access to page dom and whatever runs there runs in the page you have open you idiot