[SomaFM] Never stop playback!

SomaFM web player stops for some reason in any browser. Fix it in a dirty way.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         [SomaFM] Never stop playback!
// @namespace    none
// @version      2024-05-06
// @description  SomaFM web player stops for some reason in any browser. Fix it in a dirty way.
// @author       https://github.com/vasyan
// @match        https://somafm.com/player/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
	'use strict';
	function debounce (func, timeout) {
		var timer;
		return function () {
			clearTimeout(timer);
			timer = setTimeout(function () {
				func.apply(this, arguments);
			}, timeout);
		}
	}

	var reloadPage = debounce(function () {
		console.log('reload')
		location.reload();
	}, 2500);


	// console.log('listen timeupdate', document.querySelector('#audioPlayer audio'), document.querySelector('#audioPlayer audio').paused);
	document.querySelector('#audioPlayer audio').addEventListener('timeupdate', function() {
		// console.log('call debounced');
		reloadPage();
	});



	console.info('SomaFM will never stop!');
})();