一直以来,很依赖edge手机浏览器的语音朗读功能,这也是目前公认的最强的电子语音。首先将浏览模式设置为电脑显示,不仅可以少看乱七八糟的广告,还能显示完整的一章,不需要频繁的点击“下一页”。但是,由于是电脑模式,手机上字体太小,“下一页“按钮根本看不清,特别是开车的时候,所以编了这个篡改猴的脚步,功能就是:在当前页查找“下一页”链接,在页面上方增加一个较大的“下一页“按钮,点击就打开下一页,方便开车时候操作手机。脚本很简单,主体都是百度ai生产的,不得不赞一个人工智能的神奇。下面是源代码:
// ==UserScript==
// @name 下一页按钮生成器
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 查找网页中的"下一页"链接,并生成一个点击后可打开该链接的按钮
// @author Your Name
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 等待页面加载完成
window.addEventListener('load', function() {
// 查找包含"下一页"文本的链接
//console.log("ok");
var nextPageLink = null;
const targetString ='下一章';
const links = document.querySelectorAll('a');
links.forEach(link => {
const cont = link.textContent;
if (cont && cont.includes(targetString)) {
//console.log(cont);
nextPageLink = link;
}
//console.log(link.textContent);
});
// 如果找到了链接
if (nextPageLink) {
// 创建按钮元素
var button = document.createElement('button');
button.innerText = '点击前往下一页';
button.style.fontSize = '20px';
button.style.padding = '10px 20px';
button.style.margin = '20px';
button.style.cursor = 'pointer';
button.style.position = 'fixed';
button.style.top = '10px';
button.style.right = '10px';
button.style.zIndex = 1000; // 确保按钮在其他内容之上
// 添加按钮到页面
document.body.appendChild(button);
// 添加点击事件监听器
button.addEventListener('click', function() {
// 打开找到的链接
window.open(nextPageLink.href, '_self'); // _self 会在当前窗口/标签页中打开链接
});
}
}, false);
})();