[Request] Chat script

Does anyone know if it’s maybe possible to create a chat script that makes it possible to chat outside wme?

Then you would have a possibility to have better notifications and a chat history.

Verstuurd vanaf mijn HTC Sensation Z710e met Tapatalk

Like Google hangout?

I imagine he means the WME chat, but in a separate window and with added functionality. So we could still talk to those who rely on WME chat without it blocking half the map.

Sent from my iPhone using Tapatalk 2

^^ Correct.
And also not losing the full history if you press permalink by mistake :wink:

Agree with both…

That’s probably the number one request.

Proof of Concept:
Uses WME event system to receive chat messages, outputs them to console.
The objects it receives can be found in the W.model.chat.messages.models array.

// ==UserScript==
// @name                WME Chat POC
// @description         Proof of concept of hooking into WME's chat.
// @include             https://*.waze.com/editor/*
// @include             https://*.waze.com/*/editor/*
// @include             https://editor-beta.waze.com/*
// @version             0.1
// ==/UserScript==

if ('undefined' == typeof __RTLM_PAGE_SCOPE_RUN__) {
  (function page_scope_runner() {
    // If we're _not_ already running in the page, grab the full source
    // of this script.
    var my_src = "(" + page_scope_runner.caller.toString() + ")();";

    // Create a script node holding this script, plus a marker that lets us
    // know we are running in the page scope (not the Greasemonkey sandbox).
    // Note that we are intentionally *not* scope-wrapping here.
    var script = document.createElement('script');
    script.setAttribute("type", "text/javascript");
    script.textContent = "var __RTLM_PAGE_SCOPE_RUN__ = true;\n" + my_src;

    // Insert the script node into the page, so it will run, and immediately
    // remove it to clean up.  Use setTimeout to force execution "outside" of
    // the user script scope completely.
    setTimeout(function() {
      document.body.appendChild(script);
      document.body.removeChild(script);
    }, 1000);
  })();

  // Stop running, because we know Greasemonkey actually runs us in
  // an anonymous wrapper.
  return;
}

WME_Chat_Version = "v0.1";
console.log("WME-Chat: " + WME_Chat_Version + " starting");

WME_Chat_newMessage = function(e) {
  var now = new Date();
  if (e.attributes.from.name) {
    console.log("Chat: ", now.toLocaleString(), e.attributes.from.name + ":", e.attributes.body); 
  } else {
    console.log("Chat: ", now.toLocaleString(), e.attributes.body); 
  }
}

WME_Chat_Init = function() {
  console.log("WME-Chat: Init");
  W.model.chat.messages.on("add", WME_Chat_newMessage, W.Presenter.Chat);
}

$(document).ready(WME_Chat_Init);

FYI that code isn’t perfect but it’s a starting point for someone. Specifically it doesn’t handle updates to e.attributes.body which happens if there’s no other talker between two separate chat lines from the same person. Fortunately there’s events for that too.

Hi, right now there are any problems with the pop-up chat?

Best regards.

I have been having problems all day — specifically, the chat window does not load at all.

Normally I would direct you to report this problem to the WME feedback thread, but I believe that thread relates to the version which is available only on the North America server right now. Since you’re experiencing it on the ROW server, apparently the editor itself is not the (only) problem.