Alexandre Carette Posted May 4, 2021 Posted May 4, 2021 (edited) Bonjour, je cherche a faire de l'obfuscation de lien via javascript, j'utilise donc un modifier smarty base64_encode <span data-o="{$link->getProductLink($product.id,null,$product.id_category,null,$language.id_lang)|base64_encode}" class="l-obf dropdown-item" data-iso-code="{$language.iso_code}">{$language.name_simple}</span> J'utilise le tuto de webbax: Bon par contre mon projet n'utilise pas Jquery (librairie trop lourde et d'aucune utilité depuis bootstrap 5), j' utilise donc du pure JS // Link obfuscation var obf = document.querySelectorAll(".l-obf"); for(var i =0; i < obf.length; i++){ obf[i].addEventListener('click', function(){ var link = atob(this.dataset.o); window.location.href =link; }); } <span class="l-obf" data-o="{$urls.pages.contact|base64_encode}"> {l s='Contact Us' d='Shop.Theme.Monsupertheme'} </span> Ma question est la suivante: Sur certains liens je ne peux pas utiliser la classe link, avec la nouvelle facon d'ecrire les liens avec {url} comment puis je injecter un modifier smarty base64_encode ? merci a ceux qui pourront m'aiguiller, cdt Edited May 4, 2021 by Alexandre Carette (see edit history) Share this post Link to post Share on other sites More sharing options...
Alexandre Carette Posted May 4, 2021 Posted May 4, 2021 (edited) bon en réfléchissant un peu j'ai trouvé haha: .... {elseif $page.page_name =='index'} {assign var=linkHome value={url entity='index' controller='index' id_lang=$language.id_lang id_shop=1}} <span data-o="{$linkHome|base64_encode}" class="l-obf dropdown-item" data-iso-code="{$language.iso_code}">{$language.name_simple}</span> suffit de faire un assign... Edited May 4, 2021 by Alexandre Carette (see edit history) Share this post Link to post Share on other sites More sharing options...
Alexandre Carette Posted May 4, 2021 Posted May 4, 2021 (edited) petite update du JS pour les url UTF8 avec accents encodés en Base64 // Link obfuscation var obf = document.querySelectorAll(".l-obf"); for(var i =0; i < obf.length; i++){ obf[i].addEventListener('click', function(){ var link = escape(atob(this.dataset.o)); window.location.href = decodeURIComponent(link); }); } Edited May 4, 2021 by Alexandre Carette (see edit history) Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now