Opera GX Music

Plays Opera GX music forever when opening a page, with a link and ability to stop the music by pressing Alt+5. After stopping the music you can't play it again, but the music gives you some Opera GX vibes.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Opera GX Music
// @description  Plays Opera GX music forever when opening a page, with a link and ability to stop the music by pressing Alt+5. After stopping the music you can't play it again, but the music gives you some Opera GX vibes.
// @version      1
// @license      MIT
// @match        *://*/*
// @grant        none
// @namespace https://greasyfork.org/users/950187
// ==/UserScript==

(function() {
    'use strict';

    // Define the audio file URL and link text
    var audioUrl = "https://res.cloudinary.com/dqzmyiphj/video/upload/v1676545572/operagxmusic_m5p90k.mp3";
    var linkText = "Stop the music (Alt+5)";

    // Create the audio element
    var audio = new Audio(audioUrl);
    audio.loop = true;

    // Add event listener to play the audio when the user interacts with the document
    document.addEventListener("click", function(event) {
        audio.play();
    }, { once: true });

    // Create the link element
    var link = document.createElement("a");
    link.href = "#";
    link.style.position = "fixed";
    link.style.bottom = "0";
    link.style.right = "0";
    link.style.background = "white";
    link.style.color = "black";
    link.style.padding = "10px";
    link.style.border = "1px solid black";
    link.textContent = linkText;
    document.body.appendChild(link);

    // Add event listener to the link to stop the music
    link.addEventListener("click", function(event) {
        event.preventDefault();
        audio.pause();
    });

    // Add event listener to the document to stop the music when Alt+5 is pressed
    document.addEventListener("keydown", function(event) {
        if (event.altKey && event.key === "5") {
            audio.pause();
        }
    });
})();