Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Chrome Extension #51

Open
abrichr opened this issue May 1, 2023 · 6 comments
Open

Implement Chrome Extension #51

abrichr opened this issue May 1, 2023 · 6 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@abrichr
Copy link
Contributor

abrichr commented May 1, 2023

Certain use cases (e.g. SalesForce, LinkedIn) would greatly benefit from reading and writing website markup and the DOM (i.e. by simplifying tokenization of screenshots).

  1. Implement a Chrome Plugin that sends and receives messages from PuterBot via native messaging: https://developer.chrome.com/docs/extensions/mv3/nativeMessaging/ . On every change to the Document Object Model (DOM) of the currently opened page, the extension should send a message to PuterBot.

  2. Implement an adapter in PuterBot to receive and store the messages with https://github.com/Rayquaza01/nativemessaging. To start with, this can look something like this:

browser.py:

import nativemessaging

def main():
    # based on https://github.com/Rayquaza01/nativemessaging#sample
    reply_num = 0
    while True:
        message = nativemessaging.get_message()
        print(message)
        nativemessaging.send_message(nativemessaging.encode_message(str(reply_num))
        reply_num += 1
if __name__ == "__main__":
    main()

In the extension:

// from https://github.com/Rayquaza01/nativemessaging#sample

function onReceived(response) {
    console.log(response);
}

// runtime.connectNative
var port = browser.runtime.connectNative("application_name");
port.onMessage.addListener(onReceived);
port.postMessage("hello");


// runtime.sendNativeMessage
browser.runtime.sendNativeMessage("puterbot", document).then(onReceived);

// based on https://stackoverflow.com/questions/8882502/how-to-track-dom-change-in-chrome-extension

let observer = new MutationObserver(mutations => {
    for(let mutation of mutations) {
        browser.runtime.sendNativeMessage("puterbot", mutation).then(onReceived);
    }
});
observer.observe(document, { childList: true, subtree: true });

Once this is working, we will want to add the necessary functionality to record.py.

@abrichr abrichr added tribe-hackathon help wanted Extra attention is needed labels May 1, 2023
@abrichr abrichr changed the title Implement Chrome Plugin with Native Messaging Implement Chrome Extension with Native Messaging May 3, 2023
@KrishPatel13 KrishPatel13 self-assigned this May 6, 2023
@KrishPatel13 KrishPatel13 pinned this issue May 6, 2023
@KrishPatel13 KrishPatel13 unpinned this issue May 6, 2023
KrishPatel13 pushed a commit to KrishPatel13/OpenAdapt that referenced this issue May 19, 2023
@KrishPatel13 KrishPatel13 linked a pull request May 22, 2023 that will close this issue
@KrishPatel13
Copy link
Collaborator

KrishPatel13 commented Jun 7, 2023

Regarding MutationObserver: https://stackoverflow.com/questions/20383356/mutation-observer-is-undefined
It is only supported in Internet Explorer 11.

Currently Figuring out an alternative for Chrome.

@abrichr
Copy link
Contributor Author

abrichr commented Jun 17, 2023

It is only supported in Internet Explorer 11.

Are you sure? https://developer.chrome.com/blog/detect-dom-changes-with-mutation-observers/

@KrishPatel13
Copy link
Collaborator

@KrishPatel13
Copy link
Collaborator

KrishPatel13 commented Jul 12, 2023

Link to information on publishing extension: https://developer.chrome.com/docs/webstore/publish/

@abrichr
Copy link
Contributor Author

abrichr commented Aug 11, 2023

#364

@KrishPatel13 KrishPatel13 changed the title Implement Chrome Extension with Native Messaging Implement Chrome Extension Jul 14, 2024
@KrishPatel13
Copy link
Collaborator

This issue shall be closed as completed if this PR gets successfully merged! @abrichr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
2 participants