braydentav Posted April 24 Share Posted April 24 The code is showing under the nav bar even though it is hidden. .ProductItem .ProductItem-details .product-price, .ProductItem .ProductItem-details .afterpayString is the code that is showing. Any help to hide it is greatly appreciated. </style> .ProductItem .ProductItem-details .product-price, .ProductItem .ProductItem-details .afterpayString { visibility : hidden; } body.twc-spc-show .ProductItem .ProductItem-details .product-price, body.twc-spc-show .ProductItem .ProductItem-details .afterpayString { visibility : hidden; } </style> <script> ( ( ) => { // bail if no mutation observer available if ( ! ( 'MutationObserver' in window ) ) return; const initialize = ( ) => { const isDetail = twcsl.page.store.detail.is; const options = twc.x8af7a0e8; const keys = Object.keys ( options.searchReplaceText ); const changeText = ( node ) => { const walker = document.createTreeWalker ( node, NodeFilter.SHOW_TEXT ); while ( walker.nextNode ( ) ) { const node = walker.currentNode; let t = node.data; $.each ( keys, function ( i, s ) { const m = s.match ( /\/(.+)\/(.*)/ ); let r = options.searchReplaceText [ s ]; if ( m !== null ) { // m appears to be a regex pattern try { s = new RegExp ( m [ 1 ], m [ 2 ] ); } catch { return; // bail on error } if ( ! s.test ( t ) ) return true; // continue if text no match } if ( typeof r == 'function' ) { r = r ( node, isDetail, t, s ); if ( typeof r == 'boolean' ) return r; } t = t.replace ( s, r ); } ); node.data = t; } } const $productPrices = $( '.product-price' ) .each ( function ( ) { changeText ( this ); } ); const $afterpayPrices = $( '.afterpayString' ); if ( options.afterpay ) $afterpayPrices.each ( function ( ) { changeText ( this ); } ); if ( ! isDetail ) return; // bail if not detail const attribute = 'data-twc-spc-mo'; const observer = new MutationObserver ( mutations => { $.each ( mutations, function ( ) { // continue if no added nodes if ( ! this.addedNodes.length ) return true; const target = this.target; // previous change was forced if ( this.attributeName == attribute ) if ( $( target ).attr ( attribute ) == 'true' ) $( target ).attr ( attribute, 'false' ); else if ( this.oldValue == 'true' ) return true; observer.disconnect ( ); changeText ( target ); pricesObserve ( ); } ); } ); const pricesObserve = ( ) => { // listen for changes in product prices $productPrices.each ( function ( ) { observer.observe ( this, { attributeFilter : [ attribute ], attributeOldValue : true, childList : true } ); } ); // listen for changes in afterpay prices if ( options.afterpay ) $afterpayPrices.each ( function ( ) { observer.observe ( this, { attributeFilter : [ attribute ], attributeOldValue : true, childList : true, subtree : true } ); } ); }; pricesObserve ( ); $( 'body' ).addClass ( 'twc-spc-show' ); }; switch ( true ) { case twcsl.ss.is71 : $( initialize ); break; case twcsl.ss.is70 : Squarespace.onInitialize ( Y, initialize ); break; } } ) ( ); </script> Link to comment
Beyondspace Posted April 24 Share Posted April 24 4 hours ago, braydentav said: The code is showing under the nav bar even though it is hidden. .ProductItem .ProductItem-details .product-price, .ProductItem .ProductItem-details .afterpayString is the code that is showing. Any help to hide it is greatly appreciated. </style> .ProductItem .ProductItem-details .product-price, .ProductItem .ProductItem-details .afterpayString { visibility : hidden; } body.twc-spc-show .ProductItem .ProductItem-details .product-price, body.twc-spc-show .ProductItem .ProductItem-details .afterpayString { visibility : hidden; } </style> <script> ( ( ) => { // bail if no mutation observer available if ( ! ( 'MutationObserver' in window ) ) return; const initialize = ( ) => { const isDetail = twcsl.page.store.detail.is; const options = twc.x8af7a0e8; const keys = Object.keys ( options.searchReplaceText ); const changeText = ( node ) => { const walker = document.createTreeWalker ( node, NodeFilter.SHOW_TEXT ); while ( walker.nextNode ( ) ) { const node = walker.currentNode; let t = node.data; $.each ( keys, function ( i, s ) { const m = s.match ( /\/(.+)\/(.*)/ ); let r = options.searchReplaceText [ s ]; if ( m !== null ) { // m appears to be a regex pattern try { s = new RegExp ( m [ 1 ], m [ 2 ] ); } catch { return; // bail on error } if ( ! s.test ( t ) ) return true; // continue if text no match } if ( typeof r == 'function' ) { r = r ( node, isDetail, t, s ); if ( typeof r == 'boolean' ) return r; } t = t.replace ( s, r ); } ); node.data = t; } } const $productPrices = $( '.product-price' ) .each ( function ( ) { changeText ( this ); } ); const $afterpayPrices = $( '.afterpayString' ); if ( options.afterpay ) $afterpayPrices.each ( function ( ) { changeText ( this ); } ); if ( ! isDetail ) return; // bail if not detail const attribute = 'data-twc-spc-mo'; const observer = new MutationObserver ( mutations => { $.each ( mutations, function ( ) { // continue if no added nodes if ( ! this.addedNodes.length ) return true; const target = this.target; // previous change was forced if ( this.attributeName == attribute ) if ( $( target ).attr ( attribute ) == 'true' ) $( target ).attr ( attribute, 'false' ); else if ( this.oldValue == 'true' ) return true; observer.disconnect ( ); changeText ( target ); pricesObserve ( ); } ); } ); const pricesObserve = ( ) => { // listen for changes in product prices $productPrices.each ( function ( ) { observer.observe ( this, { attributeFilter : [ attribute ], attributeOldValue : true, childList : true } ); } ); // listen for changes in afterpay prices if ( options.afterpay ) $afterpayPrices.each ( function ( ) { observer.observe ( this, { attributeFilter : [ attribute ], attributeOldValue : true, childList : true, subtree : true } ); } ); }; pricesObserve ( ); $( 'body' ).addClass ( 'twc-spc-show' ); }; switch ( true ) { case twcsl.ss.is71 : $( initialize ); break; case twcsl.ss.is70 : Squarespace.onInitialize ( Y, initialize ); break; } } ) ( ); </script> Can you share your URL so we can check easier? BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace (+100 Spark plugin customisations) 🥳 Freemium Squarespace Widget Templates (+1000 Elfsight Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment