VRChat Random World

Adds a button to find random worlds! Fun yay!!

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        VRChat Random World
// @description Adds a button to find random worlds! Fun yay!!
// @match       https://vrchat.com/home*
// @version     1.0.0
// @author      Laku
// @namespace   https://greasyfork.org/users/1387751
// ==/UserScript==

async function random_world() {
  let json = await fetch("https://vrchat.com/api/1/worlds?n=100&sort=random").then((res) => res.json());
  let world = json[Math.floor(Math.random() * 100)];
  let url = "https://vrchat.com/home/world/" + world.id + "/info";
  window.open(url, '_blank').focus();
}

function add_the_button() {
  let nav = document.querySelector("nav>div");
  let clone = nav.querySelector("[title=worlds]").cloneNode(true);
  clone.setAttribute("style","background: #550239; color: #ff00cb; border-color: #8e063f;");
  clone.removeAttribute("href");
  clone.setAttribute("title", "randomworld");
  clone.onclick = random_world;
  clone.querySelector("div").textContent = "Random World";
  nav.appendChild(clone);
}

(new MutationObserver(check)).observe(document, {childList: true, subtree: true});
function check(changes, observer) {
    if(document.querySelector("nav>div>[title=worlds]")) {
        observer.disconnect();
        add_the_button();
    }
}