function loadword() { $.get('http://hqdl.cn/index.php/home/index/getWordJson', function (words) { words = JSON.parse(words); // console.log(words); document.body.querySelectorAll('body :not(iframe):not(style):not(script)').forEach((x, index) => { if ($(x).find('iframe').length == 0) { for (var i = 0; i < words.length; i++) { var replcae = ''; if(words[i].thword==undefined) { replcae = '*'; }else{ replcae = words[i].thword } x.innerHTML = x.innerHTML.replaceAll(new RegExp(words[i].name, 'ig'), replcae) } } }) // document.body.innerHTML = document.body.innerHTML.replaceAll(new RegExp(words[i].name, 'ig'), replcae); }); } window.onload = loadword(); String.prototype.replaceAll = function (reallyDo, replaceWith, ignoreCase) { if (!RegExp.prototype.isPrototypeOf(reallyDo)) { return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith); } else { return this.replace(reallyDo, replaceWith); } }