Next, Previous, and play/pause key shortcuts for bandcamp

Allows the left and right keyboard arrows to be used to go to the previous and next songs on bandcamp.

目前为 2019-05-15 提交的版本。查看 最新版本

// ==UserScript==
// @name         Next, Previous, and play/pause key shortcuts for bandcamp
// @description  Allows the left and right keyboard arrows to be used to go to the previous and next songs on bandcamp.
// @author       Zach Saucier
// @namespace    https://zachsaucier.com/
// @version      1.0
// @match        https://bandcamp.com/*
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('keydown', (event) => {
        console.log(event.code);
        switch(event.code) {
            case 'ArrowLeft':
                document.querySelector('.prev-icon').click();
                break;
            case 'ArrowRight':
                document.querySelector('.next-icon').click();
                break;
            case 'Space':
                document.querySelector('.playpause').click();
                event.preventDefault();
                break;
        }
    }, false);
})();