var str2 = /tmplmsg: ({"[a-zA-Z0-9]+":".*"})/i;
var tepm = 0
var pag = 0
var retult = ""
// 发送请求
function createXmlHttpRequest() {
try {
return new XMLHttpRequest();
} catch (e) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
// 在url中获取token参数
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return (false);
}
function go() {
pag++
var a = document.getElementsByClassName("weui-desktop-table__bd")[1].getElementsByTagName('tr')
var len = a.length
console.log(getQueryVariable("token"))
for (var i = 0; i < len; i++) {
var str = a[i].getElementsByTagName('td')[0].innerHTML
if (str.length == 15) {
var url = "https://mp.weixin.qq.com/advanced/tmplmsg?action=tmpl_preview&t=tmplmsg/preview&id=" + str + "&token=" + getQueryVariable("token") + "&lang=zh_CN"
var xmlHttp = createXmlHttpRequest();
xmlHttp.open("get", url, false);
xmlHttp.send();
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
var str3 = xmlHttp.responseText
var jss = str3.match(str2);
retult += JSON.parse(jss[0].substr(9)).id + "\n"
retult += JSON.parse(jss[1]).example
retult += "\n===========================================================\n"
}
}
}
var d1 = document.getElementsByClassName('weui-desktop-btn weui-desktop-btn_default weui-desktop-btn_mini');
if (d1.length == 1) {
tepm++
}
if (tepm == 2) {
exportRaw('text.txt', retult)
console.log(retult)
return
}
d1[d1.length - 1].click()
console.log(pag)
setTimeout(go, 5000)
}
function fakeClick(obj) {
var ev = document.createEvent("MouseEvents");
ev.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
obj.dispatchEvent(ev);
}
function exportRaw(name, data) {
var urlObject = window.URL || window.webkitURL || window;
var export_blob = new Blob([data]);
var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
save_link.href = urlObject.createObjectURL(export_blob);
save_link.download = name;
fakeClick(save_link);
}
go()
使用方法很简单,在模板消息库页面,直接在控制台里粘贴代码即可,他会自动打包成txt下载