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

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

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!
7 Firefox extensions to explore source code
View Formatted Source extension
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.

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.

Related

Guide for Carrot2 in PDF

Could you please say if there is a pdf (or doc) version of the documentation? If yes, where can I find it?
If such does not exist, I guess it would be great to create such.
PDF allows reading the file in Mendeley Desktop program, underlining parts that are important for me and putting comments. THis would be a great advantage to compare with the html version of the guide.
If you're using Chrome, just go to the Carrot2 online help manual and choose "Print...". In the "Destination" box on the left-hand side change it to "Save as PDF" and click OK. This functionality is built-in to Chrome by default.
For other browsers I'm sure there are add-ins/plugins you can find or you can always use a third-party PDF driver like PrimoPDF.

Opening a bar on top of the page with firefox sdk

I am making a firefox pluggin and I want to open a "topbar" on a few websites. Realy, it would be a few informations about the curent page a link back to my own website. What would be te best way to do that ?
My first idea was to use content script, but that seems to be a very bad practice. I also read about panels, here are my questions :
How can I add my pannel just under the adressbar ?
How can I only open in it on the website I need ?
thx.
Using content script is completely fine.
It is modern, simple, less-code, more compatible way
to add top-panel to some web pages.
Also, code of content script is not injected to the web page, it just uses the dom and context; page script has no access (if you do not provide it explicit) to content script.
The only possible disadvantage is that panel would not look like native part of the browser.
If I convienced you to use content script:
The module you really need in your plugin page-mod
Using Add-on Builder you make have your plugin in a day

Modify contents of Firefox download dialog from add-on kit

I'd like to be able to add an option to the download dialog that pops-up in Firefox when starting a file download. Is it possible to do so using the new add-on SDK or do I have to do it the old way?
edit: Obviously, if the new option is selected, I need a way to know it and execute code based on it.
That's something you would use XUL overlays for. I guess that the dialog you are talking about is chrome://mozapps/content/downloads/downloads.xul - the download manager. AFAIK doing this isn't possible with the Add-on SDK, it only provides the most common UI integration points. You could create a traditional extension however, it can overlay any dialog.
There is no existing module that will help you that I know of, so you would have to create one, or wait for one to be made by someone else. But the main idea to extending browser UI is simple, and goes like this:
When the addon is loaded, scan for open windows of the type that you wish to extend.
extend the open windows by adding xul elements and javascript to the page.
listen for newly opened windows, and test that they are the type that you are looking for once they open
extend newly opened windows while your addon is active
Clean up after yourself when windows close or when your addon is disabled/uninstalled.
The last step is the most important and never matter with old school extensions which were not restartless.
Some for the built-in modules that you can look at that do this are the widget module, the context menu module, and the hotkeys module, all of which you can find here.
I've made a couple myself which are the toolbar button module, the xulkeys module, the menuitems module, and a few others, all of which you can find here.
Recently I wrote an extension do the same things. A bootstrap extension, not using addon-sdk.
I already submit it on AMO, but wait for review
https://addons.mozilla.org/en-US/firefox/addon/download-dialog-tweak/
And the source code
https://github.com/muzuiget/download_dialog_tweak

How to make a site-lookup addon for Firefox?

I'd like to create an addon for Firefox that would enable me to search a particular site by selecting text on one site and choosing to search another site by selecting that option in the context menu.
I already have an extension like that in my browser - the Wikipedia Lookup extension. Basically, I want the exact same functionality but which will send the search text to a different site.
I'm completely new to Firefox addons, so can somebody tell me what's involved in this? Or point me at a site with a list of instructions to do a plugin like this? I can see examples on how to make a Hello World kind of plugin but I can't see how to extend that example into what I need. Thanks.
Have you considered opening the Wikipedia extension source and modifying the pointer from wikipedia.com to the other search site? This is assuming you're using Windows Vista or higher. The source code should be located at:
C:\Users\YourUserName\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default\extensions\something#wikipedia.com\chrome\content
You would then have to modify the source code inside to change the pointer, and the POST variables string to match that of the site you will be using.
I hope this at least points you in the general direction!
-Alex

Developing a Firefox addon that turns a file's URI into its filename when saving it

I've read some documentation and tutorials about developing Firefox Addons.
But never found how to do this.
I would like to make an addon that when you try to save a file (via left-click or right-click/save as) it automatically sets the to-be-created-file's name to be the same as the original file's URI. (but with some changes, like making slashes into hyphens, etc.)
Any hints on how to do this?
Thanks!
I don't believe Firefox Add-ons can change the default "save as" behavior. They could however add another option in the context menu (right click) perhaps named "save as file named with uri". You'd want to learn some JavaScript and such and look at a demo Add-on for the context menu.
Okay, so I looked at a starting point, which took me to these:
A pretty complete get up an developing guide from Mozilla. (No context menu stuff)
A XUL reference. It mentions there is a way to configure the context menu.
Some code snippets for various Mozilla developing.
A very comprehensive hello-world. Similar to #1, but it DOES cover adding actions in the context menu.
I think you can override any behaviour in Firefox - finding out the correct XPCOM call and location in the DOM tree is another matter. Have a look at Extending Firefox and Thunderbird

Resources