非公開 効果音追加

    @@ -4,58 +4,47 @@ * @private */ javascript:(function(){ - const SOUNDS = { - start: 'https://actions.google.com/sounds/v1/alarms/beep_short.ogg', - kill: 'https://actions.google.com/sounds/v1/cartoon/pop.ogg', - dead: 'https://actions.google.com/sounds/v1/science_fiction/glitch_low_power.ogg', - end: 'https://actions.google.com/sounds/v1/alarms/digital_watch_alarm_long.ogg' + const S = { + s: 'https://actions.google.com/sounds/v1/alarms/beep_short.ogg', + k: 'https://actions.google.com/sounds/v1/cartoon/pop.ogg', + d: 'https://actions.google.com/sounds/v1/science_fiction/glitch_low_power.ogg', + e: 'https://actions.google.com/sounds/v1/alarms/digital_watch_alarm_long.ogg' }; + const play = (u) => { const a = new Audio(u); a.volume = 0.5; a.play().catch(()=>{}); }; - const play = (url) => { - const a = new Audio(url); - a.volume = 0.5; - a.play().catch(()=>{}); + /* 1. キル音の判定(自分の名前が含まれるメッセージを監視) */ + const _ok = window.addKillFeed; + window.addKillFeed = (m) => { + const me = players.find(p => p.id === myId); + if (me && me.name && m.includes(me.name)) play(S.k); + return _ok(m); }; - /* 1. 自分が敵を「倒した時」をフック */ - /* キルフィードにメッセージが追加されるタイミングで、自分のキルかどうか判定 */ - const _origAddKill = window.addKillFeed; - window.addKillFeed = function(msg) { - if (typeof players !== 'undefined' && typeof myId !== 'undefined') { - const me = players.find(p => p.id === myId); - const myName = me ? me.name : ''; - /* メッセージの先頭が自分の名前なら、自分がキルした証拠 */ - if (myName && msg.startsWith(myName)) { - play(SOUNDS.kill); + /* 2. スタート・死亡・復活の監視 */ + let last = 'waiting'; + const _ol = window.loop; + window.loop = () => { + const me = players.find(p => p.id === myId); + if (me) { + /* waiting または dead から active になった瞬間に鳴らす */ + if (last !== 'active' && me.state === 'active') { + play(S.s); + } + /* 生存から死亡(またはゴースト)になった瞬間に鳴らす */ + else if (last === 'active' && (me.state === 'dead' || me.state === 'ghost')) { + play(S.d); } + last = me.state; } - return _origAddKill.apply(this, arguments); + return _ol(); }; - /* 2. スタート / 自分が「倒された時」を監視 */ - let lastState = 'waiting'; - const _origLoop = window.loop; - window.loop = function() { - if (typeof players !== 'undefined' && typeof myId !== 'undefined') { - const me = players.find(p => p.id === myId); - if (me) { - if (lastState !== 'active' && me.state === 'active' && !me.isSpawnWait) { - play(SOUNDS.start); /* スタート・復活 */ - } else if (lastState === 'active' && (me.state === 'dead' || me.isGhost)) { - play(SOUNDS.dead); /* 死亡 */ - } - lastState = me.state; - } - } - return _origLoop.apply(this, arguments); - }; - - /* 3. ラウンド終了をフック */ - const _origResult = window.showResultScreen; + /* 3. リザルト音 */ + const _or = window.showResultScreen; window.showResultScreen = function() { - play(SOUNDS.end); - return _origResult.apply(this, arguments); + play(S.e); + return _or.apply(this, arguments); }; - alert('【自分限定サウンドパッチ】適用!\n自分のキル・死亡・リスポーン時のみ音が鳴ります。'); -})();; + alert('【サウンドパッチ改】\nリスポーン・キル音を最適化しました。'); +})();
  • /*
     * @title 効果音追加
     * @description キル時、ゲーム開始・終了時などに短い効果音が鳴るようになるぞっ
     * @private
     */
    javascript:(function(){
        const S = {
            s: 'https://actions.google.com/sounds/v1/alarms/beep_short.ogg',
            k: 'https://actions.google.com/sounds/v1/cartoon/pop.ogg',
            d: 'https://actions.google.com/sounds/v1/science_fiction/glitch_low_power.ogg',
            e: 'https://actions.google.com/sounds/v1/alarms/digital_watch_alarm_long.ogg'
        };
        const play = (u) => { const a = new Audio(u); a.volume = 0.5; a.play().catch(()=>{}); };
    
        /* 1. キル音の判定(自分の名前が含まれるメッセージを監視) */
        const _ok = window.addKillFeed;
        window.addKillFeed = (m) => {
            const me = players.find(p => p.id === myId);
            if (me && me.name && m.includes(me.name)) play(S.k);
            return _ok(m);
        };
    
        /* 2. スタート・死亡・復活の監視 */
        let last = 'waiting';
        const _ol = window.loop;
        window.loop = () => {
            const me = players.find(p => p.id === myId);
            if (me) {
                /* waiting または dead から active になった瞬間に鳴らす */
                if (last !== 'active' && me.state === 'active') {
                    play(S.s);
                } 
                /* 生存から死亡(またはゴースト)になった瞬間に鳴らす */
                else if (last === 'active' && (me.state === 'dead' || me.state === 'ghost')) {
                    play(S.d);
                }
                last = me.state;
            }
            return _ol();
        };
    
        /* 3. リザルト音 */
        const _or = window.showResultScreen;
        window.showResultScreen = function() {
            play(S.e);
            return _or.apply(this, arguments);
        };
    
        alert('【サウンドパッチ改】\nリスポーン・キル音を最適化しました。');
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2026/05/07 23:23:57 - 2 hours ago
  2. 2026/05/07 23:23:28 - 2 hours ago
  3. 2026/05/07 23:17:52 - 2 hours ago
  4. 2026/05/07 23:11:10 - 2 hours ago
  5. 2026/05/07 23:08:10 - 2 hours ago
  6. 2026/05/07 22:55:07 - 3 hours ago
  7. 2026/05/07 22:53:10 - 3 hours ago
  8. 2026/05/07 22:43:36 - 3 hours ago
  9. 2026/05/07 21:54:00 - 4 hours ago
  10. 2026/05/07 14:27:35 - 11 hours ago