extra.js 1.2 KB

1234567891011121314151617181920212223
  1. document.addEventListener("DOMContentLoaded", function () {
  2. // Find all horizontal navigation links pointing to the image selector
  3. let selectorLinks = document.querySelectorAll('a[href*="image-selector"]');
  4. const externalLinkIcon = `
  5. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="display: inline-block; vertical-align: text-bottom; margin-left: 4px; fill: none !important;">
  6. <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
  7. <polyline points="15 3 21 3 21 9"></polyline>
  8. <line x1="10" y1="14" x2="21" y2="3"></line>
  9. </svg>
  10. `;
  11. selectorLinks.forEach(function (link) {
  12. // 1. Set to open in a new tab
  13. link.setAttribute('target', '_blank');
  14. link.setAttribute('rel', 'noopener noreferrer');
  15. // 2. Check if the icon has already been added (prevent duplicate icons if script runs multiple times)
  16. if (!link.innerHTML.includes('<svg')) {
  17. link.insertAdjacentHTML('beforeend', externalLinkIcon);
  18. }
  19. });
  20. });