Internet Roadtrip Permanent Radio - WBOR

Override Internet Roadtrip radio with WBOR and shows song info

// ==UserScript==
// @name        Internet Roadtrip Permanent Radio - WBOR
// @namespace   http://tampermonkey.net/
// @match       https://neal.fun/internet-roadtrip/*
// @version     1.2
// @author      TotallyNotSamm
// @description Override Internet Roadtrip radio with WBOR and shows song info
// @license     MIT
// @run-at      document-end
// @require     https://cdn.jsdelivr.net/npm/[email protected]
// @grant       GM_xmlhttpRequest
// @connect     azura.wbor.org
// ==/UserScript==

(async function () {
    if (!IRF.isInternetRoadtrip) return;

    let nowPlayingText = "WBOR 91.1 FM Brunswick, ME";

    // 1. Fetch function using GM_xmlhttpRequest
    function fetchNowPlaying() {
        GM_xmlhttpRequest({
            method: "GET",
            url: "https://azura.wbor.org/api/nowplaying/1",
            onload: async function (response) {
                try {
                    const data = JSON.parse(response.responseText);
                    const song = data[0]?.now_playing?.song || {};
                    const artist = song.artist || "Unknown Artist";
                    const title = song.title || "Unknown Title";

                    // Title first, then artist
                    nowPlayingText = `${title} – ${artist}`;

                    const radio = await IRF.vdom.radio;
                    radio.state.stationInfo = nowPlayingText;
                } catch (e) {
                    console.error("JSON parse error:", e);
                }
            },
            onerror: function (e) {
                console.error("GM_xmlhttpRequest failed:", e);
            }
        });
    }

    fetchNowPlaying();
    setInterval(fetchNowPlaying, 30000);

    // 2. Replace default radio station
    const container = await IRF.vdom.container;
    const originalUpdateData = container.methods.updateData;

    container.state.updateData = new Proxy(originalUpdateData, {
        apply: (target, thisArg, args) => {
            args[0].station = {
                name: "WBOR 91.1 FM",
                url: "https://listen.wbor.org/",
                distance: 0
            };

            IRF.vdom.radio.then(radio => {
                radio.state.stationInfo = nowPlayingText;
            });

            return Reflect.apply(target, thisArg, args);
        }
    });
})();
 	//vibe-coded
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元