Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chavesm/86f0b29318709dd79f6d12e804e1994d to your computer and use it in GitHub Desktop.
Save chavesm/86f0b29318709dd79f6d12e804e1994d to your computer and use it in GitHub Desktop.
Auto populate customer URL from Help Scout Custom Field
(function(rn) {
let customerURL;
const customerURLElt =
document.querySelector(`#ex-templateBody td.ex-mcnTextContent table:nth-child(${rn}) tbody tr:nth-child(2) td a`);
if (customerURLElt) {
customerURL = customerURLElt.innerText;
}
if (!customerURL) return;
console.log('customerURL', customerURL);
const targetURLElt = document.querySelector('#custom-url');
let targetURL = targetURLElt.getAttribute('value').trim();
console.log('targetURL', targetURL);
if (targetURL) return;
targetURLElt.setAttribute('value', customerURL);
console.log('%cAuto populated URL: %s', 'color:limegreen;font-size:16px', customerURL);
})(4);
/**
Change the arg to specify the row that
the URL is displayed.
Install and run as a Chrome Dev Tools
saved snippet.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment