Created
July 30, 2019 20:05
-
-
Save davecurrierseo/5733cdd498b2c8752a4c71efa6856eec to your computer and use it in GitHub Desktop.
Google Sheets - Extract Rich Text Links
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
# step 1 - make sure the rich text links are in column (a) | |
# step 2 - export sheet as a webpage (.html) | |
# step 3 - open sheet in chrome, open dev tools and paste this in the console: | |
let cells = document.getElementsByTagName('td'); | |
for (let i = 0; i < cells.length; i++) { | |
let links = cells[i].getElementsByTagName('a'); | |
for (let k = 0; k < links.length; k++) { | |
if (typeof links[k] !== 'undefined') { | |
let newCellLocation = cells[i].parentNode.insertCell(2); | |
let newCellText = cells[i].parentNode.insertCell(3); | |
newCellLocation.innerHTML = links[k].href; | |
newCellText.innerHTML = links[k].text; | |
} | |
} | |
} | |
let thead = document.getElementsByTagName('thead')[0]; | |
thead.remove(); | |
let table = document.getElementsByTagName('table')[0]; | |
table.style.tableLayout = 'auto'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much.