直接复制代码段到浏览器控制台回车运行即可
代码忘了是拉哪个网站的了,好像是笔趣阁的?
let links = document.querySelectorAll('dl > dd > a')
let result = []
for (let l of links) {
$.ajax({
type: 'get',
url: l.href,
async: false,
success: function(data) {
console.log(typeof data)
let c = document.createElement('div')
c.innerHTML = data
result.push(l.text, c.querySelector("#content").textContent)
}
})
}
function downloadFile(blob, name) {
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, name);
return;
}
var WURL = window.URL || window.webkitURL;
// 转为url:"blob:null/4b27d1aa-d7dc-4c91-a6f8-60f0a1b26134"
var bloburl = WURL.createObjectURL(blob);
var anchor = document.createElement("a");
if ('download' in anchor) {
anchor.style.visibility = "hidden";
anchor.href = bloburl;
anchor.download = name;
document.body.appendChild(anchor);
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
anchor.dispatchEvent(evt);
document.body.removeChild(anchor);
// 释放对象
WURL.revokeObjectURL(bloburl);
} else {
location.href = bloburl;
}
}
// 文本文件
var blob = new Blob([result.join("\n\n")], { type:"text/plain;charset=UTF-8" })
downloadFile(blob, 'fileName.txt')