Greasemonkey:点击按钮播放声音

时间:2016-07-12 08:14:40

标签: javascript greasemonkey

这是一个按钮代码:

      <a href="#" class="lu_button lu_img lb_btn_chart_organisation no_redirect" data-button-id="2" data-issue-id="8568" data-lock-version="1">
        <span class="lu_button_main">Classification</span>
      </a>

我想在点击该按钮时播放声音。我可以用greasemonkey做到吗?

现在它可以使用键盘和“提交”按钮

var player = document.createElement('audio');
player.src = 'https://dl.dropboxusercontent.com/s/xl4r4ocjj8dvtvr/delo-sdelano-delo-sdelano%20%28mp3cut.ru%29.mp3?dl=0';
player.preload = 'auto';

// CTRL+Enter click "Submit" button
(function(){

window.addEventListener('keypress', function(e){
    if (e.ctrlKey && e.keyCode == 13 && e.target.form) {
        if (e.shiftKey) {
            e.target.form.setAttribute('target', '_blank');
        }
        e.target.form.submit();
        e.preventDefault();
        player.play();
        if (e.shiftKey) {
            e.target.form.removeAttribute('target');
        }
    }
}, false);

})();

0 个答案:

没有答案