Last active
July 24, 2020 08:53
-
-
Save ivanlawrence/57deb49a10a04c44fda2df0b298d1eb9 to your computer and use it in GitHub Desktop.
Magic Formula Investing - copy to clipboard - Bookmarklet
This file contains hidden or 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
| 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