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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GhOsTTeCh
    New Member
    • Dec 2008
    • 22

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

    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.

    Thankyou

    This is my basic idea/script:

    Code:
    var CURL = (get url sumhow, will reasearch later);
    var Uname = (get user frm prefs);
    var Pass = (get pass from prefs);
    
    if (CURL = (url i want)) {
    document.forms[0].TEXTFIELD1.value = Uname 
    document.forms[0].TEXTFIELD2.value = Pass
    document.forms[0].submit()
    }
    Last edited by GhOsTTeCh; Jan 15 '09, 04:11 AM. Reason: forgot ";" :$
  • GhOsTTeCh
    New Member
    • Dec 2008
    • 22

    #2
    Code:
    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

    Comment

    • rnd me
      Recognized Expert Contributor
      • Jun 2007
      • 427

      #3
      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.

      Comment

      • GhOsTTeCh
        New Member
        • Dec 2008
        • 22

        #4
        Originally posted by rnd me
        why does it need to be an extension?
        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.

        Originally posted by rnd me
        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.
        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.

        Comment

        • rnd me
          Recognized Expert Contributor
          • Jun 2007
          • 427

          #5
          Originally posted by GhOsTTeCh
          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.
          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(reC heck, 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.

          Comment

          • GhOsTTeCh
            New Member
            • Dec 2008
            • 22

            #6
            Originally posted by rnd me
            ...lets call that function reCheck().

            when the exe runs, the first thing it does is write to the json file "setTimeout(reC heck, 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..
            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 .

            Code:
            file = [FF classes , etc]
            
            var to = 0;
            do
            to++;
            while (file.exists() == false)
            //then i wanted to see what to was after the looping
            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 :)
            Last edited by GhOsTTeCh; Jan 16 '09, 01:42 AM. Reason: i never knew bytes allowed spaces inside the usernames?

            Comment

            Working...