Created
November 1, 2018 17:30
-
-
Save sokol815/0d42d45eb5953a26cc044339fce60ce0 to your computer and use it in GitHub Desktop.
A Tampermonkey script to export the TradingView Alert log. Requires the Quickalerts extension (quickalerts.us)
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
// ==UserScript== | |
// @name QA Alert List Export addon | |
// @namespace http://tampermonkey.net/* | |
// @version 1.0.0 | |
// @description Export csv of Alerts that have fired. | |
// @author sokol815 LTC: LNpicahdGTFpuXNEhTVoUErPb6EEjBdmwg | |
// @match https://www.tradingview.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
var addonAL = function(){ | |
QuickAlerts.prototype.AlertLogExport = 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(); | |
}; | |
QuickAlerts.prototype.AlertLogExportInitialize = function(){ | |
var self = this; | |
$('.widgetbar-widget.widgetbar-widget-alerts_manage .widgetbar-widgetheader .widgetbar-headerspace').prepend('<div id="qa_al_alertlog_export" class="button apply-common-tooltip" title="Export Alert Log">EAL</div>'); | |
$('#qa_al_alertlog_export').on('click',function(){ | |
self.AlertLogExport(); | |
}); | |
}; | |
quickAlerts.AlertLogExportInitialize(); | |
}; | |
var startupAL = setInterval(function(){ | |
if( quickAlerts != undefined ) { | |
addonAL(); | |
clearInterval(startupAL); | |
} | |
},500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is there a way to export details like the price from where the mouse is to your clipboard using tampermonkey?