Created
March 24, 2021 18:18
-
-
Save chavesm/86f0b29318709dd79f6d12e804e1994d to your computer and use it in GitHub Desktop.
Auto populate customer URL from Help Scout Custom Field
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
(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