I have written a short extension that captures my mouse movements in Chrome, and I want use those coordinates in Python as soon as Javascript has captured them, see below for the short Javascript code in the content file:
var actualCode = `
document.onmousemove = function(e){
var pageCoords = "( " + e.pageX + ", " + e.pageY + " )";
console.log(pageCoords);
};
`;
var script = document.createElement('script');
script.textContent = actualCode;
(document.head||document.documentElement).appendChild(script);
script.remove();
Currently Javascript just prints them in the console, I was thinking about printing to a text file and then make python read that, but it seems like a terribly slow process full of potential issues.
Any better way of doing transferring data from Chrome browser generated by a javascript extension to a Python script?
Edit: This is different from How to send data from JavaScript to Python as that focuses on web development, here both scripts are being run on my local machine.