// ==UserScript== // @name radiko ワンクリックプレイ // @namespace https://yyya-nico.co/ // @version 1.3.1 // @description 選局したらすぐ再生する。 // @author yyya_nico // @license MIT License // @match https://radiko.jp/ // @icon https://www.google.com/s2/favicons?sz=64&domain=radiko.jp // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 監視ターゲットの取得 const target = document.getElementById('contents'); // オブザーバーの作成 const observer = new MutationObserver(records => { records.forEach(record => { if (record.target.id == 'now-programs-list') { const playBtn = Array.from(record.addedNodes) .find(node => node.nodeType == 1/*ELEMENT*/ && node.classList.contains('live-detail__body')) .querySelector('.live-detail__play .btn--play'); if (playBtn != null) { setTimeout(() => playBtn.click(), 50); } observer.disconnect(); } }); }); const options = { //監視オプション childList: true, //直接の子の変更を監視 subtree: true //全ての子要素を監視 } window.addEventListener('hashchange', () => { if(/live/.test(location.hash)) { // 監視の開始 observer.observe(target, options); } }); })();