Created
January 10, 2019 01:26
-
-
Save sokol815/e4cca44e46181346bcebace5ebe57d21 to your computer and use it in GitHub Desktop.
Tradingview Script to download Alert log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var rows = $($(".alert-list")[1]).find('tr'); | |
var csv = ''; | |
var headers = $(rows[0]).find('th'); | |
for( var i = 0; i < headers.length; i++ ) { | |
csv += (i > 0 ? ',' : '' ) + $(headers[i]).text().trim().split(',').join(' '); | |
} | |
csv += '\r\n'; | |
for( var i = 1; i < rows.length; i++ ) { | |
var cells = $(rows[i]).find('td'); | |
for( var j = 0; j < cells.length; j++ ) { | |
csv += (j > 0 ? ',' : '' ) + $(cells[j]).text().trim().split(',').join(' '); | |
} | |
csv += '\r\n'; | |
} | |
var name = 'Alerts Log'; | |
// download the .csv by creating a link | |
var link = document.createElement('a'); | |
link.id = 'download-csv-'+Date.now(); | |
link.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(csv)); | |
link.setAttribute('download', name+'_'+Date.now()+'.csv'); | |
document.body.appendChild(link); | |
document.querySelector('#'+link.id).click(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment