By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,570 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,570 IT Pros & Developers. It's quick & easy.

Read WMI from FF extension and [SOLVED]Change value of textbox via Firefox extension

P: 22
as title says i wish to change the value of a textfield in the current website.

Basicly it enters a certan user and pass on a certan website, both will be stoerd in the prefrences.

then the script will check if the website is the correct it will logon and click submit.

also (sorry for merging 2 questions) is it possible to get WMI data from within a firefox extension , i can do it in VBscript.


This is my basic idea/script:

Expand|Select|Wrap|Line Numbers
  1. var CURL = (get url sumhow, will reasearch later);
  2. var Uname = (get user frm prefs);
  3. var Pass = (get pass from prefs);
  5. if (CURL = (url i want)) {
  6. document.forms[0].TEXTFIELD1.value = Uname 
  7. document.forms[0].TEXTFIELD2.value = Pass
  8. document.forms[0].submit()
  9. }
Jan 15 '09 #1
Share this Question
Share on Google+
5 Replies

P: 22
Expand|Select|Wrap|Line Numbers
  1. content.document.forms[0].TEXTFIELD.value = "GhOsTTeCh"
That code changes the value of "TEXTFIELD" to "GhOsTTECh"
for any1 reading this that also wants an awnser (possibly from a google search) add "content." beofre "document."

well than the next question remains , How do i Query the WMI via a firefox extension
Jan 15 '09 #2

rnd me
Expert 100+
P: 427
you can use command line tools to enumerate wmi.

not sure that extensions can run commands however.
why does it need to be an extension?

it would be easier to do it all in regular firefox javascript.

i have a small routine that uses a simple exe to fetch a remote url, local file, or run and retrieve a command. i can find it for you if it sounds useful.

it can be activated using a custom mime-type document.
it reports back to the script via a script tag pointing to a file in the same folder as the exe.
Jan 15 '09 #3

P: 22
@rnd me
Due to the fact in order to browse the net , umust now login into the new Routers we have(thats why i had to change the Textbox values), we cannot edit the router login page and most 70% forget to log in , so if it was automatic it would save us alot of time and headache.

@rnd me
unfortanetly a exe cannot be used in this scenario as the extension will check the SSID and if it matches the set SSID , it will apply proxy settings and log the user in. with a exe it may get too complicated for the users and the "Technichal Support" (if you only knew the full story you would laugh or be shocked). a simple extension is good due to the fact they will not start complaining about reasons they pull out of their behind.

at the moment i hav created a simple exe that reads the WMI and saves the data to a txt file. Firefox exectues this file and then reads the txt, the negativ is that mozilla dose not wait for the exe to finish and the WMI class lags and sometimes it goes to read the file it the file dosnt exist so proxy isnt applied.
however with a built in WMI command it will wait to compltely grab the data before executing the rest of the extension.
Jan 15 '09 #4

rnd me
Expert 100+
P: 427
that's basically the setup i described except for one thing:
i don't use a raw text-file, i use json and a callback.
this allows the data to be loaded though a script tag.

i have a function that re-loads a script tag by changing it's source.

lets call that function reCheck().

when the exe runs, the first thing it does is write to the json file "setTimeout(reCheck, 500)".

this causes the script to self-refresh twice a second until the data is written by the slow exe.

i guess you could simply poll the text file though...

to me, it sounds like the main idea is to break your operation into two parts:
the data call and a callback, and let the exe run between those.

EDIT: one more thought:
is you have an ASP server, you can call an exe from there and wait for the results. you could call the ASP page with a synchronous ajax call, and the data would have be there as function process the result. ASP can wait, javascript really cannot.
Jan 15 '09 #5

P: 22
@rnd me
Rechecking it to see if the file has been written smart :).
i did a quick and dirty way to keep chcking and if it exists to read it .

Expand|Select|Wrap|Line Numbers
  1. file = [FF classes , etc]
  3. var to = 0;
  4. do
  5. to++;
  6. while (file.exists() == false)
  7. //then i wanted to see what to was after the looping
  8. alert(to);
to ranged from 1200 - 2700 so it is much fatser than the 3 seconds timeout i had set.

if anyone still knows how to query the WMI via the fox plz tell , im still curious and it may help with diagnostic extensions.

thankyou rnd me ur idea gave me the right idea :)
Jan 16 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.