leetcod AC music feedback

LeetCode AC play music 《Good luck》

Verze ze dne 20. 11. 2021. Zobrazit nejnovější verzi.

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         leetcod AC music feedback
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  LeetCode AC play music 《Good luck》
// @author       WangXiaowu
// @match        https://leetcode.com/*
// @icon         https://www.google.com/s2/favicons?domain=leetcode.com
// @require      http://code.jquery.com/jquery-latest.js
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    let netease_src = "https://m704.music.126.net/20211120101235/597d909fe47e4e1336d43ea96eda127e/jdyyaac/obj/w5rDlsOJwrLDjj7CmsOj/8837130090/e64d/e6e0/76ad/4b9e06388e5bf007db0a99c0170a662c.m4a?authSecret=0000017d3b07043f05c80aaba3b00328";
    let qq_src = "https://dl.stream.qqmusic.qq.com/C400000491MM0CyBv8.m4a?guid=3154030324&vkey=3159164EDCFFAD356C35F3258E781F1FEEB4AB9F2E9A942787D6AA4BC686CE5E239F09722BB8992203AD3DE25D44A80791EB877E0866C1F8&uin=&fromtag=66";
    var player = document.createElement('audio');
    player.src = qq_src;
    var observer = new MutationObserver(function (mutations, me) {
        // `mutations` is an array of mutations that occurred
        // `me` is the MutationObserver instance
        var button =  $("a[data-question-title-slug]").length;
        if (button) {
            if(!player.paused || player.currentTime){
                player.pause();
            }else{
                player.play();
            }
            //me.disconnect(); // stop observing
            return;
        }
    });

    // start observing
    observer.observe(document, {
        childList: true,
        subtree: true
    });


    // Your code here...
})();