Skip to content

Instantly share code, notes, and snippets.

@davecurrierseo
Created July 30, 2019 20:05
Show Gist options
  • Save davecurrierseo/5733cdd498b2c8752a4c71efa6856eec to your computer and use it in GitHub Desktop.
Save davecurrierseo/5733cdd498b2c8752a4c71efa6856eec to your computer and use it in GitHub Desktop.
Google Sheets - Extract Rich Text Links
# 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';
@nartcan
Copy link

nartcan commented Mar 22, 2020

Thank you very much.

@Suryapratap-R
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment