This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 打开一个新窗口以便于存放和显示提取的内容 | |
var newWin = window.open('', '_blank'); | |
// 提取带有'blog-content-box'类的元素的HTML内容 | |
var contentBox = document.querySelector('.blog-content-box').outerHTML; | |
// 获取标题用于文件名 | |
var articleTitle = document.querySelector('#articleContentId').innerText.trim(); | |
var fileName = articleTitle.replace(/[\/\\:*?"<>|]/g, '_') + '.html'; // 清理文件名中的非法字符 |