The code below is meant to put links in words, but it works only with english words, I would like it to work with arabic words too
The code
<script>
// <![CDATA[
document.addEventListener("DOMContentLoaded", function(){
var links = {
"مغامرات": "https://www.example.com/search/label/%D9%85%D8%BA%D8%A7%D9%85%D8%B1%D8%A7%D8%AA",
"East": "https://www.example.com/search/label/%D8%AE%D9%8A%D8%A7%D9%84",
}
var bodi = document.querySelectorAll("body *:not(script)");
for(var x=0; x<bodi.length; x++){
var html = bodi[x].innerHTML;
for(var i in links){
var re = new RegExp("([\s| ]"+i+"(?:(?=[,<.\s])))", "gi");
var matches = html.match(re);
if(matches){
matches = html.match(re)[0].trim();
html = html.replace(re, function(a){
return ' <a href="'+links[i]+'">'+a.match(/[A-zÀ-ú]+/)[0].trim()+'</a>';
});
}
}
bodi[x].innerHTML = html;
}
});
// ]]>
</script>