Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

would it be possible to control a Chrome Extension externally using a C/C++ script? So, for example, when my C script receives an

if

trigger, it would send the command to an open Chrome Extension; e.g. to click a certain part of a page. This must be done using C, as my program is going to be heavily C based when completed.

Many thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
651 views
Welcome To Ask or Share your Answers For Others

1 Answer

Quick solution that came to my mind:

A chrome extension can read files within its own directory.

So I would suggest to create a function in background.js that periodically (adjust the granularity as per your needs), reads some file within the extensions directory using chrome.extension.getURL, XMLHttpRequest and "GET" command.

Then execute the command stated in the file.

From your C/C++/Bash controlling program, you can send the commands.

Here is an example of the function:

function read_control_file() {
    var url = chrome.extension.getURL("control_cmd.txt");
    var request = new XMLHttpRequest();
    // false so that request is processed immediately and we need not pass callback                                                
    request.open("GET", url, false);
    request.send();

    return request.responseText;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...