[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Google Chrome Javascript via Inspect Element

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 12
Thread images: 1

File: 1024[1].png (17KB, 250x250px) Image search: [Google]
1024[1].png
17KB, 250x250px
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
Thread posts: 12
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.