Greasy Fork

Greasy Fork is available in English.

Open2chの返信音を変える

hayabusaの方

// ==UserScript==
// @name         Open2chの返信音を変える
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  hayabusaの方
// @author       icchi
// @match        https://hayabusa.open2ch.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const targetURLs = {
        'https://image.open2ch.net/lib/sound/sound.mp3': 'https://soundeffect-lab.info/sound/anime/mp3/peta1.mp3',
        'https://image.open2ch.net/lib/sound/drum-japanese2.mp3': 'https://soundeffect-lab.info/sound/anime/mp3/nyu3.mp3'
    };

    const originalAudio = window.Audio;
    window.Audio = function(src) {
        for (const [target, custom] of Object.entries(targetURLs)) {
            if (src && src.includes(target)) {
                console.log(`[Tampermonkey] 音源を置き換え: ${src} → ${custom}`);
                return new originalAudio(custom);
            }
        }
        return new originalAudio(src);
    };

    const originalPlay = HTMLAudioElement.prototype.play;
    HTMLAudioElement.prototype.play = function() {
        for (const [target, custom] of Object.entries(targetURLs)) {
            if (this.src.includes(target)) {
                console.log(`[Tampermonkey] 音源を置き換え: ${this.src} → ${custom}`);
                this.src = custom;
            }
        }
        return originalPlay.call(this);
    };
})();