我想从页面中获取每个单词或句子(不是HTML代码),然后通过POST将其发送到服务器,得到响应,并用响应更改单词/句子/全文。
我的代码在单击TamperMonkey上下文菜单后运行:
// ==UserScript==
// @name name
// @namespace https://github.com/...
// @version 1.0
// @description description
// @copyright 2016+, 31SDS14
// @grant unsafeWindow
// @grant GM_registerMenuCommand
// ==/UserScript==
GM_registerMenuCommand('Change that words!', function() {
alert(document.body.innerHTML);
//here send every word or whole sentences to the server via POST and replace those words with received response
}, 'r');在没有HTML代码的情况下,如何从正文中获取文本?
发布于 2016-03-19 01:30:43
一个简单的答案是:
document.body.innerText;https://stackoverflow.com/questions/36096782
复制相似问题