User:Sudhiksha v/hidensme.js

// ==UserScript== // @name        Wikipedia Text-to-Voice // @namespace   http://tampermonkey.net/ // @version     1.0 // @description Add text-to-voice feature to Wikipedia pages. // @author      YourName // @match       *://*.wikipedia.org/* // @grant       none // @run-at      document-idle // ==/UserScript==

(function {   'use strict';

// Function to speak text function speakText(text) { var synth = window.speechSynthesis; var utterance = new SpeechSynthesisUtterance(text); synth.speak(utterance); }

// Attach event listeners to elements for text-to-voice document.addEventListener('DOMContentLoaded', function {       // Example: Add a button to each paragraph to speak its text        var paragraphs = document.getElementsByTagName('p');        for (var i = 0; i < paragraphs.length; i++) {            var paragraph = paragraphs[i];            var speakButton = document.createElement('button');            speakButton.textContent = 'Speak';            speakButton.addEventListener('click', function(event) { var text = event.target.parentElement.textContent; speakText(text); });           paragraph.appendChild(speakButton);        }    }); });