pmarks-net / ipvfoo

Display the current page's IP version and addresses
Apache License 2.0
545 stars 50 forks source link

Add option to save data! #27

Open mikeadamz opened 8 years ago

mikeadamz commented 8 years ago

Not sure if you can do this in the chrome sandbox. It'd be cool to be able to log URLs with their IPV4/IPV6 status to a CSV file or something. Maybe create a google sheet?

MichaelDimmitt commented 4 years ago

@mikeadamz

something like this should work added to src/popup.js https://github.com/pmarks-net/ipvfoo/blob/f91c7da5bedca80a1e95a6e9a3b4f9ef7dccacd0/src/popup.js

const rows = [
    ["name1", "city1", "some other info"],
    ["name2", "city2", "more info"]
];

let csvContent = "data:text/csv;charset=utf-8," 
    + rows.map(e => e.join(",")).join("\n");

var encodedUri = encodeURI(csvContent);
window.open(encodedUri);

https://stackoverflow.com/a/14966131/5283424

or

 const rows = [
    ["name1", "city1", "some other info"],
    ["name2", "city2", "more info"]
];

let csvContent = "data:text/csv;charset=utf-8," 
    + rows.map(e => e.join(",")).join("\n");

var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "my_data.csv");
document.body.appendChild(link); // Required for FF

link.click();