Re: Include a css file into the HTML - Mozilla

This is a discussion on Re: Include a css file into the HTML - Mozilla ; Hi Yongbin, Thanks for your help, but it does not work for me I will give you more details to see if you guys can help me My Project directory is like this: D:\formfree\chrome\skin\classic\formfree 25/06/2008 17:05 . 25/06/2008 17:05 .. ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: Re: Include a css file into the HTML

  1. Re: Include a css file into the HTML

    Hi Yongbin,

    Thanks for your help, but it does not work for me
    I will give you more details to see if you guys can help me

    My Project directory is like this:

    D:\formfree\chrome\skin\classic\formfree

    25/06/2008 17:05 .
    25/06/2008 17:05 ..
    12/03/2008 09:05 558 contents.rdf
    30/12/2005 20:21 2.020 formfree.png
    30/12/2005 20:21 1.224 formfree16.png
    25/06/2008 11:20 5.291 formFreeCss.css
    30/12/2005 20:21 8.052 formfreedb.png
    25/06/2008 10:46 4.823 nfo64.png
    12/03/2008 11:40 1.344 preview.gif


    the red file is the file I would like to add in the current HTML page

    I tried the code below, and it does not work:

    href="chrome://formfree/skin/formFreeCss.css"?>

    Thanks for help

    Daniel


    On Wed, Jun 25, 2008 at 12:32 PM, Yongbin Tian wrote:

    > e.g. Include these into your xul file:
    >
    >
    > > href="chrome://your-ext/skin/default.css"?>
    >
    > On Wed, Jun 25, 2008 at 11:18 PM, Daniel Neto
    > wrote:
    >
    > > Hi all
    > >
    > > In the overlay XLU is ok to include a Javascript file, but how to include

    > a
    > > css file?
    > >
    > > Regards
    > >
    > > Daniel
    > >
    > > [image: Logo ZCE]<
    > >

    > http://www.zend.com/store/education/...onID=209210010
    > > >

    > > *Daniel Neto*
    > > Especialista e consultor WEB
    > > _______________________________________________
    > > dev-extensions mailing list
    > > dev-extensions@lists.mozilla.org
    > > https://lists.mozilla.org/listinfo/dev-extensions
    > >

    >
    >
    >
    > --
    > Yours sincerely,
    > Yongbin Tian
    > Nankai University, China
    > _______________________________________________
    > dev-extensions mailing list
    > dev-extensions@lists.mozilla.org
    > https://lists.mozilla.org/listinfo/dev-extensions
    >


  2. Re: Include a css file into the HTML

    On Wed, 25 Jun 2008 17:18:28 -0300, Daniel Neto wrote:

    > Hi Yongbin,
    >
    > Thanks for your help, but it does not work for me
    > I will give you more details to see if you guys can help me
    >
    > My Project directory is like this:
    >
    > D:\formfree\chrome\skin\classic\formfree
    >
    > 25/06/2008 17:05
    .
    > 25/06/2008 17:05
    ..
    > 12/03/2008 09:05 558 contents.rdf
    > 30/12/2005 20:21 2.020 formfree.png
    > 30/12/2005 20:21 1.224 formfree16.png
    > 25/06/2008 11:20 5.291 formFreeCss.css
    > 30/12/2005 20:21 8.052 formfreedb.png
    > 25/06/2008 10:46 4.823 nfo64.png
    > 12/03/2008 11:40 1.344 preview.gif
    >
    >
    > the red file is the file I would like to add in the current HTML page


    It is the CSS, alright.

    > I tried the code below, and it does not work:
    >
    > > href="chrome://formfree/skin/formFreeCss.css"?>
    >
    > Thanks for help
    >
    > Daniel


    Did you register the skin[1] in the Chrome Manifest (chrome.manifest)? See
    the `Example Chrome Manifest'[2] or manifests of other extensions for an
    example.

    The skin registration line should look like this:

    skin formfree formfree/1.0 chrome/skin/classic/formfree

    I am not sure if it is `/' or `\' on your system. It could be:

    skin formfree formfree/1.0 chrome\skin\classic\formfree

    > On Wed, Jun 25, 2008 at 12:32 PM, Yongbin Tian wrote:
    >
    >> e.g. Include these into your xul file:
    >>
    >>
    >> >> href="chrome://your-ext/skin/default.css"?>
    >>
    >> On Wed, Jun 25, 2008 at 11:18 PM, Daniel Neto
    >> wrote:
    >>
    >> > Hi all
    >> >
    >> > In the overlay XLU is ok to include a Javascript file, but how to include

    >> a
    >> > css file?
    >> >
    >> > Regards
    >> >
    >> > Daniel
    >> >
    >> > [image: Logo ZCE]<
    >> >

    >> http://www.zend.com/store/education/...onID=209210010
    >> > >
    >> > *Daniel Neto*
    >> > Especialista e consultor WEB
    >> > _______________________________________________
    >> > dev-extensions mailing list
    >> > dev-extensions@lists.mozilla.org
    >> > https://lists.mozilla.org/listinfo/dev-extensions
    >> >

    >>
    >>
    >>
    >> --
    >> Yours sincerely,
    >> Yongbin Tian
    >> Nankai University, China
    >> _______________________________________________
    >> dev-extensions mailing list
    >> dev-extensions@lists.mozilla.org
    >> https://lists.mozilla.org/listinfo/dev-extensions




    [1] Manifest Instructions - skin - http://developer.mozilla.org/en/docs...istration#skin
    [2] Example Chrome Manifest - http://developer.mozilla.org/en/docs...hrome_Manifest

    --
    Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]

  3. Re: Include a css file into the HTML

    I think I have expressed myself wrong
    I am trying to inject a javascript and a css file into the html page.
    I need to use the javascript in the form elements in the current HTML file,
    also I will need some global javascript variables.
    In example if I am in the google.com page, I will be able to interact with
    their input text element.
    I hope is clear now

    Regards

    Daniel


    On Wed, Jun 25, 2008 at 7:45 PM, Kim A. Brandt wrote:

    > On Wed, 25 Jun 2008 17:18:28 -0300, Daniel Neto wrote:
    >
    > > Hi Yongbin,
    > >
    > > Thanks for your help, but it does not work for me
    > > I will give you more details to see if you guys can help me
    > >
    > > My Project directory is like this:
    > >
    > > D:\formfree\chrome\skin\classic\formfree
    > >
    > > 25/06/2008 17:05
    .
    > > 25/06/2008 17:05
    ..
    > > 12/03/2008 09:05 558 contents.rdf
    > > 30/12/2005 20:21 2.020 formfree.png
    > > 30/12/2005 20:21 1.224 formfree16.png
    > > 25/06/2008 11:20 5.291 formFreeCss.css
    > > 30/12/2005 20:21 8.052 formfreedb.png
    > > 25/06/2008 10:46 4.823 nfo64.png
    > > 12/03/2008 11:40 1.344 preview.gif
    > >
    > >
    > > the red file is the file I would like to add in the current HTML page

    >
    > It is the CSS, alright.
    >
    > > I tried the code below, and it does not work:
    > >
    > > > > href="chrome://formfree/skin/formFreeCss.css"?>
    > >
    > > Thanks for help
    > >
    > > Daniel

    >
    > Did you register the skin[1] in the Chrome Manifest (chrome.manifest)? See
    > the `Example Chrome Manifest'[2] or manifests of other extensions for an
    > example.
    >
    > The skin registration line should look like this:
    >
    > skin formfree formfree/1.0 chrome/skin/classic/formfree
    >
    > I am not sure if it is `/' or `\' on your system. It could be:
    >
    > skin formfree formfree/1.0 chrome\skin\classic\formfree
    >
    > > On Wed, Jun 25, 2008 at 12:32 PM, Yongbin Tian wrote:
    > >
    > >> e.g. Include these into your xul file:
    > >>
    > >>
    > >> > >> href="chrome://your-ext/skin/default.css"?>
    > >>
    > >> On Wed, Jun 25, 2008 at 11:18 PM, Daniel Neto
    > >> wrote:
    > >>
    > >> > Hi all
    > >> >
    > >> > In the overlay XLU is ok to include a Javascript file, but how to

    > include
    > >> a
    > >> > css file?
    > >> >
    > >> > Regards
    > >> >
    > >> > Daniel
    > >> >
    > >> > [image: Logo ZCE]<
    > >> >
    > >>

    > http://www.zend.com/store/education/...onID=209210010
    > >> > >
    > >> > *Daniel Neto*
    > >> > Especialista e consultor WEB
    > >> > _______________________________________________
    > >> > dev-extensions mailing list
    > >> > dev-extensions@lists.mozilla.org
    > >> > https://lists.mozilla.org/listinfo/dev-extensions
    > >> >
    > >>
    > >>
    > >>
    > >> --
    > >> Yours sincerely,
    > >> Yongbin Tian
    > >> Nankai University, China
    > >> _______________________________________________
    > >> dev-extensions mailing list
    > >> dev-extensions@lists.mozilla.org
    > >> https://lists.mozilla.org/listinfo/dev-extensions

    >
    >
    >
    > [1] Manifest Instructions - skin -
    > http://developer.mozilla.org/en/docs...istration#skin
    > [2] Example Chrome Manifest -
    > http://developer.mozilla.org/en/docs...hrome_Manifest
    >
    > --
    > Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]
    > _______________________________________________
    > dev-extensions mailing list
    > dev-extensions@lists.mozilla.org
    > https://lists.mozilla.org/listinfo/dev-extensions
    >


  4. Re: Include a css file into the HTML

    Now I guess I got your point.
    It's hard to inject any scripts or styles INTO the web page, but you can run
    scripts in your extension.
    For example you want to get the input textbox in Google.com, in your
    extension js file, you can try:
    var gBrowser = document.getElementById("content");
    var doc = gBrowser.selectedBrowser.contentDocument;
    // this doc is the current browsing document
    var googleTextbox = doc.getElementsByName("q")[0];

    On Thu, Jun 26, 2008 at 7:18 AM, Daniel Neto wrote:

    > I think I have expressed myself wrong
    > I am trying to inject a javascript and a css file into the html page.
    > I need to use the javascript in the form elements in the current HTML file,
    > also I will need some global javascript variables.
    > In example if I am in the google.com page, I will be able to interact with
    > their input text element.
    > I hope is clear now
    >
    > Regards
    >
    > Daniel
    >
    >
    > On Wed, Jun 25, 2008 at 7:45 PM, Kim A. Brandt wrote:
    >
    > > On Wed, 25 Jun 2008 17:18:28 -0300, Daniel Neto wrote:
    > >
    > > > Hi Yongbin,
    > > >
    > > > Thanks for your help, but it does not work for me
    > > > I will give you more details to see if you guys can help me
    > > >
    > > > My Project directory is like this:
    > > >
    > > > D:\formfree\chrome\skin\classic\formfree
    > > >
    > > > 25/06/2008 17:05
    .
    > > > 25/06/2008 17:05
    ..
    > > > 12/03/2008 09:05 558 contents.rdf
    > > > 30/12/2005 20:21 2.020 formfree.png
    > > > 30/12/2005 20:21 1.224 formfree16.png
    > > > 25/06/2008 11:20 5.291 formFreeCss.css
    > > > 30/12/2005 20:21 8.052 formfreedb.png
    > > > 25/06/2008 10:46 4.823 nfo64.png
    > > > 12/03/2008 11:40 1.344 preview.gif
    > > >
    > > >
    > > > the red file is the file I would like to add in the current HTML page

    > >
    > > It is the CSS, alright.
    > >
    > > > I tried the code below, and it does not work:
    > > >
    > > > > > > href="chrome://formfree/skin/formFreeCss.css"?>
    > > >
    > > > Thanks for help
    > > >
    > > > Daniel

    > >
    > > Did you register the skin[1] in the Chrome Manifest (chrome.manifest)?

    > See
    > > the `Example Chrome Manifest'[2] or manifests of other extensions for an
    > > example.
    > >
    > > The skin registration line should look like this:
    > >
    > > skin formfree formfree/1.0 chrome/skin/classic/formfree
    > >
    > > I am not sure if it is `/' or `\' on your system. It could be:
    > >
    > > skin formfree formfree/1.0 chrome\skin\classic\formfree
    > >
    > > > On Wed, Jun 25, 2008 at 12:32 PM, Yongbin Tian

    > wrote:
    > > >
    > > >> e.g. Include these into your xul file:
    > > >>
    > > >>
    > > >> > > >> href="chrome://your-ext/skin/default.css"?>
    > > >>
    > > >> On Wed, Jun 25, 2008 at 11:18 PM, Daniel Neto
    > > >> wrote:
    > > >>
    > > >> > Hi all
    > > >> >
    > > >> > In the overlay XLU is ok to include a Javascript file, but how to

    > > include
    > > >> a
    > > >> > css file?
    > > >> >
    > > >> > Regards
    > > >> >
    > > >> > Daniel
    > > >> >
    > > >> > [image: Logo ZCE]<
    > > >> >
    > > >>

    > >

    > http://www.zend.com/store/education/...onID=209210010
    > > >> > >
    > > >> > *Daniel Neto*
    > > >> > Especialista e consultor WEB
    > > >> > _______________________________________________
    > > >> > dev-extensions mailing list
    > > >> > dev-extensions@lists.mozilla.org
    > > >> > https://lists.mozilla.org/listinfo/dev-extensions
    > > >> >
    > > >>
    > > >>
    > > >>
    > > >> --
    > > >> Yours sincerely,
    > > >> Yongbin Tian
    > > >> Nankai University, China
    > > >> _______________________________________________
    > > >> dev-extensions mailing list
    > > >> dev-extensions@lists.mozilla.org
    > > >> https://lists.mozilla.org/listinfo/dev-extensions

    > >
    > >
    > >
    > > [1] Manifest Instructions - skin -
    > > http://developer.mozilla.org/en/docs...istration#skin
    > > [2] Example Chrome Manifest -
    > >

    > http://developer.mozilla.org/en/docs...hrome_Manifest
    > >
    > > --
    > > Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]
    > > _______________________________________________
    > > dev-extensions mailing list
    > > dev-extensions@lists.mozilla.org
    > > https://lists.mozilla.org/listinfo/dev-extensions
    > >

    > _______________________________________________
    > dev-extensions mailing list
    > dev-extensions@lists.mozilla.org
    > https://lists.mozilla.org/listinfo/dev-extensions
    >




    --
    Yours sincerely,
    Yongbin Tian
    Nankai University, China

  5. Re: Include a css file into the HTML

    On Wed, 25 Jun 2008 17:45:37 -0500, Kim A. Brandt wrote:

    > skin formfree formfree/1.0 chrome/skin/classic/formfree


    You made a mistake. It should be:

    skin formfree classic/1.0 chrome/skin/classic/formfree

    If you really want a second skin called formfree then you'll need two
    lines and two subdirectories:

    skin formfree classic/1.0 chrome/skin/classic/formfree
    skin formfree formfree/1.0 chrome/skin/formfree/formfree

    Phil

    --
    Philip Chee ,
    http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
    Guard us from the she-wolf and the wolf, and guard us from the thief,
    oh Night, and so be good for us to pass.
    [ ]Military intelligence is a contradiction of terms.
    * TagZilla 0.066.6


  6. Re: Include a css file into the HTML

    On Thu, Jun 26, 2008 at 12:06 PM, Philip Chee wrote:

    > On Wed, 25 Jun 2008 17:45:37 -0500, Kim A. Brandt wrote:
    >
    > > skin formfree formfree/1.0 chrome/skin/classic/formfree

    >
    > You made a mistake. It should be:
    >
    > skin formfree classic/1.0 chrome/skin/classic/formfree



    Another mistake! I have ever met this mistake which cost me a few hours to
    solve the problem...you missed the "/", the skin line should be:

    skin formfree classic/1.0 chrome/skin/classic/formfree/


    >
    > If you really want a second skin called formfree then you'll need two
    > lines and two subdirectories:
    >
    > skin formfree classic/1.0 chrome/skin/classic/formfree
    > skin formfree formfree/1.0 chrome/skin/formfree/formfree
    >
    > Phil
    >
    > --
    > Philip Chee ,
    > http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
    > Guard us from the she-wolf and the wolf, and guard us from the thief,
    > oh Night, and so be good for us to pass.
    > [ ]Military intelligence is a contradiction of terms.
    > * TagZilla 0.066.6
    >
    > _______________________________________________
    > dev-extensions mailing list
    > dev-extensions@lists.mozilla.org
    > https://lists.mozilla.org/listinfo/dev-extensions
    >




    --
    Yours sincerely,
    Yongbin Tian
    Nankai University, China

  7. Re: Include a css file into the HTML

    On Wed, 25 Jun 2008 20:18:52 -0300, Daniel Neto wrote:

    > I think I have expressed myself wrong I am trying to inject a javascript
    > and a css file into the html page. I need to use the javascript in the
    > form elements in the current HTML file, also I will need some global
    > javascript variables. In example if I am in the google.com page, I will
    > be able to interact with their input text element.
    > I hope is clear now
    >
    > Regards
    >
    > Daniel
    >
    > ...


    I use two functions to inject `JavaScript' and inject/extract `Stylesheets' into
    a website.

    /* To inject a Stylesheet do:
    *
    * injectCSS("chrome://formfree/skin/formFreeCss.css", true);
    *
    * To extract a Stylesheet do:
    *
    * injectCSS("chrome://formfree/skin/formFreeCss.css", false);
    */
    function injectCSS(uri, value)
    {
    if (!uri) return;

    var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
    var uri = ios.newURI(uri, "UTF-8", null); // URI, CHARSET, BASEURI
    var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetSer vice);
    if (value) { if (!sss.sheetRegistered(uri, sss.USER_SHEET)) sss.loadAndRegisterSheet(uri, sss.USER_SHEET); }
    else { if (sss.sheetRegistered(uri, sss.USER_SHEET)) sss.unregisterSheet(uri, sss.USER_SHEET); }
    }

    You still need to register the skin as Yongbin found out has to look like this:

    skin formfree classic/1.0 chrome/skin/classic/formfree/

    Sorry for any inconvenience.

    /* To inject (execute) JavaScript do:
    *
    * var file = /* prepare your nsILocalFile */;
    * injectJavaScript(file);
    */
    function injectJavaScript(file)
    {
    if (!file) return;

    var lineFinder = null;
    try
    {
    var data = getData(file); // or use data (string) as parameter instead of a file
    var safeView = new XPCNativeWrapper(defaultView);
    var sandbox = Components.utils.Sandbox(safeView);
    sandbox.window = safeView;
    sandbox.document = safeView.document;
    sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult;
    sandbox.__proto__ = safeView;
    lineFinder = new Error();
    Components.utils.evalInSandbox(data, sandbox);
    }
    catch(e)
    {
    if (!lineFinder) throw e;
    else
    {
    var consoleService = Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleServic e);
    var scriptError = Components.classes['@mozilla.org/scripterror;1'].createInstance(Components.interfaces.nsIScriptErr or);
    var sourceName = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).ne wFileURI(file).spec;
    scriptError.init(e.message, sourceName, null, e.lineNumber - lineFinder.lineNumber, e.columnNumber, scriptError.errorFlag, "content javascript");
    consoleService.logMessage(scriptError);
    }
    }
    }

    function getData(file)
    {
    if (!file) return null;

    var fis = Components.classes['@mozilla.org/network/file-input-stream;1'].createInstance(Components.interfaces.nsIFileInput Stream);
    fis.init(file, 0x01, 00004, null);
    var sis = Components.classes['@mozilla.org/scriptableinputstream;1'].createInstance(Components.interfaces.nsIScriptabl eInputStream);
    sis.init(fis);
    var data = sis.read(sis.available());
    var suc = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptabl eUnicodeConverter);
    suc.charset = "UTF-8";
    var data = suc.ConvertToUnicode(data);
    sis.close();
    fis.close();
    return data;
    }

    Hope this gets you started.

    --
    Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]

  8. Re: Include a css file into the HTML

    Thanks, it helps a lot, I will try out

    [image: Logo ZCE]
    *Daniel Neto*
    Especialista e consultor WEB


    On Thu, Jun 26, 2008 at 5:19 AM, Kim A. Brandt wrote:

    > On Wed, 25 Jun 2008 20:18:52 -0300, Daniel Neto wrote:
    >
    > > I think I have expressed myself wrong I am trying to inject a javascript
    > > and a css file into the html page. I need to use the javascript in the
    > > form elements in the current HTML file, also I will need some global
    > > javascript variables. In example if I am in the google.com page, I will
    > > be able to interact with their input text element.
    > > I hope is clear now
    > >
    > > Regards
    > >
    > > Daniel
    > >
    > > ...

    >
    > I use two functions to inject `JavaScript' and inject/extract `Stylesheets'
    > into
    > a website.
    >
    > /* To inject a Stylesheet do:
    > *
    > * injectCSS("chrome://formfree/skin/formFreeCss.css", true);
    > *
    > * To extract a Stylesheet do:
    > *
    > * injectCSS("chrome://formfree/skin/formFreeCss.css", false);
    > */
    > function injectCSS(uri, value)
    > {
    > if (!uri) return;
    >
    > var ios = Components.classes["@mozilla.org/network/io-service;1
    > "].getService(Components.interfaces.nsIIOService);
    > var uri = ios.newURI(uri, "UTF-8", null); // URI, CHARSET, BASEURI
    > var sss = Components.classes["@
    > mozilla.org/content/style-sheet-service;1
    > "].getService(Components.interfaces.nsIStyleSheetSer vice);
    > if (value) { if (!sss.sheetRegistered(uri, sss.USER_SHEET))
    > sss.loadAndRegisterSheet(uri, sss.USER_SHEET); }
    > else { if (sss.sheetRegistered(uri, sss.USER_SHEET))
    > sss.unregisterSheet(uri, sss.USER_SHEET); }
    > }
    >
    > You still need to register the skin as Yongbin found out has to look like
    > this:
    >
    > skin formfree classic/1.0 chrome/skin/classic/formfree/
    >
    > Sorry for any inconvenience.
    >
    > /* To inject (execute) JavaScript do:
    > *
    > * var file = /* prepare your nsILocalFile */;
    > * injectJavaScript(file);
    > */
    > function injectJavaScript(file)
    > {
    > if (!file) return;
    >
    > var lineFinder = null;
    > try
    > {
    > var data = getData(file); // or use data (string) as parameter
    > instead of a file
    > var safeView = new XPCNativeWrapper(defaultView);
    > var sandbox = Components.utils.Sandbox(safeView);
    > sandbox.window = safeView;
    > sandbox.document = safeView.document;
    > sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult;
    > sandbox.__proto__ = safeView;
    > lineFinder = new Error();
    > Components.utils.evalInSandbox(data, sandbox);
    > }
    > catch(e)
    > {
    > if (!lineFinder) throw e;
    > else
    > {
    > var consoleService = Components.classes['@
    > mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleServic e)
    > ;
    > var scriptError = Components.classes['@
    > mozilla.org/scripterror;1'].createInstance(Components.interfaces.nsIScriptErr or)
    > ;
    > var sourceName = Components.classes["@
    > mozilla.org/network/io-service;1
    > "].getService(Components.interfaces.nsIIOService).ne wFileURI(file).spec;
    > scriptError.init(e.message, sourceName, null, e.lineNumber -
    > lineFinder.lineNumber, e.columnNumber, scriptError.errorFlag, "content
    > javascript");
    > consoleService.logMessage(scriptError);
    > }
    > }
    > }
    >
    > function getData(file)
    > {
    > if (!file) return null;
    >
    > var fis = Components.classes['@
    > mozilla.org/network/file-input-stream;1'].createInstance(Components.interfaces.nsIFileInput Stream)
    > ;
    > fis.init(file, 0x01, 00004, null);
    > var sis = Components.classes['@
    > mozilla.org/scriptableinputstream;1'].createInstance(Components.interfaces.nsIScriptabl eInputStream)
    > ;
    > sis.init(fis);
    > var data = sis.read(sis.available());
    > var suc = Components.classes["@
    > mozilla.org/intl/scriptableunicodeconverter
    > "].createInstance(Components.interfaces.nsIScriptabl eUnicodeConverter);
    > suc.charset = "UTF-8";
    > var data = suc.ConvertToUnicode(data);
    > sis.close();
    > fis.close();
    > return data;
    > }
    >
    > Hope this gets you started.
    >
    > --
    > Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]
    > _______________________________________________
    > dev-extensions mailing list
    > dev-extensions@lists.mozilla.org
    > https://lists.mozilla.org/listinfo/dev-extensions
    >


  9. Re: Include a css file into the HTML

    Thanks for all help, I have learned a lot from those functions
    but in the getData function I am getting the following error:

    Could not convert Javascript argument arg 0 [nsIFileInputStream.init]
    0x80570009 NS_ERROR_XPC_BAD_CONVERT_JS
    All help is welcome

    Regards

    Daniel

    [image: Logo ZCE]
    *Daniel Neto*
    Especialista e consultor WEB


    On Thu, Jun 26, 2008 at 9:23 AM, Daniel Neto wrote:

    > Thanks, it helps a lot, I will try out
    >
    > [image: Logo ZCE]
    > *Daniel Neto*
    > Especialista e consultor WEB
    >
    >
    > On Thu, Jun 26, 2008 at 5:19 AM, Kim A. Brandt wrote:
    >
    >> On Wed, 25 Jun 2008 20:18:52 -0300, Daniel Neto wrote:
    >>
    >> > I think I have expressed myself wrong I am trying to inject a javascript
    >> > and a css file into the html page. I need to use the javascript in the
    >> > form elements in the current HTML file, also I will need some global
    >> > javascript variables. In example if I am in the google.com page, I will
    >> > be able to interact with their input text element.
    >> > I hope is clear now
    >> >
    >> > Regards
    >> >
    >> > Daniel
    >> >
    >> > ...

    >>
    >> I use two functions to inject `JavaScript' and inject/extract
    >> `Stylesheets' into
    >> a website.
    >>
    >> /* To inject a Stylesheet do:
    >> *
    >> * injectCSS("chrome://formfree/skin/formFreeCss.css", true);
    >> *
    >> * To extract a Stylesheet do:
    >> *
    >> * injectCSS("chrome://formfree/skin/formFreeCss.css", false);
    >> */
    >> function injectCSS(uri, value)
    >> {
    >> if (!uri) return;
    >>
    >> var ios = Components.classes["@mozilla.org/network/io-service;1
    >> "].getService(Components.interfaces.nsIIOService);
    >> var uri = ios.newURI(uri, "UTF-8", null); // URI, CHARSET, BASEURI
    >> var sss = Components.classes["@
    >> mozilla.org/content/style-sheet-service;1
    >> "].getService(Components.interfaces.nsIStyleSheetSer vice);
    >> if (value) { if (!sss.sheetRegistered(uri, sss.USER_SHEET))
    >> sss.loadAndRegisterSheet(uri, sss.USER_SHEET); }
    >> else { if (sss.sheetRegistered(uri, sss.USER_SHEET))
    >> sss.unregisterSheet(uri, sss.USER_SHEET); }
    >> }
    >>
    >> You still need to register the skin as Yongbin found out has to look like
    >> this:
    >>
    >> skin formfree classic/1.0 chrome/skin/classic/formfree/
    >>
    >> Sorry for any inconvenience.
    >>
    >> /* To inject (execute) JavaScript do:
    >> *
    >> * var file = /* prepare your nsILocalFile */;
    >> * injectJavaScript(file);
    >> */
    >> function injectJavaScript(file)
    >> {
    >> if (!file) return;
    >>
    >> var lineFinder = null;
    >> try
    >> {
    >> var data = getData(file); // or use data (string) as parameter
    >> instead of a file
    >> var safeView = new XPCNativeWrapper(defaultView);
    >> var sandbox = Components.utils.Sandbox(safeView);
    >> sandbox.window = safeView;
    >> sandbox.document = safeView.document;
    >> sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult;
    >> sandbox.__proto__ = safeView;
    >> lineFinder = new Error();
    >> Components.utils.evalInSandbox(data, sandbox);
    >> }
    >> catch(e)
    >> {
    >> if (!lineFinder) throw e;
    >> else
    >> {
    >> var consoleService = Components.classes['@
    >> mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleServic e)
    >> ;
    >> var scriptError = Components.classes['@
    >> mozilla.org/scripterror;1'].createInstance(Components.interfaces.nsIScriptErr or)
    >> ;
    >> var sourceName = Components.classes["@
    >> mozilla.org/network/io-service;1
    >> "].getService(Components.interfaces.nsIIOService).ne wFileURI(file).spec;
    >> scriptError.init(e.message, sourceName, null, e.lineNumber
    >> - lineFinder.lineNumber, e.columnNumber, scriptError.errorFlag, "content
    >> javascript");
    >> consoleService.logMessage(scriptError);
    >> }
    >> }
    >> }
    >>
    >> function getData(file)
    >> {
    >> if (!file) return null;
    >>
    >> var fis = Components.classes['@
    >> mozilla.org/network/file-input-stream;1'].createInstance(Components.interfaces.nsIFileInput Stream)
    >> ;
    >> fis.init(file, 0x01, 00004, null);
    >> var sis = Components.classes['@
    >> mozilla.org/scriptableinputstream;1'].createInstance(Components.interfaces.nsIScriptabl eInputStream)
    >> ;
    >> sis.init(fis);
    >> var data = sis.read(sis.available());
    >> var suc = Components.classes["@
    >> mozilla.org/intl/scriptableunicodeconverter
    >> "].createInstance(Components.interfaces.nsIScriptabl eUnicodeConverter);
    >> suc.charset = "UTF-8";
    >> var data = suc.ConvertToUnicode(data);
    >> sis.close();
    >> fis.close();
    >> return data;
    >> }
    >>
    >> Hope this gets you started.
    >>
    >> --
    >> Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]
    >> _______________________________________________
    >> dev-extensions mailing list
    >> dev-extensions@lists.mozilla.org
    >> https://lists.mozilla.org/listinfo/dev-extensions
    >>

    >
    >


  10. Re: Include a css file into the HTML

    On Thu, 26 Jun 2008 10:36:35 -0300, Daniel Neto wrote:

    > Thanks for all help, I have learned a lot from those functions but in
    > the getData function I am getting the following error:
    >
    > Could not convert Javascript argument arg 0 [nsIFileInputStream.init]
    > 0x80570009 NS_ERROR_XPC_BAD_CONVERT_JS All help is welcome
    >
    > Regards
    >
    > Daniel


    Try to create your file like this:

    var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile );
    file.initWithPath("D:\\formfree\\chrome\\skin\\classic\\formfree\\you rScript.js");

    Remember to use `\\'. Check out `Creating a file object'[1] for `native' (Windows) examples.

    If it still doesn't work, you could post the relevant code.

    > [image: Logo
    > ZCE]
    > *Daniel Neto*
    > Especialista e consultor WEB
    >
    >
    > On Thu, Jun 26, 2008 at 9:23 AM, Daniel Neto
    > wrote:
    >
    >> Thanks, it helps a lot, I will try out
    >>
    >> [image: Logo
    >> ZCE]
    >> *Daniel Neto*
    >> Especialista e consultor WEB
    >>
    >>
    >> On Thu, Jun 26, 2008 at 5:19 AM, Kim A. Brandt
    >> wrote:
    >>
    >>> On Wed, 25 Jun 2008 20:18:52 -0300, Daniel Neto wrote:
    >>>
    >>> > I think I have expressed myself wrong I am trying to inject a
    >>> > javascript and a css file into the html page. I need to use the
    >>> > javascript in the form elements in the current HTML file, also I
    >>> > will need some global javascript variables. In example if I am in
    >>> > the google.com page, I will be able to interact with their input
    >>> > text element. I hope is clear now
    >>> >
    >>> > Regards
    >>> >
    >>> > Daniel
    >>> >
    >>> > ...
    >>>
    >>> I use two functions to inject `JavaScript' and inject/extract
    >>> `Stylesheets' into
    >>> a website.
    >>>
    >>> /* To inject a Stylesheet do:
    >>> *
    >>> * injectCSS("chrome://formfree/skin/formFreeCss.css", true); *
    >>> * To extract a Stylesheet do:
    >>> *
    >>> * injectCSS("chrome://formfree/skin/formFreeCss.css", false);
    >>> */
    >>> function injectCSS(uri, value)
    >>> {
    >>> if (!uri) return;
    >>>
    >>> var ios = Components.classes["@mozilla.org/network/io-service;1
    >>> "].getService(Components.interfaces.nsIIOService);
    >>> var uri = ios.newURI(uri, "UTF-8", null); // URI, CHARSET,
    >>> BASEURI var sss = Components.classes["@
    >>> mozilla.org/content/style-sheet-service;1
    >>> "].getService(Components.interfaces.nsIStyleSheetSer vice);
    >>> if (value) { if (!sss.sheetRegistered(uri, sss.USER_SHEET))
    >>> sss.loadAndRegisterSheet(uri, sss.USER_SHEET); }
    >>> else { if (sss.sheetRegistered(uri, sss.USER_SHEET))
    >>> sss.unregisterSheet(uri, sss.USER_SHEET); }
    >>> }
    >>>
    >>> You still need to register the skin as Yongbin found out has to look
    >>> like this:
    >>>
    >>> skin formfree classic/1.0 chrome/skin/classic/formfree/
    >>>
    >>> Sorry for any inconvenience.
    >>>
    >>> /* To inject (execute) JavaScript do:
    >>> *
    >>> * var file = /* prepare your nsILocalFile */; *
    >>> injectJavaScript(file);
    >>> */
    >>> function injectJavaScript(file)
    >>> {
    >>> if (!file) return;
    >>>
    >>> var lineFinder = null;
    >>> try
    >>> {
    >>> var data = getData(file); // or use data (string) as
    >>> parameter
    >>> instead of a file
    >>> var safeView = new XPCNativeWrapper(defaultView); var
    >>> sandbox = Components.utils.Sandbox(safeView);
    >>> sandbox.window = safeView;
    >>> sandbox.document = safeView.document; sandbox.XPathResult =
    >>> Components.interfaces.nsIDOMXPathResult; sandbox.__proto__
    >>> = safeView;
    >>> lineFinder = new Error();
    >>> Components.utils.evalInSandbox(data, sandbox);
    >>> }
    >>> catch(e)
    >>> {
    >>> if (!lineFinder) throw e;
    >>> else
    >>> {
    >>> var consoleService = Components.classes['@
    >>> mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleServic e)
    >>> ;
    >>> var scriptError = Components.classes['@
    >>> mozilla.org/scripterror;1'].createInstance(Components.interfaces.nsIScriptErr or)
    >>> ;
    >>> var sourceName = Components.classes["@
    >>> mozilla.org/network/io-service;1
    >>> "].getService(Components.interfaces.nsIIOService).ne wFileURI(file).spec;
    >>> scriptError.init(e.message, sourceName, null,
    >>> e.lineNumber
    >>> - lineFinder.lineNumber, e.columnNumber, scriptError.errorFlag,
    >>> "content javascript");
    >>> consoleService.logMessage(scriptError);
    >>> }
    >>> }
    >>> }
    >>>
    >>> function getData(file)
    >>> {
    >>> if (!file) return null;
    >>>
    >>> var fis = Components.classes['@
    >>> mozilla.org/network/file-input-stream;1'].createInstance(Components.interfaces.nsIFileInput Stream)
    >>> ;
    >>> fis.init(file, 0x01, 00004, null);
    >>> var sis = Components.classes['@
    >>> mozilla.org/scriptableinputstream;1'].createInstance(Components.interfaces.nsIScriptabl eInputStream)
    >>> ;
    >>> sis.init(fis);
    >>> var data = sis.read(sis.available()); var suc =
    >>> Components.classes["@
    >>> mozilla.org/intl/scriptableunicodeconverter
    >>> "].createInstance(Components.interfaces.nsIScriptabl eUnicodeConverter);
    >>> suc.charset = "UTF-8";
    >>> var data = suc.ConvertToUnicode(data); sis.close();
    >>> fis.close();
    >>> return data;
    >>> }
    >>>
    >>> Hope this gets you started.
    >>>
    >>> --
    >>> Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]
    >>> _______________________________________________ dev-extensions mailing
    >>> list
    >>> dev-extensions@lists.mozilla.org
    >>> https://lists.mozilla.org/listinfo/dev-extensions
    >>>
    >>>

    >>




    [1] Creating a file object - http://developer.mozilla.org/en/docs...ng.22_files.29

    --
    Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]

  11. Re: Include a css file into the HTML

    Thanks Kim



    The js file I am trying to load is inside the



    formfree\chrome\content\formfree\tool-man



    25/04/2005 15:01 4.138 coordinates.js

    25/04/2005 17:47 4.717 core.js

    25/04/2005 15:01 528 css.js

    25/06/2008 11:24 7.361 drag.js

    25/04/2005 15:01 1.192 events.js



    How do I create a nsifile from it?



    I am using your function and I am trying to do like this:



    *var file = Components.classes["@mozilla.org/file/local;1"]*

    * .createInstance(Components.interfaces.nsILocalFile );*

    *file.initWithPath("chrome://formfree/content/tool-man/core.js");*

    * *

    *injectJavaScript(file);*



    my install.rdf looks like:



    **

    *
    * xmlns:NC="http://home.netscape.com/NC-rdf#"*

    * xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">*

    * escription RDF:about="rdf:#$3yxCW3"*

    * em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"*

    * em:minVersion="1.5"*

    * em:maxVersion="3.1a1pre" />*

    * escription RDF:about="urn:mozilla:install-manifest"*

    * em:id="{E2082660-5330-49e6-BD84-9978CE15BA72}"*

    * em:name="Form free"*

    * em:version="0.7"*

    * em:creator="Daniel Neto"*

    * em:description="Set all form fields free to edit"*

    * em:homepageURL="http://www.danielneto.com"*

    * em:iconURL="chrome://formfree/skin/formfree.png"*

    * em:aboutURL="chrome://formfree/content/about.xul">*

    * *

    * *

    *
    escription>*

    * escription RDF:about="urn:mozilla:extension:file:formfree.jar"*

    * emackage="content/formfree/"*

    * em:skin="skin/classic/formfree/" />*

    *
    *


    On Thu, Jun 26, 2008 at 11:35 AM, Kim A. Brandt wrote:

    > On Thu, 26 Jun 2008 10:36:35 -0300, Daniel Neto wrote:
    >
    > > Thanks for all help, I have learned a lot from those functions but in
    > > the getData function I am getting the following error:
    > >
    > > Could not convert Javascript argument arg 0 [nsIFileInputStream.init]
    > > 0x80570009 NS_ERROR_XPC_BAD_CONVERT_JS All help is welcome
    > >
    > > Regards
    > >
    > > Daniel

    >
    > Try to create your file like this:
    >
    > var file = Components.classes["@mozilla.org/file/local;1
    > "].createInstance(Components.interfaces.nsILocalFile );
    >
    > file.initWithPath("D:\\formfree\\chrome\\skin\\classic\\formfree\\you rScript.js");
    >
    > Remember to use `\\'. Check out `Creating a file object'[1] for `native'
    > (Windows) examples.
    >
    > If it still doesn't work, you could post the relevant code.
    >
    > > [image: Logo
    > > ZCE]<

    > http://www.zend.com/store/education/...onID=209210010
    > >
    > > *Daniel Neto*
    > > Especialista e consultor WEB
    > >
    > >
    > > On Thu, Jun 26, 2008 at 9:23 AM, Daniel Neto
    > > wrote:
    > >
    > >> Thanks, it helps a lot, I will try out
    > >>
    > >> [image: Logo
    > >> ZCE]<

    > http://www.zend.com/store/education/...onID=209210010
    > >
    > >> *Daniel Neto*
    > >> Especialista e consultor WEB
    > >>
    > >>
    > >> On Thu, Jun 26, 2008 at 5:19 AM, Kim A. Brandt
    > >> wrote:
    > >>
    > >>> On Wed, 25 Jun 2008 20:18:52 -0300, Daniel Neto wrote:
    > >>>
    > >>> > I think I have expressed myself wrong I am trying to inject a
    > >>> > javascript and a css file into the html page. I need to use the
    > >>> > javascript in the form elements in the current HTML file, also I
    > >>> > will need some global javascript variables. In example if I am in
    > >>> > the google.com page, I will be able to interact with their input
    > >>> > text element. I hope is clear now
    > >>> >
    > >>> > Regards
    > >>> >
    > >>> > Daniel
    > >>> >
    > >>> > ...
    > >>>
    > >>> I use two functions to inject `JavaScript' and inject/extract
    > >>> `Stylesheets' into
    > >>> a website.
    > >>>
    > >>> /* To inject a Stylesheet do:
    > >>> *
    > >>> * injectCSS("chrome://formfree/skin/formFreeCss.css", true); *
    > >>> * To extract a Stylesheet do:
    > >>> *
    > >>> * injectCSS("chrome://formfree/skin/formFreeCss.css", false);
    > >>> */
    > >>> function injectCSS(uri, value)
    > >>> {
    > >>> if (!uri) return;
    > >>>
    > >>> var ios = Components.classes["@mozilla.org/network/io-service;1
    > >>> "].getService(Components.interfaces.nsIIOService);
    > >>> var uri = ios.newURI(uri, "UTF-8", null); // URI, CHARSET,
    > >>> BASEURI var sss = Components.classes["@
    > >>> mozilla.org/content/style-sheet-service;1
    > >>> "].getService(Components.interfaces.nsIStyleSheetSer vice);
    > >>> if (value) { if (!sss.sheetRegistered(uri, sss.USER_SHEET))
    > >>> sss.loadAndRegisterSheet(uri, sss.USER_SHEET); }
    > >>> else { if (sss.sheetRegistered(uri, sss.USER_SHEET))
    > >>> sss.unregisterSheet(uri, sss.USER_SHEET); }
    > >>> }
    > >>>
    > >>> You still need to register the skin as Yongbin found out has to look
    > >>> like this:
    > >>>
    > >>> skin formfree classic/1.0 chrome/skin/classic/formfree/
    > >>>
    > >>> Sorry for any inconvenience.
    > >>>
    > >>> /* To inject (execute) JavaScript do:
    > >>> *
    > >>> * var file = /* prepare your nsILocalFile */; *
    > >>> injectJavaScript(file);
    > >>> */
    > >>> function injectJavaScript(file)
    > >>> {
    > >>> if (!file) return;
    > >>>
    > >>> var lineFinder = null;
    > >>> try
    > >>> {
    > >>> var data = getData(file); // or use data (string) as
    > >>> parameter
    > >>> instead of a file
    > >>> var safeView = new XPCNativeWrapper(defaultView); var
    > >>> sandbox = Components.utils.Sandbox(safeView);
    > >>> sandbox.window = safeView;
    > >>> sandbox.document = safeView.document; sandbox.XPathResult =
    > >>> Components.interfaces.nsIDOMXPathResult; sandbox.__proto__
    > >>> = safeView;
    > >>> lineFinder = new Error();
    > >>> Components.utils.evalInSandbox(data, sandbox);
    > >>> }
    > >>> catch(e)
    > >>> {
    > >>> if (!lineFinder) throw e;
    > >>> else
    > >>> {
    > >>> var consoleService = Components.classes['@
    > >>>

    > mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleServic e)
    > <
    > http://mozilla.org/consoleservice;1%...soleService%29
    > >
    > >>> ;
    > >>> var scriptError = Components.classes['@
    > >>>

    > mozilla.org/scripterror;1'].createInstance(Components.interfaces.nsIScriptErr or)
    > <
    > http://mozilla.org/scripterror;1%27%...ScriptError%29
    > >
    > >>> ;
    > >>> var sourceName = Components.classes["@
    > >>> mozilla.org/network/io-service;1
    > >>>

    > "].getService(Components.interfaces.nsIIOService).ne wFileURI(file).spec;
    > >>> scriptError.init(e.message, sourceName, null,
    > >>> e.lineNumber
    > >>> - lineFinder.lineNumber, e.columnNumber, scriptError.errorFlag,
    > >>> "content javascript");
    > >>> consoleService.logMessage(scriptError);
    > >>> }
    > >>> }
    > >>> }
    > >>>
    > >>> function getData(file)
    > >>> {
    > >>> if (!file) return null;
    > >>>
    > >>> var fis = Components.classes['@
    > >>>

    > mozilla.org/network/file-input-stream;1'].createInstance(Components.interfaces.nsIFileInput Stream)
    > <
    > http://mozilla.org/network/file-inpu...InputStream%29
    > >
    > >>> ;
    > >>> fis.init(file, 0x01, 00004, null);
    > >>> var sis = Components.classes['@
    > >>>

    > mozilla.org/scriptableinputstream;1'].createInstance(Components.interfaces.nsIScriptabl eInputStream)
    > <
    > http://mozilla.org/scriptableinputst...InputStream%29
    > >
    > >>> ;
    > >>> sis.init(fis);
    > >>> var data = sis.read(sis.available()); var suc =
    > >>> Components.classes["@
    > >>> mozilla.org/intl/scriptableunicodeconverter
    > >>> "].createInstance(Components.interfaces.nsIScriptabl eUnicodeConverter);
    > >>> suc.charset = "UTF-8";
    > >>> var data = suc.ConvertToUnicode(data); sis.close();
    > >>> fis.close();
    > >>> return data;
    > >>> }
    > >>>
    > >>> Hope this gets you started.
    > >>>
    > >>> --
    > >>> Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]
    > >>> _______________________________________________ dev-extensions mailing
    > >>> list
    > >>> dev-extensions@lists.mozilla.org
    > >>> https://lists.mozilla.org/listinfo/dev-extensions
    > >>>
    > >>>
    > >>

    >
    >
    >
    > [1] Creating a file object -
    > http://developer.mozilla.org/en/docs...ng.22_files.29
    >
    > --
    > Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]
    > _______________________________________________
    > dev-extensions mailing list
    > dev-extensions@lists.mozilla.org
    > https://lists.mozilla.org/listinfo/dev-extensions
    >


  12. Re: Include a css file into the HTML

    On Fri, 27 Jun 2008 10:58:46 -0300, Daniel Neto wrote:

    > Thanks Kim
    >
    >
    >
    > The js file I am trying to load is inside the
    >
    >
    >
    > formfree\chrome\content\formfree\tool-man
    >
    >
    >
    > 25/04/2005 15:01 4.138 coordinates.js
    >
    > 25/04/2005 17:47 4.717 core.js
    >
    > 25/04/2005 15:01 528 css.js
    >
    > 25/06/2008 11:24 7.361 drag.js
    >
    > 25/04/2005 15:01 1.192 events.js
    >
    >
    >
    > How do I create a nsifile from it?
    >
    >
    >
    > I am using your function and I am trying to do like this:
    >
    >
    >
    > *var file = Components.classes["@mozilla.org/file/local;1"]*
    >
    > *
    > .createInstance(Components.interfaces.nsILocalFile );*
    >
    > *file.initWithPath("chrome://formfree/content/tool-man/core.js");*
    >
    > * *
    >
    > *injectJavaScript(file);*


    If you didn't package your chrome contents into an jar-archive you could
    use the following approach:

    /* `path' is actually just a `/' or `\' delimited string of
    * directories and a file at the end.
    *
    * Call the function like this (or something like it):
    *
    * var file = getFile("extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/chrome/content/tool-man/core.js");
    */
    function getFile(path)
    {
    if (!path) return null;

    var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).g et("ProfD", Components.interfaces.nsIFile);
    var aPath = path.split(/\/|\\/);
    for (var i = 0; i < aPath.length; i++) file.append(aPath[i]);
    if (!file.exists()) file.create(Components.interfaces.nsIFile.NORMAL_F ILE_TYPE, 0600);
    if (file.isFile()) return file;
    else return null;
    }

    Otherwise you could try this:

    var icr = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIChromeRegistr y);
    var iio = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
    var fph = Components.classes["@mozilla.org/network/protocol;1?name=file"].getService(Components.interfaces.nsIFileProtocolH andler);

    var chromeUrl = iio.newURI("chrome://formfree/content/tool-man/core.js", null, null);
    var fileUrl = icr.convertChromeURL(chromeUrl);
    var file = fph.getFileFromURLSpec(fileUrl.spec);

    The nsIFileProtocolHandler is the interface you should take a look at!

    > my install.rdf looks like:
    >
    >
    >
    > **
    >
    > * >
    > * xmlns:NC="http://home.netscape.com/NC-rdf#"*
    >
    > * xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">*
    >
    > * escription RDF:about="rdf:#$3yxCW3"*
    >
    > * em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"*
    >
    > * em:minVersion="1.5"*
    >
    > * em:maxVersion="3.1a1pre" />*
    >
    > * escription RDF:about="urn:mozilla:install-manifest"*
    >
    > * em:id="{E2082660-5330-49e6-BD84-9978CE15BA72}"*
    >
    > * em:name="Form free"*
    >
    > * em:version="0.7"*
    >
    > * em:creator="Daniel Neto"*
    >
    > * em:description="Set all form fields free to edit"*
    >
    > * em:homepageURL="http://www.danielneto.com"*
    >
    > * em:iconURL="chrome://formfree/skin/formfree.png"*
    >
    > * em:aboutURL="chrome://formfree/content/about.xul">*
    >
    > * *
    >
    > * *
    >
    > *
    escription>*
    >
    > * escription RDF:about="urn:mozilla:extension:file:formfree.jar"*
    >
    > * emackage="content/formfree/"*
    >
    > * em:skin="skin/classic/formfree/" />*
    >
    > *
    *
    >
    > ...


    --
    Be excellent to each other. Party on, dudes. [Bill and Ted, 1989]

+ Reply to Thread