Reputation: 59
So there's an online quiz which uses flash, and my friend claims he has a script which pulls the answers from the flash app and displays them. I want to test this out, but I have a question:
How can I add or run this script to chrome so that this happens? In general, how can you run your javascript on a certain site on chrome? This concept interests me, and I didn't know it was possible to force sites to do stuff.
Upvotes: 2
Views: 2332
Reputation: 77523
It's quite a broad question. However. there are 3 main answers:
For one-time fiddling, you have the power of Dev Tools at your fingertips. You can run code in the context of the page, examine and debug its own code, make realtime modifications to the DOM etc.
To make a script execute every time you load some page, the traditionally used approach is Userscripts, a notion that came from Firefox. Google Chrome is able (or at least used used to be able) to handle them directly, but now most people use an extension, TamperMonkey, that runs userscripts for you.
Finally, if you need more powerful tools for interacting with your browser, you have Chrome Extensions. They are, basically, JavaScript scripts empowered with access to Chrome APIs. In this context, JS code injected into pages is called Content Scripts.
Upvotes: 2
Reputation: 47966
You can open the developers tools by pressing your F12 key or Ctrl+Shift+i. You can also right click on any element in the page and select "inspect element".
Once the developers tools are open, you can navigate to the right most tab called "console". There you can enter arbitrary JavaScript code to be executed on the currently open page.
Be careful what you paste into that console though! Someone might give you some malicious code to run. When you open the console while you browse Facebook, they actually display this warning:
Facebook is just an example. The same warning is applicable for any site.
Upvotes: 3