自动播放抓取的音频文件使网页保持前台

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

目前为 2023-07-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         自动播放抓取的音频文件使网页保持前台
// @namespace    Psychiiii.Su
// @version      1.0
// @license      MIT
// @description  Automatically play audio files to keep the webpage in the foreground. 从指定网址抓取音频文件并播放,用于部分网页挂机游戏保持前台,使用时请自行修改@Match以及下面“检查是否在指定网址”中的网址。
// @match        https://ivark.github.io/AntimatterDimensions/*
// @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 === 'https://ivark.github.io/AntimatterDimensions/') {
            // 加载音频文件
            audio.src = audioURL;
            audio.loop = true;
            audio.volume = 0.01;
            audio.play();
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址