How to access webpage data from a firefox extension?

后端 未结 1 1495
面向向阳花
面向向阳花 2021-01-15 03:37

I have managed to get a custom very basic extension running in Firefox.

What I want to do next is:

  1. Check if the user is on a desired webpage
相关标签:
1条回答
  • 2021-01-15 04:28

    So what is leftover for you is the DOM traversal and the external program launching.

    Your DOM traversal can be done in so many ways. However, here is a simple take

    var inputs = document.getElementsByTagName("input");
    for (var idx=0; idx<inputs.length; idx++){
        var tp = inputs[idx].attributes['type'].value
        console.log(tp);
        if (tp == 'hidden'){
           // grab your text at here and launch the app.
        }
    }
    

    External application launching according to this post

    var file = Components.classes["@mozilla.org/file/local;1"]
                         .createInstance(Components.interfaces.nsILocalFile);
    file.initWithPath("c:\\myapp.exe");
    file.launch();
    
    0 讨论(0)
提交回复
热议问题