This zone is sleeping right now! ZzzZZzzz

Better not disturb it! ~You go to the petrol station and buy a slushy instead, everything is cool!~

This area will open again in 000.beats!

(Learn about Swatch Time)

Some other zones are awake :^]


Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
a Summer night - @168.88
Activity rating: Three Stars Posts & Arts: 41/1k.beats Random | Recent Posts | Guild Recents
News: There's a great big indie web tomorrow! :smile: Guild Events: There are no events!

+  MelonLand Forum
|-+  Materials & Info
| |-+  ⛄︎ ∙ MelonLand Info & Questions
| | |-+  [FIXED] Rout 66 Chat Mode Mod


« previous next »
Pages: [1] Print Embed
Author Topic: [FIXED] Rout 66 Chat Mode Mod  (Read 201 times)
mrparker
Casual Poster ⚓︎
*
View Profile WWW

⛺︎ My Room

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!Joined 2026!
« on: a Summer night » Embed

Updates:
- Added /say as an alternative to /chat
- Added command aliases /s and /c for /say and /chat! Shorter to type!
- forgot to up the version number again

I made a script that allows you to chat, and to click links in the Melonland chat when in Rout 66 mode.

Some people wanted to be able to click links, and I personally wanted to be able to chat - both without leaving Rout 66 mode. So I made this userscript to allow you to do both.

If you don't have it already, you'll need to use a plugin for your browser called ViolentMonkey, which can be found here:
https://violentmonkey.github.io/

Quick little tutorial on how to use:

- To send a chat message in the normal chat, use the /chat command with your message added
- To click links, click the "Toggle Links" button at the bottom

This script took me an embarrassingly long time to make, primarily cause I had no idea how keyboard input was handled with iframes - something I wish browsers had documentation for!

Anyways, here's the userscript:

Code
// ==UserScript==
// @name        Rout 66 chat enhancer
// @namespace   Violentmonkey Scripts
// @icon        https://forum.melonland.net/apple-touch-icon.png
// @version     1.1.0
//
// @match       https://forum.melonland.net/chat.php*
// @homepageURL https://forum.melonland.net/index.php?topic=5760.msg56075
// @grant       none
// @run-at      document-idle
//
// @author      mrparker
// @description Allows you to still chat and click links in the melonland chat when in Rout 66 mode
// ==/UserScript==

const chatBarSelector = `input[placeholder="Send a chat message... or /help"]` // chatbar inside the route frame
const inputBarInFrame = `div.shoutbox_input_bar` // inside chat iframe (contains chat box and submit buttons)
const melonStreetPaneId = "melon-street-plane" // overlay that prevents clicking links

// Shouldn't ever need to edit anything below
const chatBar = document.querySelector(chatBarSelector)
const melonStreetPane = document.getElementById(melonStreetPaneId)

const setPointerEvents = (enabled) => {
  const autoOrNot = enabled == true ? "auto" : "none"
  const currentlyEnabled = autoOrNot == "auto" ? "none" : "auto"

  melonStreetPane.setAttribute("style", melonStreetPane.getAttribute("style").replace(`pointer-events: ${currentlyEnabled};`, `pointer-events: ${autoOrNot};`))
}

let toggleButton = document.createElement("button")
toggleButton.setAttribute("style", `width: 120px; background-color: blue; color: white; pointer-events: auto; cursor: pointer; border-radius: 12px; height: 25px; margin: 2px 8px;`)
toggleButton.innerHTML = "Toggle Links"
chatBar.parentElement.appendChild(toggleButton)

toggleButton.addEventListener("click", () => { setPointerEvents(melonStreetPane.getAttribute("style").indexOf("pointer-events: none;") != -1 ? true : false) })

document.getElementById("chat-window").addEventListener("load", (e) => {
  const contentDocument = e.target.contentDocument
  const contentWindow = e.target.contentWindow

  const chatBarSubmit = contentDocument.querySelector(`${inputBarInFrame} input[type="submit"]`)
  const chatBarTextBox = contentDocument.querySelector(`${inputBarInFrame} input[type="text"]`)

  const sendMessage = (message) => {
    chatBarTextBox.value = message
    chatBarSubmit.click()

    chatBar.focus()
  }

  Street.registerCommand("chat", sendMessage)
  Street.registerCommand("say", sendMessage)

  Street.registerCommand("s", sendMessage)
  Street.registerCommand("c", sendMessage)
})

Enjoy!

« Last Edit: a Summer night by mrparker » Logged
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 MelonLand Editor Recent Edits Tenement Arcade Want to Login or Join ? Forum Art Hub Chat Webring Web Guides Graphics Catalogue Wiki Newsletters Image Stream
Melon's Sites TamaNotchi Textures PixelSea GifyPet MoMG Ozwomp Online Loom Videos Leaky Webring Melonking
Tools Melon Software ArtHub Embed Maker ML Passports
Outlinks Frutiger Aero Forum Onio Club m15o's Web Services 32Bit Cafe iMood Webrings Internet Phone Book HTML Energy Declarations Hackers & Designers
Zap!
Minecraft: Online
Who: lithiumgamma