🏠 Home 

自动播放抓取的音频文件使网页保持前台(挂机游戏)

Automatically play audio files to keep the webpage in the foreground. 从指定网址抓取音频文件并播放,用于部分网页挂机游戏保持前台,使用时请自行修改@Match以及下面“检查是否在指定网址”中的网址。


Install this script?
// ==UserScript==
// @name         自动播放抓取的音频文件使网页保持前台(挂机游戏)
// @namespace    Psychiiii.Su
// @version      1.3
// @license      MIT
// @description  Automatically play audio files to keep the webpage in the foreground. 从指定网址抓取音频文件并播放,用于部分网页挂机游戏保持前台,使用时请自行修改@Match以及下面“检查是否在指定网址”中的网址。
// @match        *://*.itch.io/*
// @grant        none
// ==/UserScript==
(function() {
'use strict';
// 音频文件的URL
var audioURL = 'https://download.samplelib.com/mp3/sample-9s.mp3';
// 创建音频元素
var audio = new Audio();
// 监听页面加载完成事件
window.addEventListener('load', function() {
// 检查是否在指定网址
if (window.location.href.indexOf('itch.io') !== -1) {
// 加载音频文件
audio.src = audioURL;
audio.loop = true;
audio.volume = 0.01;
audio.play();
}
});
})();