Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autofill from URL in the Chrome extension

I want to prepare a Chrome Extension for my password manager program. The password manager program keeps the usernames and passwords encrypted locally and is therefore not on any server. Instead of copying and pasting every time, I send the usernames and passwords to the Google address line as follows:

https://stackoverflow.com/users/login?user_name=USERNAME&password=PASSWORD

I want the Google Extension to automatically add the username and password in the address line to the corresponding textboxes. Unfortunately, I have no idea for this. I downloaded and reviewed Google Extensions like Daslane, but they are all very complicated and I could not understand. Your ideas and examples, if possible, on how to do this very simply are very valuable for me.

like image 824
Quince Avatar asked May 15 '20 13:05

Quince


1 Answers

First you need to find simple chrome extension sample code.

This is the simple source from chrome developer page.

After that, you have to detect the control name using chrome developer tool and use this script to auto fill and click login button.

function AutoFill() {
    var html = window.location.href + "\n\n";

    if (html.includes("example.com") == true)
    {
        document.getElementById("username").value = "username"
        document.getElementById("password").value = "password"
        document.getElementsByName("login")[0].click();
    }       
    return html;
}
chrome.extension.sendRequest(AutoFill());
like image 92
Jack Lee Avatar answered Oct 17 '22 04:10

Jack Lee