您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
抓取金十页面市场快讯,并进行语音播报(官方语音播报是收费功能)
当前为
// ==UserScript== // @name 金十快讯语音播报 // @namespace https://www.jin10.com/ // @version 1.1 // @description 抓取金十页面市场快讯,并进行语音播报(官方语音播报是收费功能) // @author robaggio // @match https://www.jin10.com/ // @icon https://www.google.com/s2/favicons?sz=64&domain=jin10.com // @run-at document-end // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // setup speech settings const synth = window.speechSynthesis; const voices = synth.getVoices(); var voice = null; for (let i = 0; i < voices.length; i++) { if (voices[i].name === 'Ting-Ting') { voice = voices[i]; } } var lastMessageId = null; let observer = new MutationObserver(mutations => { //console.log(mutations) mutations.forEach(function(mutation) { mutation.addedNodes.forEach(function(node) { // 只获取addnodes里的.jin-flash-item-container变化 if (node.className?.indexOf('jin-flash-item-container')>=0){ // id可以用来判定消息的先后 let id = node.id; if (lastMessageId!=null && id<lastMessageId)return; lastMessageId = id; // 标题, 不一定有 let title = node.querySelector('.right-common-title')?.innerText; // 正文,肯定有 let content = node.querySelector('.collapse-content')?.innerText; if (content == null)return; console.log('content',title,content); var utterThis = new SpeechSynthesisUtterance(title?(title + '。' + content):content); utterThis.lang = 'zh-CN'; utterThis.voice = voice; synth.speak(utterThis); } }); }); }); let box = document.querySelector('#jin_flash_list'); observer.observe(box,{childList:true,subtree:true}); })();