NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name eDom Economy to csv // @version 0.2 // @author Runy69 // @match https://www.edominations.com/*/country/economy/* // @copyright 2020, Runy69 (https://openuserjs.org/users/Runy69) // @updateURL https://openuserjs.org/meta/Runy69/eDom_Economy_to_csv.meta.js // @downloadURL https://openuserjs.org/install/Runy69/eDom_Economy_to_csv.user.js // @grant none // @license MIT // ==/UserScript== let $ = window.jQuery; if (!$) return; $(document).ready(function () { $('#myChart').before('<div style="display: flex; justify-content: flex-end; margin-bottom: -2.5em;"><a id="export" class="btn btn-theme" href="javascript:;"><span>Export today tax revenue</span></a></div>'); $("#export").click(() => exportData()); function exportData() { let country = window.location.pathname.match(/\w+$/)[0]; let rows = []; let data = window.myChart.data; let day = parseInt(data.datasets[0].label.replace("Day", "")); let labels = data.labels; labels.unshift("Day"); rows.push(labels); data = data.datasets[0].data; data.unshift(day); for(let i = 0; i < data.length; i++) { data[i] = data[i].toString().replace('.', ','); } rows.push(data); let csvContent = "data:text/csv;charset=utf-8," + rows.map(e => e.join(";")).join("\n"); let encodedUri = encodeURI(csvContent); let link = document.createElement("a"); link.setAttribute("href", encodedUri); link.setAttribute("download", `eDom-${country}-${day}.csv`); document.body.appendChild(link); link.click(); link.remove(); } });