尝试避免使用tampermonkey中的声音文件的非活动选项卡镶边上的间隔

时间:2018-08-31 22:27:33

标签: javascript jquery google-chrome google-chrome-extension howler.js

我正在尝试使用setinterval,因此我为stackoverflow帖子的同一网站创建了另一个脚本,说一个mp3应该使该网站保持活动状态,但是我仍然无法正常工作,这是我的tampermonkey上的howwlr代码:< / p>

// @require https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.15/howler.core.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.15/howler.min.js
// ==/UserScript==

(function() {
    'use strict';


function performance_trick()
{
    if(sounds.empty) return sounds.empty.play();
    sounds.empty = new Howl({
        src: ['http://adventure.land/sounds/loops/empty_loop_for_js_performance.ogg','http://adventure.land/sounds/loops/empty_loop_for_js_performance.wav'],
       volume:0.5,
        autoplay: true, loop: true,
    });
}

performance_trick();

})();

有人知道我在想什么吗?

只检查了错误控制台,就像不工作核心

ReferenceError: sounds is not defined
    at performance_trick (userscript.html?id=8fbfbb66-2c0a-427e-8fd7-9c1d5b47cc87:28)
    at eval (userscript.html?id=8fbfbb66-2c0a-427e-8fd7-9c1d5b47cc87:36)
    at Window.eval (userscript.html?id=8fbfbb66-2c0a-427e-8fd7-9c1d5b47cc87:38)
    at <anonymous>:2:491
    at eval (userscript.html?id=8fbfbb66-2c0a-427e-8fd7-9c1d5b47cc87:2)
    at eval (userscript.html?id=8fbfbb66-2c0a-427e-8fd7-9c1d5b47cc87:3)
    at Object.eval (userscript.html?id=8fbfbb66-2c0a-427e-8fd7-9c1d5b47cc87:39)
    at eval (userscript.html?id=8fbfbb66-2c0a-427e-8fd7-9c1d5b47cc87:41)
    at eval (<anonymous>)
    at <anonymous>:2:491

0 个答案:

没有答案