StuckGraber

抓取在线音乐播放器正在播放的歌曲并下载,支持QQ音乐,酷狗音乐,酷我音乐,咪咕音乐

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         StuckGraber
// @namespace    copws.github.io/StackGraber
// @version      0.1
// @description  抓取在线音乐播放器正在播放的歌曲并下载,支持QQ音乐,酷狗音乐,酷我音乐,咪咕音乐
// @author       copcin
// @match        https://y.qq.com/n/ryqq/player
// @match        https://www.kugou.com/song/*
// @match        https://www.kuwo.cn/play_detail/*
// @match        https://music.migu.cn/v3/music/player/audio
// @license      GNU GPLv3
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    window.onload = function() {
        HotKeyHandler.Init();
    }
    var HotKeyHandler = {
        currentMainKey: null,
        currentValueKey: null,
        Init: function() {
            HotKeyHandler.Register(0, "D",
            function() {
                var audios = document.getElementsByTagName("audio");
                GM_setClipboard(audios[0].src);
                alert("下载链接已复制到剪贴板");
            });
        },
        Register: function(tag, value, func) {
            var MainKey = "";
            switch (tag) {
            case 0:
                MainKey = 17; //Ctrl
                break;
            case 1:
                MainKey = 16; //Shift
                break;
            case 2:
                MainKey = "18"; //Alt
                break;
            }
            document.onkeyup = function(e) {
                HotKeyHandler.currentMainKey = null;
            }
            document.onkeydown = function(event) {
                //获取键值
                var keyCode = event.keyCode;
                var keyValue = String.fromCharCode(event.keyCode);
                event.preventDefault();
                if (HotKeyHandler.currentMainKey != null) {
                    if (keyValue == value) {
                        HotKeyHandler.currentMainKey = null;
                        if (func != null) func();
                    }
                }
                if (keyCode == MainKey) HotKeyHandler.currentMainKey = keyCode;
            }
        }
    }
})();