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.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();
        }
    });
})();