0

Currently im working with personal chrome extension tool via javascript, im having a hard time with this payment form since the form inputs only accepts user input keypress. I already do some research and i find that the chrome.debugger might work but as of now im not sure how do this work like normal javascript that will get the id of input text then set the value to my desired value

Payment form
current code

chrome.runtime.onMessage.addListener(function(message,sender,sendResponse){
if(message.pressEnter){
    chrome.tabs.query({active: true}, function(tabs) {
        chrome.debugger.attach({ tabId: tabs[0].id }, "1.0");
        // chrome.debugger.sendCommand({ tabId: tabs[0].id }, 'Input.insertText', { text: '1234567'});
        chrome.debugger.sendCommand({ tabId: tabs[0].id }, 'Input.dispatchKeyEvent', { type: 'char', text: "testttt"  });
        chrome.debugger.sendCommand({ tabId: tabs[0].id }, 'Input.dispatchKeyEvent', { type: 'char', text: "\r"  });
        chrome.debugger.sendCommand({ tabId: tabs[0].id }, 'Input.dispatchKeyEvent', { type: 'char', text: "\t"  });
        // chrome.debugger.sendCommand({ tabId: tabs[0].id }, 'Input.dispatchKeyEvent', { type: 'char', text: "123456789"  });
        // chrome.debugger.sendCommand({ tabId: tabs[0].id }, 'Input.dispatchKeyEvent', { type: 'keyDown', windowsVirtualKeyCode:13, nativeVirtualKeyCode : 13, macCharCode: 13  });
        chrome.debugger.detach({ tabId: tabs[0].id });
    });
}

});

here is the IDs of those input types #firstName #lastName #cardNumber #expiryDate #cvv

Renz
  • 1
  • 1
  • You need to focus the correct element in the [content script](https://stackoverflow.com/a/4532567) first. See also [Enter data into a custom-handled input field](https://stackoverflow.com/a/57900849) – wOxxOm Apr 01 '21 at 02:40
  • isee thanks bro its working now – Renz Apr 02 '21 at 16:15

0 Answers0