Skip to content

Instantly share code, notes, and snippets.

@ivanlawrence
Last active July 24, 2020 08:53
Show Gist options
  • Select an option

  • Save ivanlawrence/57deb49a10a04c44fda2df0b298d1eb9 to your computer and use it in GitHub Desktop.

Select an option

Save ivanlawrence/57deb49a10a04c44fda2df0b298d1eb9 to your computer and use it in GitHub Desktop.
Magic Formula Investing - copy to clipboard - Bookmarklet
javascript:(function(){
let csv = []
// loop through each row
$('#tableform').find('tr').each(function() {
let row = [];
// loop through each cell in a row
$(this).find('th,td').each(function() {
// add to the row array
row.push( '"' + $(this).text().trim() + '"' );
});
// add a row to the CSV
csv.push( row.join(',') );
});
// flatten the CSV
let csvText = csv.join('\r\n')
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
textArea.value = csvText;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
console.log('Copied!');
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild(textArea);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment