# \[Request\] Chat script

**URL:** <https://www.waze.com/discuss/t/request-chat-script/216862>\
**Category:** Addons, Extensions, And Scripts\
**Created:** [February 14, 2014, 6:16pm UTC](https://www.waze.com/discuss/t/request-chat-script/216862 "2014-02-14T18:16:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![petervdveen](https://www.waze.com/discuss/letter_avatar_proxy/v4/letter/p/1BAB50/32.png) [@petervdveen](https://www.waze.com/discuss/u/petervdveen)\
**Post date:** [February 14, 2014, 6:16pm UTC](https://www.waze.com/discuss/t/request-chat-script/216862/1 "2014-02-14T18:16:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![orbitc](https://www.waze.com/discuss/user_avatar/www.waze.com/orbitc/32/117035_2.png) [@orbitc](https://www.waze.com/discuss/u/orbitc)\
**Post date:** [February 14, 2014, 7:07pm UTC](https://www.waze.com/discuss/t/request-chat-script/216862/2 "2014-02-14T19:07:10Z")

</div>

> [@petervdveen](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![sketch](https://www.waze.com/discuss/user_avatar/www.waze.com/sketch/32/336_2.png) [@sketch](https://www.waze.com/discuss/u/sketch)\
**Post date:** [February 14, 2014, 10:26pm UTC](https://www.waze.com/discuss/t/request-chat-script/216862/3 "2014-02-14T22:26:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![petervdveen](https://www.waze.com/discuss/letter_avatar_proxy/v4/letter/p/1BAB50/32.png) [@petervdveen](https://www.waze.com/discuss/u/petervdveen)\
**Post date:** [February 14, 2014, 11:04pm UTC](https://www.waze.com/discuss/t/request-chat-script/216862/4 "2014-02-14T23:04:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![orbitc](https://www.waze.com/discuss/user_avatar/www.waze.com/orbitc/32/117035_2.png) [@orbitc](https://www.waze.com/discuss/u/orbitc)\
**Post date:** [February 15, 2014, 1:33am UTC](https://www.waze.com/discuss/t/request-chat-script/216862/5 "2014-02-15T01:33:36Z")

</div>

Agree with both…

That’s probably the number one request.

---

<div class="post-metadata">

**Author:** ![bgodette1](https://www.waze.com/discuss/letter_avatar_proxy/v4/letter/b/963EFF/32.png) [@bgodette1](https://www.waze.com/discuss/u/bgodette1)\
**Post date:** [February 18, 2014, 5:25am UTC](https://www.waze.com/discuss/t/request-chat-script/216862/6 "2014-02-18T05:25:56Z")

</div>

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.

```auto
// ==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);
```

---

<div class="post-metadata">

**Author:** ![bgodette1](https://www.waze.com/discuss/letter_avatar_proxy/v4/letter/b/963EFF/32.png) [@bgodette1](https://www.waze.com/discuss/u/bgodette1)\
**Post date:** [February 18, 2014, 5:33am UTC](https://www.waze.com/discuss/t/request-chat-script/216862/7 "2014-02-18T05:33:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![walbing](https://www.waze.com/discuss/letter_avatar_proxy/v4/letter/w/90959C/32.png) [@walbing](https://www.waze.com/discuss/u/walbing)\
**Post date:** [April 9, 2014, 1:19am UTC](https://www.waze.com/discuss/t/request-chat-script/216862/8 "2014-04-09T01:19:54Z")

</div>

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

Best regards.

---

<div class="post-metadata">

**Author:** ![sketch](https://www.waze.com/discuss/user_avatar/www.waze.com/sketch/32/336_2.png) [@sketch](https://www.waze.com/discuss/u/sketch)\
**Post date:** [April 9, 2014, 1:36am UTC](https://www.waze.com/discuss/t/request-chat-script/216862/9 "2014-04-09T01:36:32Z")

</div>

> [@walbing](#):
>
> 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](https://www.waze.com/forum/viewtopic.php?f=8&t=86708&start=170), 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.
