Emoji (hay emoticon) còn gọi là biểu tượng cảm xúc, hay nói ngắn gọn là mặt cười đó. Nó góp phần làm cho cuộc trò chuyện Facebook hay Zalo bớt nhạt hơn, hoặc đơn giản không muốn rep tin nhắn chỉ việc quăng cái icon mặt cười cute :) vào là xong :v
Đề xuất: Chèn ảnh, video từ Youtube vào phần nhận xét của Blogspot
Bài viết hôm nay mình sẽ mang bộ emoji của Facebook Messenger vào thread comment của Blogspot, để phần bình luận bớt nhạt nhòa hơn, hơn thế nữa cũng thể hiện được tình cảm, cảm xúc của người bình luận. Chỉ bằng một đoạn javascript dùng hàm replace từ text thành ảnh, chúng ta có thể dễ dàng thêm biểu tượng cảm xúc emoji vào phần nhận xét của Blogger.
Bài viết hôm nay mình sẽ mang bộ emoji của Facebook Messenger vào thread comment của Blogspot, để phần bình luận bớt nhạt nhòa hơn, hơn thế nữa cũng thể hiện được tình cảm, cảm xúc của người bình luận. Chỉ bằng một đoạn javascript dùng hàm replace từ text thành ảnh, chúng ta có thể dễ dàng thêm biểu tượng cảm xúc emoji vào phần nhận xét của Blogger.
Cách thực hiện
Thêm toàn bộ javascript bên dưới vào trước thẻ</body>
trong template.<b:if cond='data:blog.pageType != "index"'>và lưu lại!
<!-- đk chỉ áp dụng cho trang bài viết và trang tĩnh -->
<style>.bacsiwindows_emoticon {width: 20px; margin: -5px 0 0!important; vertical-align: middle;pointer-events:none}</style>
<!-- css định dạng lại kích thước và vị trí mặt cười -->
<script type='text/javascript'>
//<![CDATA[
function replaceText(){if(!document.getElementById){return;}
bodyText = document.getElementById("comments");
theText = bodyText.innerHTML;
theText = theText.replace(/\/\=r/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0wsF2L8CQCTVFLSlJ8VmdnCcnmGyJVEnBTR47sgElM93j7Mdwxeaw5m0pVV27eaUTms8wudvBTOLukv4-UhnB9dwvgyM8WPCg4EeqAy53wU9ByoJzApB7MrBxnJU6QQ_00Bu-uGl91gbC/s1600/icon-cuoi-khinh-------BacSiWindows-Com.png'/>");
theText = theText.replace(/:\)\)/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIddNfy-DHjWaXQNWtQbk5OzzBmVv-61nFKueE5HO_TNGAeh2_rrU1L9QHxeY12DRKjCjIA4TddxvtN6Y-xFrwjldWRkuyoUimnUSF9Q_YQMZGl9FBJSmHyzq8G-VA_SfJd6yU6zbAlCKr/s30/cuoi-chay-mo-hoi-_------BacSiWindows-Com.png'/>");
theText = theText.replace(/;\)/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXYRbFDV57Zt2VsO1TrLIBprYtAcVzjyHtrFhv5974XG0mApargt91hgV5vmGjpUDReAF0BmtEfU9jUZvDheG_9R2s1hZciDy4MhRm_B-gHbfJTPWIwVzcd8om11YeznrtMWJHR1-tkTqZ/s30/nhay-mat-emoji-_----BacSiWindows-Com.png'/>");
theText = theText.replace(/=\)\)/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVY2r2_nxkrd29SNWcZdas0VMgMEDGfLj_ZzCp3IiPkI5XIOJpZfIZT4mB9XLsQEeWd4KQfdWYj2HsMRO6227bNo4Qz-9CCwJR_FCy7I-xzqmc9AlC_J0wmOGffD2frEcK_Uo7UqUhVFry/s30/cuoi-ra-nuoc-mat-_----BacSiWindows-Com.png'/>");
theText = theText.replace(/:\(\(/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDZdd1lu3JjEbKgTSmoK1DZSDgUPmfhtLUmgzE8PS6X9GnqJVy6_ZkkTX_ZK8FP-2VXiZC3ieWmnfzJqZOJ5awXF9aPjDDic4HJkTEoetj7jiggnx-LEVBEKLV_ZPCmAkz_tvKWoRXIEVT/s30/khoc-cmnr-_--------BacSiWindows-Com.png'/>");
theText = theText.replace(/<3/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIMzv2-0HJAP29M45M-tt03K2sbumDAIHP5YEg40ZAjZ324yC5L6GQrSR9JzQoqLUYVx_8Nc9B1aqxtFop4ynkzev1ieomBM5Kcwa_wvetBIYD6r1f_gWOOJ7BvAILzLquUINeDv_eedIN/s30/heart-emo-_----BacSiWindows-Com.png'/>");
theText = theText.replace(/:v/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNPT6-sMhkylT_LQHhC1m0wLjqlOkW_P2t1CYJnx4nd6M3rsr9YnnIS3-CCf2qN6lbqkYRGSVjOLHjffon8Uv-8BF1DAUIYuN64UhV1EZan2mPA0G_6DScUKm4yxeCarWO6POaY6RwuXtA/s30/pac-man-emoji-_----BacSiWindows-Com.png'/>");
theText = theText.replace(/:\)/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipvaYOkj2KVZptARIBv1PBQEttiknzJXEDwEYqZxW60kyWbPtB_QxauxH7d41xtBKka-qyRl0qVKJhS8ZATTOUkS8-xHi2ZPsNb7wDjoEdtLHWpFy8uVoXnw2DhbnS99uZFtqleqGWggwz/s30/cuoi-mim-emoji-_-----BacSiWindows-Com.png'/>");
theText = theText.replace(/:\(/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk5YQfuLLd1oeHJZy0xiXWWf4u9ZbkfWOOrrPmXPQ9ePikutmxaR0aXeyMdiU2SrEtzoROtfHGFQu5idMy1cuIntOj0xYsPqyWuockVkatxrtVoJONu5-iOGFgA5V-KP2ZcsLTqBmV0-jG/s30/sad-emoji-_--_----BacSiWindows-Com.png'/>");
theText = theText.replace(/==/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAEcM9-IuozUmMKz1cogYFDp0Ymusm7j9qhdJ8ypdTUxMlqSVvNllg9iWXwb8Eb7NoYalng5ikBCLfQROt5PYBFsz1G5ds_YYJ9SG6h3F2GDDNElaWQyrfvx0Z11USkPRh9naitlcjkFOQ/s30/emoji-mat-l-_----BacSiWindows-Com.png''/>");
theText = theText.replace(/:\*/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI4B16GL2pKN-oYKleROm8zl6E0weu1vyy4JC-lAPZUxz9M3hJt84O_IDS-0ZZv95XVf59KaNm8GPoNazWr1nxh60xBBbAJx8KFSLvC_7aSW0s0A5nUyCYF9EAGUgnTlJDR9Rmjw634olD/s30/kiss-_-----BacSiWindows-Com.png'/>");
theText = theText.replace(/:D/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijEXaIh9v8SZmcKrLvIgNcXYrAGmNAffnTsk-2SEurnGhv5zO3r9-YLtE4TLk1gJXqCkVtwKopiXpnc-p28cG3o4dxkFHdwSkgmTNaVt_KRPVsaANKvnQbuUwG8mbWA_pnsdui0SWEL5qO/s30/cuoi-nhe-rang-_------BacSiWindows-Com.png'/>");
theText = theText.replace(/\^\_\^/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRXwhdsMHpO7ux178GJMc5C93Dhlp7CU_46pjN-9Xvi2rz1o3u0ojj2bfBEnc8uXHqLgJlK1a2dKqv9RXVhxZv_lkgxoeE_8V-36bGRE3qXhzNTg0wce2OoVeF3NCMdiZKdCZR9H9K66Ha/s30/cuoi-thoa-man-_--------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=s/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbO8MqPFhJ7V2UOCC2XEdCcJEPpoV3FPIetn0YLQ3VY1mk0JnWPsjuJC-AjSOCsDM7oednLMR25NZLKZzkWjOsQ8vz8dZ_XIzKtlDISgOq95QNuHEb2MbTbxd1xDfbHwkrkSyFwjiuX4GF/s30/cuc-shit-_----------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=ok/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtSgPa-Dy2n47QOudfX-tfDuo286cE2mkUn-z5UO2B4Q0PzDfOgdKimqfE_SwcG2gQNsGy0SCDEmQg13WzwbLklqa6lFVGdRpQWvh3d9ytTE31-2MUxrr6l01kYQF38q5TeS0Mwax86Seo/s30/OK-_--------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=hi/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjpNJtk1ISL0i4ActSMiEcQm8AO2BqfP38530ZqppP75aQ_z-q6wgahELiwVRRlmTnJiH7PIO3kqAOeZNJRP7TFZZl0a-nPItjlC7wgYMuutogtth6CQzOf5eplpRpKH_TUIm7_hz5880Z/s30/hi_-_----BacSiWindows-Com.png'/>");
theText = theText.replace(/\(y\)/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl3FzFgjfZazPc1PIrVseyui_qFv4rNfrN5mwF-plQDgIbyLF6VjQbKNZ35fEUM8djLo4o2C9TIqqjmvOL9UWr11JrO1SLh44yJ9JnnO-GWTUmaSpeNGCPMkNTVym3Ekg25qMGt-3WNDsL/s30/like-_--------BacSiWindows.png'/>");
theText = theText.replace(/:p/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0QywMTW86GaRGxcQ9fKvi0Yf7XqfVWZoeVVo57g0jgpPXar_niTaEUfImQM45vrYdV2pHIk0LpYYWPg1ji9mqn00w5n_fTZx4Vj6VcYqXRfOdL3VBePhKggcCNiuJOcw83bk55Es_zqn8/s30/hahe-_--_---------BacSiWindows-Com.png'/>");
theText = theText.replace(/\(yy\)/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRBbqM2Hja6BCUBNkPAk4uK1BnZBDoFu3tUxLvTBsB7PZmlmqUP4Uf2tNsedbBTWN8DmhJm5_ezYSQtSgfImRrgn3kUe9TD-D2Zi3PffMYWF3eWub7wnzaMDMsA5u8A6yzWT_GFRDtQLrM/s30/dislike_-_---BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=l/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZH0X9rzJ1YLwCR5NRewuPsXAm1qPtBTfRyjpYZ_YkpvOSAZII67Hu58FlJwtu7XygJP9Sfq0bxrrrObaXOE5IHCKcYqeMA9AjMrQV9RJdCaPFLs29XRNCEsDy87o1fK-71MSTVZRmLRyw/s30/liec-cmn-mat-_-------BacSiWindows-Com.png'/>");
theText = theText.replace(/\:\-\)/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLjp94hQuiVS6PHegQmYUODR4Gy-fhoMWlouuewhvhdmktB5957YPm7TK-MkpImEF2J_uH0JIC0GAsFxeggH1jIC29YTQFN6ryHyuttHRK6RHmHNKPav4EyLiDEulSvZWL8MqhMLBxso_R/s30/haiz-_---------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=hl/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSS3PqEPMN86LaUpIK2y6XhBrMmvUnC0r2IIaDJvMaoe43ak-Z80xNGcLsjVRsWZClIIaFgA6OBvim2Mt5yyNacnsSWAAVoED-065-yfygJ0nw8YSUdIzFUZh3FisBy1CL9M7vzLf9myfo/s30/hand-left-_-------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=hr/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuMmrvoLGfkP_DWzJPchvOVncIIaHLNqdXZN17dN69c1jk8J-rezbQDLirIkXlZBBz9w4yQBK9OeqheU6IrIVWaqrnPH1IwEvdNSnvPjwUguLEAJ8TnzpQ8IukZ2Q_d1-TS9ghIES2swJD/s30/hand-right-_--------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=hup/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnMmR0_KVdy_gq5GesmnkBKZPuwS5YTUeQAe4w7DH6rklKiNv40eLOqjCoqCK9yiJ7J_gfFwHwsuUYVD33Kv0prnDynkubW8Y6TqiKkiPuAgsEPBfATq8O7KNS-SABePWeJluIL9G-fEdJ/s30/hand-up-_--------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=hd/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXm1gJGKO0VnFM3entDUUN8NB1GPt7_YG3ISq-V_YptsKyyluHjHhmkd3TMjPVAcmg83RuJoC0kqUq3ZsQUEQnh3cPBlaVgOhkNAK7Hrhao8XL-lU53djI9TCITkndeGeQ1DjMKXiQeHA7/s30/hand-down-_-------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=j/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXm1gJGKO0VnFM3entDUUN8NB1GPt7_YG3ISq-V_YptsKyyluHjHhmkd3TMjPVAcmg83RuJoC0kqUq3ZsQUEQnh3cPBlaVgOhkNAK7Hrhao8XL-lU53djI9TCITkndeGeQ1DjMKXiQeHA7/s30/hand-down-_-------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=clap/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj81s4hW3-xYUU-f_jVBI3pA0avLR-WyZ07Ptens6KM_Ra4LT_MsmDUwLGcJgfnQTKxKptUmH9higQDatljKuDUPrSu2Ft2h7XKda7n7N3mJxQc8a4qHPizoNxUBecRvg7mta0HNlfhoRh2/s30/clap-hand-_----------BacSiWindows-Com.png'/>");
theText = theText.replace(/\/=he/gi, "<img class='bacsiwindows_emoticon' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfCeLx8xGatj52wavYmbN9VaGfDA7_2cYWT-MAekO47rhDetGjhdz47QYwVG3TfVCjMfYF-iZK2t-FSehZeW2ECdXwGFAxBVfWHvRogb_h6igEa43Ydd5aQNLkPPF1Er5QSgoWabSY5afn/s30/love-_-------BacSiWindows-Com.png'/>");
bodyText.innerHTML = theText;
}replaceText();
//]]>
</script>
</b:if>
0 nhận xét