Nisarg Shah
Nisarg Shah

Reputation: 354

How to inject JavaScript snippet via Firebug on page load?

I want to inject a JavaScript snippet in the Firebug Command Editor while opening a new tab and execute it.

Here is the explanation.

Anchor tag opener in Firefox

Now the real issue begins. When a page is opened I want a snippet to appear in the Command Editor. So I only have to click on Run. If possible, if clicking Run can be automatized then it would be great.

The purpose is automatize the process of accepting all the requests, which I currently have to do manually.

Upvotes: 0

Views: 1515

Answers (1)

Sebastian Zartner
Sebastian Zartner

Reputation: 20125

Firebug allows to include and execute external JavaScript files via its include() command. This command also allows you to provide an alias for the script, so you can use that one instead of the script's URL.

The syntax of the command for including the script (and storing an alias for it) looks like this:

include(url[, alias])

where url is the URL string of the script you want to include and alias the optional alias string for the URL.

If you stored an alias for it, you can then call it like this:

include(alias)

If you want to see a list of all aliases, you can call the command without parameters:

include()

And to remove an alias you have to call the command like this:

include(null, alias)

Firebug (up to 2.0) doesn't provide storing arbitrary snippets entered into its Command Editor yet, though. This feature is suggested as issue 6951 as UI for the Command Editor and as a command in issue 6201.

Also automatic execution of JavaScript on page load isn't implemented yet. This is requested in issue 6303.

Upvotes: 1

Related Questions