3

Lets imagine that we have a web page. We don't have direct access to this page so we couldn't change the source code but we need to add a js to it contents. Is there any way? I mean for example external javascript or any other way.

5
  • This is for what purpose?. You can use Firebug or such browser plugins to do so , for your own purpose. Commented May 3, 2012 at 11:47
  • 3
    greasemonkey is what you need. Commented May 3, 2012 at 11:47
  • Big_buka , Yes @Elzo is right, Greasemonkey is the best. Commented May 3, 2012 at 11:49
  • lol! hacking questions at stackoverflow xD Commented May 3, 2012 at 11:49
  • Who is "we"? Are you responsible for loading a page within an iframe of a page you own? If so, browser-level security will prevent you from accessing the page in the iframe if it is on a different domain. This is to prevent cross-site scripting attacks. If you are in control of the browser that is loading the page, you can use something like Greasemonkey. Commented May 3, 2012 at 11:52

3 Answers 3

1

check Greasemonkey and its addon for FF. You can use it to inject js into any page.

Sign up to request clarification or add additional context in comments.

Comments

1

Without any access, you of course can't add any script to the site. What are we talking about? XSS instructions ?

You maybe should clarify what exactly you're after and for what reason. The above statement remains true, no access, no permanently adding any script (without some kind of xss attack).

If you just want to inject code to a page you locally openend, you can just use any js-console like Firebug. For instance

var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement, scr = document.createElement('script'); scr.src = 'http://myserver/myscript.js'; scr.type = 'text/javascript'; head.insertBefore(scr, head.firstChild); 

Comments

0

Generally no, however a browser extension could.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.