StuckGraber

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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;
            }
        }
    }
})();