NHK日本国际传媒是日本公共传媒机构NHK的对外播出平台,通过电视、广播以及互联网,向全球受众提供日本乃至亚洲的最新资讯。本脚本对音频播放进行了修改,将其固定到了右下角,并添加了循环播放和倍速播放两个功能。
// ==UserScript==
// @name NHK新闻
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @AuThor You
// @match https://www3.nhk.or.jp/news/easy/*
// @Icon https://www.google.com/s2/favicons?sz=64&domain=nhk.or.jp
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.onload = function() {
document.querySelector("#easy-wrapper > div.l-container > main > article > div.article-main__tools").setAttribute('style', 'transform:scale(0.8);z-index:100;position: fixed;right: 0; bottom: 0;');
setTimeout(function() {
document.getElementsByClassName('toggle-audio')[0].click()
}, 2000);
setTimeout(function() {
console.log('start')
var div=document.createElement("div");
div.style="position: absolute;left:40%;top:25%"
div.innerHTML='<button id="loopBtn" style="background-color:#2E6EBD;border-radius: 50px 50px 50px 50px ; font-weight: 900;color:#FFFFFF;padding:10px ">重复播放</button><select id="speed" style="padding:12px;border-radius: 50px 50px 50px 50px;margin-left:10px "><option value="2" style="font-weight:900">2倍速</option><option value="1" selected="" style="font-weight:900";>正常速度</option><option value="0.5" style="font-weight:900">0.5倍速</option></select>'
var share=document.getElementsByTagName('iframe')[document.getElementsByTagName('iframe').length-1 ].contentDocument.getElementsByTagName('iframe')[0].contentDocument.querySelector(' div.vjs-control-bar');
var zs=document.getElementsByTagName('iframe')[document.getElementsByTagName('iframe').length-1 ].contentDocument.getElementsByTagName('iframe')[0].contentDocument.querySelector('button.vjs-play-control');
share.insertBefore(div, zs);
var audio=document.getElementsByTagName('iframe')[document.getElementsByTagName('iframe').length-1 ].contentDocument.getElementsByTagName('iframe')[0].contentDocument.getElementsByTagName('audio')[0]
let loop = false;
var select=document.getElementsByTagName('iframe')[document.getElementsByTagName('iframe').length-1 ].contentDocument.getElementsByTagName('iframe')[0].contentDocument.getElementById('speed')
var lbtn=document.getElementsByTagName('iframe')[document.getElementsByTagName('iframe').length-1 ].contentDocument.getElementsByTagName('iframe')[0].contentDocument.getElementById('loopBtn')
lbtn.addEventListener('click',() => {
loop = !loop;
if(loop) {
// 设置循环播放
audio.loop = true;
lbtn.textContent = '取消重复播放';
} else {
// 取消循环播放
audio.loop = false;
lbtn.textContent = '重复播放';
}
} );
select.addEventListener('change', (e) => {
audio.playbackRate = e.target.value;
});
}, 10000);
}
// Your code here...
})();
|