Skip to content

Instantly share code, notes, and snippets.

@Cheezmeister
Created April 12, 2023 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cheezmeister/d20f4b65d698f34a011af1697024b630 to your computer and use it in GitHub Desktop.
Save Cheezmeister/d20f4b65d698f34a011af1697024b630 to your computer and use it in GitHub Desktop.
JS: QR Phone Numbers
links = [ ...
document.querySelectorAll('a')
].filter(el => !!el.href?.match(/^tel:.*/))
links.forEach(el => {
qrEl = document.createElement('a')
qrEl.innerText = 'QR'
qrEl.style = 'width: 16px; height: 16px; font-size: 8px; border-radius: 1px; border: 1px solid currentColor; background: cyan'
el.href = `https://duckduckgo.com/?q=!qr+${el.href}`
el.appendChild(qrEl)
})
/*
javascript:links = [ ... document.querySelectorAll('a') ].filter(el => !!el.href?.match(/^tel:.*/)); links.forEach(el => { qrEl = document.createElement('a'); qrEl.innerText = 'QR'; qrEl.style = 'width: 16px; height: 16px; font-size: 8px; border-radius: 1px; border: 1px solid currentColor; background: cyan'; el.href = `https://duckduckgo.com/?q=!qr+${el.href}`; el.appendChild(qrEl); });
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment