// ==UserScript== // @name 中国哲学书电子化计划下载 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.0 // @description 中国哲学书电子化计划添加下载按钮 // @author 昊色居士 // @match https://ctext.org/wiki.pl?if=*&chapter=* // ==/UserScript== (function () { 'use strict'; let title = document.querySelector('title').textContent.split(' - 中国哲学书电子化计划')[0] let texts = [] let all_text_el = document.querySelectorAll('.result>td:nth-child(2)') all_text_el.forEach(el => { if (el.textContent) { texts.push(el.textContent) } }) let text = texts.join('\n') let filename = `${title}.txt` let a = document.createElement('a') let blob = new Blob([text]) a.innerHTML = ''; a.download = filename a.href = URL.createObjectURL(blob) URL.revokeObjectURL(blob) document.querySelector('div[class="noprint opt"]').appendChild(a) })();