<script>
// 获取当前访问域名
let curHost = window.location.host;
// 微信官方域名白名单
let whiteList = [
'mp.weixin.qq.com',
'mmbiz.qpic.cn',
'mmsns.qpic.cn'
];
// 检查当前访问域名是否在白名单中,如果不在,则终止脚本运行
if (!whiteList.includes(curHost)) {
throw new Error('host not in white list!');
}
// 正常运行下面的代码逻辑...
</script>