User:小躍/tools/SpeechSynthesisUtterance/ListenAssistance.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

if(! navigator.userAgent.match("Windows")){
//start First function
mw.loader.using(['jquery.ui'], function() {
var optiontext="";
var Listentext="";


if (wgAction == 'view' && wgNamespaceNumber ===0){$('#firstHeading').after('<input id="wpListenButton" value="聆聽頁面播放" title="聆聽該頁面的內容" type="button"/>');
$('#wpListenButton').click(ListenShow);}
function ListenShow(event) {
	event.preventDefault();
	Listentext='歡迎收聽頁面名稱:'+wgPageName+',維基百科,自由的百科全書。我是維基娘,主講準備開始囉!'+$('p').text().toString().replace(/\[\d\]/g,'').replace(/\[\w\w\]/g,'').replace(/\[\w\w\]/g,'').replace(/\[\w\w\w\]/g,'').replace(/\-/g,'至')+'。演講結束,如有其他需要補充的,可以請線上或旁邊的協助人員為您服務,感謝您用心地聆聽,祝福您聆聽愉快!';
	var Voice2 = new SpeechSynthesisUtterance(Listentext);
	Voice2.lang='zh-TW';
	Voice2.pitch=1.3;

	window.speechSynthesis.speak(Voice2);
}
if (wgAction == 'view' && wgPageName=='User:小躍/tools/SpeechSynthesisUtterance'){
	optiontext=wgUserName+'您好,我是維基娘,有什麼我可以幫忙的嗎?';
	
		$('#A1').after('<input id="wpListenA1Button" value="互動" title="與維基娘的互動" type="button"/>');
		$('#A2').after('<input id="wpListenA2Button" value="互動" title="與維基娘的互動" type="button"/>');
		$('#wpListenA1Button').click(ListenShowA1);
		$('#wpListenA2Button').click(ListenShowA2);
	
	
}
function ListenShowA1(event) {
	event.preventDefault();
	Listentext=wgUserName+'您好,我是維基娘,我誕生於2001年1月15日,2006年由日本維基人Kasuga來畫本人的角色設計,我也曾被拿去參與2006年舉行的維基百科吉祥物投票,因此榮獲各界的好評,後來也相繼成為各個維基百科的吉祥人物,陸續榮獲維基百科創辦人Jimmy Wales的許可,雖然編輯很辛苦,但只要維基娘在您的身邊,您就可以細心地去體會維基百科廣大資源的收集性,親愛的 '+wgUserName+',期待您總有一天將是未來的編輯歷史的風雲人物,同樣跟維基娘一樣站上世界的舞台,讓大家看到您所留下的美好回憶,這一份的努力將會被其他專家所引用。維基娘將獻上滿滿的祝福給'+wgUserName+',bong jiu !';
	$('<div id="ListenShowhowing" title="內容顯示器">' +
      '<label>顯示內容:<br/><pre>'+Listentext+'</pre></label><br/>'+
      '</div>'
     ).dialog({
    modal: false,
    autoOpen: true,
    width: 500
    });
    var Voice3 = new SpeechSynthesisUtterance(Listentext);
	Voice3.lang='zh-TW'; 
	Voice3.pitch=1.3;
	window.speechSynthesis.speak(Voice3);
}
function ListenShowA2(event) {
	var now=new Date();
	var nowyear=now.getUTCFullYear();
	var nowmonth=now.getUTCMonth()+1;
	var nowdate=now.getUTCDate();
			
	Listentext=wgUserName+'您好,我是維基娘,今天是'+nowyear+'年'+nowmonth+'月'+nowdate+'日。';
	$('<div id="ListenShowhowing" title="內容顯示器">' +
     '<label>顯示內容:<br/><pre>'+Listentext+'</pre></label><br/>'+
     '</div>'
     ).dialog({
    modal: false,
    autoOpen: true,
    width: 500
     });
    var Voice3 = new SpeechSynthesisUtterance(Listentext);
 	Voice3.lang='zh-TW';
	Voice3.pitch=1.3;
	window.speechSynthesis.speak(Voice3);
}


var Voice = new SpeechSynthesisUtterance(optiontext);
Voice.lang='zh-TW';
Voice.pitch=1.3;

window.speechSynthesis.speak(Voice);

});//end
}