Vasil
Vasil

Reputation: 38186

Can I get the current page sourcecode from a firefox extension?

Can this be done? How?


I want to write my own extension. Can Get the current page sorcecode in my own extension?

Upvotes: 1

Views: 1112

Answers (2)

ConroyP
ConroyP

Reputation: 41956

As Rich says, adding view-source in front of the URL will give you the current page's source code. A keyboard shortcut for this is Ctrl+U.

I want to write my own extension.

There are a number of existing Firefox extensions that fetch a page's source code and apply some action to it (colour-coding, syntax-checking, etc). Downloading them and looking at how they handle it may be a good place to start!

If you're new to Firefox extension development, this article at Lifehacker is an excellent primer in how to start, and will give you an idea of where to look in the above linked extensions for tasks that may be similar to your own.

Upvotes: 5

Rich Bradshaw
Rich Bradshaw

Reputation: 73055

Sure, just add view-source: in front of the URL.

view-source:http://stackoverflow.com/posts/edit/145419

Will show the source of this page for instance - try it in the address bar.

Upvotes: 2

Related Questions