@@ -21,22 +21,31 @@ const initOutboundDomains = () => {
2121 const existingCookie = clickId || cookieManager . get ( DUB_ID_VAR ) ;
2222 if ( ! existingCookie ) return ;
2323
24- const selector = filteredDomains
25- . map ( ( domain ) => `a[href*="${ domain } "]` )
24+ // Create selectors for both links and iframes
25+ const selectors = filteredDomains
26+ . map ( ( domain ) => [ `a[href*="${ domain } "]` , `iframe[src*="${ domain } "]` ] )
27+ . flat ( )
2628 . join ( ',' ) ;
2729
28- const links = document . querySelectorAll ( selector ) ;
29- if ( ! links || links . length === 0 ) return ;
30+ const elements = document . querySelectorAll ( selectors ) ;
31+ if ( ! elements || elements . length === 0 ) return ;
3032
31- links . forEach ( ( link ) => {
32- // Skip already processed links
33- if ( outboundLinksUpdated . has ( link ) ) return ;
33+ elements . forEach ( ( element ) => {
34+ // Skip already processed elements
35+ if ( outboundLinksUpdated . has ( element ) ) return ;
3436
3537 try {
36- const url = new URL ( link . href ) ;
38+ const url = new URL ( element . href || element . src ) ;
3739 url . searchParams . set ( DUB_ID_VAR , existingCookie ) ;
38- link . href = url . toString ( ) ;
39- outboundLinksUpdated . add ( link ) ;
40+
41+ // Update the appropriate attribute based on element type
42+ if ( element . tagName . toLowerCase ( ) === 'a' ) {
43+ element . href = url . toString ( ) ;
44+ } else if ( element . tagName . toLowerCase ( ) === 'iframe' ) {
45+ element . src = url . toString ( ) ;
46+ }
47+
48+ outboundLinksUpdated . add ( element ) ;
4049 } catch ( e ) { }
4150 } ) ;
4251 }
0 commit comments