Command alias - go

Allows to navigate between rooms using '.' as a shortcut

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Command alias - go
// @namespace   https://shinyuu.net
// @match       https://wolfery.com/*
// @grant       none
// @version     1.0
// @author      Shinyuu Wolfy
// @description Allows to navigate between rooms using '.' as a shortcut
// @license     Apache-2.0
// ==/UserScript==

function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                observer.disconnect();
                resolve(document.querySelector(selector));
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}

waitForElm('.console-editor').then(async () => {
  await app.loadBundle({
    tinygo: class {
      constructor(app) {
        this.app = app;

        this.app.require([ 'cmd', 'cmdLists', 'help' ], this._init.bind(this));
      }

      _init(module) {
        this.module = module;
        const ListStep = Object.getPrototypeOf(this.module.cmd.cmds._keys.go.next).constructor;
        this.module.cmd.addCmd({
          key: 'tinygo',
          next: new ListStep('exitId', this.module.cmdLists.getInRoomExits(), {
            name: "exit",
            textId: 'exitKey',
            errRequired: () => new Err('go.exitRequired', "Where do you want to go?"),
          }),
          value: this.go.bind(this),
          symbol: '.',
        });
      }

      go(ctx, p) {
        return ctx.char.call('useExit', p.exitId
          ? { exitId: p.exitId }
          : { exitKey: p.exitKey },
        );
      }
    }
  });
});