Skip to content

Instantly share code, notes, and snippets.

@rafuwu
Last active February 14, 2024 10:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafuwu/fcccc9cefabf4c6364847263919fd697 to your computer and use it in GitHub Desktop.
Save rafuwu/fcccc9cefabf4c6364847263919fd697 to your computer and use it in GitHub Desktop.
YNO Expeditions keyboard shortcuts: Press "R" to open the Expeditions window and "T" to cycle between Locations and Vending Machine Finder.
// ==UserScript==
// @name YNO Expeditions keyboard shortcuts
// @name:fr Raccourcis clavier de YNO Expéditions
// @name:pt Atalhos de teclado para Expedições YNO
// @name:ja YNOのドリームラリーキーボードショートカット
// @description Press "R" to open the Expeditions window and "T" to cycle between Locations and Vending Machine Finder.
// @description:fr Appuyez sur "R" pour ouvrir la fenêtre Expéditions et "T" pour passer de Lieux à Distributeur automatique à trouver.
// @description:pt Pressiona "R" para abrir o menu das Expedições e "T" para alternar entre Localizações e Máquina de Venda Automática.
// @description:ja Rキーでドリームラリーウインドウを開閉する。Tキーで世界と自販機の切り替えができます。
// @version 0.9.0
// @namespace https://ynoproject.net/
// @match *://*.ynoproject.net/yume/*
// @match *://*.ynoproject.net/2kki/*
// @match *://*.ynoproject.net/flow/*
// @match *://*.ynoproject.net/unevendream/*
// @match *://*.ynoproject.net/deepdreams/*
// @match *://*.ynoproject.net/prayers/*
// @match *://*.ynoproject.net/someday/*
// @match *://*.ynoproject.net/amillusion/*
// @match *://*.ynoproject.net/muma/*
// @match *://*.ynoproject.net/mikan/*
// @match *://*.ynoproject.net/ultraviolet/*
// @match *://*.ynoproject.net/sheawaits/*
// @author rafuwu
// @homepageURL https://gist.github.com/rafuwu/fcccc9cefabf4c6364847263919fd697
// @license 0BSD
// ==/UserScript==
(function() {
'use strict';
let eventsModal = document.getElementById("eventsModal");
let eventsButton = document.getElementById("eventsButton");
let modalOverlay = document.getElementsByClassName('modalOverlay')[0];
let eventTabLocations = document.getElementById("eventTabLocations");
let eventTabVms = document.getElementById("eventTabVms");
let eventLocationsList = document.getElementById("eventLocationsList");
let eventVmsList = document.getElementById("eventVmsList");
document.addEventListener("keydown", function(event) {
// Only works if the user isn't typing
if (!(event.target.tagName === "INPUT" || event.target.tagName === "TEXTAREA" || event.ctrlKey || event.altKey || event.shiftKey)) {
// When R key is pressed
// Open and close the Expeditions window
if (event.code === "KeyR") {
// The opening and closing behaviour depends on whether the window is already open
if (eventsModal.classList.contains("hidden")) {
eventsButton.click();
} else {
modalOverlay.click();
}
}
// When T key is pressed
// Cycle between "Locations" and "Vending Machine Finder"
if (event.code === "KeyT") {
// Toggle "active" class for the tabs
eventTabLocations.classList.toggle("active");
eventTabVms.classList.toggle("active");
// Toggle "hidden" class for the content
eventLocationsList.classList.toggle("hidden");
eventVmsList.classList.toggle("hidden");
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment