Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
function dec2hex(dec, padding){
return parseInt(dec, 10).toString(16).padStart(padding, '0');
function utf8StringToUtf16String(str) {
var utf16 = [];
for (var i=0, strLen=str.length; i < strLen; i++) {
utf16.push(dec2hex(str.charCodeAt(i), 4));
return utf16.join('');
var keywords = ['复联4', '复联', '复仇者联盟4', '复仇者联盟', '钢铁侠', '托尼', '美国队长', '美队', '黑寡妇', '寡姐', '蜘蛛侠', '浩克', '绿巨人', '鹰眼', '灭霸', '雷神', '惊奇队长', '惊奇', '蚁人', '银河护卫队', '银队'];
var result = body;
keywords.forEach(function(k) {
result = replaceAll(result, k, '喵喵喵');
result = replaceAll(result, utf8StringToUtf16String(k), "\u55b5\u55b5\u55b5");

This comment has been minimized.

Copy link

@francox9 francox9 commented Apr 26, 2019

Good stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.