// ==UserScript==
// @name WME Forum Chat Indicator
// @description Add indication if user has unread forum chat items
// @namespace https://greasyfork.org/users/gad_m/wme_forum_chat_indicator
// @version 0.1.14
// @author gad_m
// @license MIT
// @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor.*$/
// @exclude https://www.waze.com/user/*editor/*
// @exclude https://www.waze.com/*/user/*editor/*
// @grant GM_xmlhttpRequest
// @connect waze.com
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAMO2lDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnltSSWiBCEgJvQkivUgJoQUQkA42QhIglBgDQcWOLiq4FlREwYauiii6FkDWithdBHtfLKgo62LBrrxJAV32le/N9507/z1z5j9nzp2ZOwOAxnGeRJKLagKQJy6QxoYGspJTUlmkJ4AMtKHQAJHHz5ewY2IiASwD9d/Lu+sAkddXHORc/2z/r0VLIMznA4DEQJwuyOfnQXwAALyaL5EWAECU682nFkjkGArQkcIAIV4kx5lKXC3H6Uq8V2ETH8uBuBUAMo3Hk2YCoN4O9axCfibkUO+F2EksEIkB0GBB7JeXN1kAcRrENtBGArGc3zP9B57Mv3GmD3LyeJmDWDkWRSEHifIlubzp/2c6/nfJy5UN+LCCQsuShsXKxwzzdjNncoQc0yDuEadHRUOsDfEHkUBhDzFKzZKFJSjtUUN+PgfmDDAhdhLwgiIgNoQ4RJwbFanSp2eIQrgQwxmCThMVcOMh1oN4kTA/OE5ls0k6OVblC23IkHLYKv1ZnlThV+7rviwnga3if50l5Kr4MfWirPgkiKkQWxSKEqMgVofYMT8nLkJlM7ooixM1YCOVxcrjt4A4VigODVTyY4UZ0pBYlX1pXv7AeLFNWSJulArvK8iKD1PmB2vl8xTxw7Fg7UIxO2GAR5ifHDkwFoEwKFg5duyZUJwQp+L5ICkIjFX2xamS3BiVPW4mzA2V680gds0vjFP1xRML4IRU8uMZkoKYeGWceFE2LzxGGQ++HEQCDggCLCCDkg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k+YkfE2K1iA+KK2N8LMJHJuCq5SG25efhQYCO1x0WL7xmeTVpWcnH0wOfJgpLNptNmjvvXc7SlcJCLuJwOPi+IsPe/Ee7bW1tktR++7Nn/+R6g4cOl+7V3+O6PWGYC9KD3bjTaGhokKLihkrzFyyUTCYz33c6nR45doDyUwCyzYKCS1L61AwOKD+/wCPvLeNZ9DPxAPJWUm65Z+8+P2pPLrML5Bw8JKVMTONg9u7b72H7WdhhVr2yrMOfxSUl/E9AQADoMFRW3kbt3bswmUzQU6zEDBgADRVKa3MzGhobkUfZ9+OuHVzn6NFjmDIlnfc48qrne6rDejcz5a7eDOW0Z1na5Cn8xmSim7deWrf+a+nmzXLFnOQWO7LWs9iDic9P2JaWFlDK4yJ9jI0cOQIDqfYMiouD0WhEVVUVZ4suAMZgRK9eVJsGoH///h426Fz5K6AbMnxt+wTEBNmBNvqyCw4O8qXnd+1FwDCjfgH5OpEuzqu07z3mVbYvtyBfMj1Z8wuI3dR7KAc9vc5klD1v+eed+wX0vAZfVM/TOl7U0L+l/z+g7pj8B4ED8vOOCcIoAAAAAElFTkSuQmCC
// ==/UserScript==
/* global W */
/* global jQuery */
/* global ChatSDK */
(function() {
console.info('wme-forum-chat-indicator: script loading...');
//"https://www.waze.com/chat/sdk/v1"
const ChatSDK_=function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=4)}([function(e,t,i){(t=i(7)(!1)).push([e.i,".iEq5RN8t4YhcS87dFFLCN{--waze-header-height: 56px;--waze-chat-container-width: 100%;--waze-chat-z-index: var(\n --waze-chat-option-z-index,\n 4\n );--waze-chat-z-index-keyboard-open: 2147483647;--waze-viewport-offset-top: 0px;--waze-chat-offset-bottom: var(--waze-chat-option-offset-bottom, 0px);position:fixed;top:calc(var(--waze-viewport-offset-top) + var(--waze-header-height));right:0;width:var(--waze-chat-container-width);height:calc( var(--waze-viewport-height, 100%) - var(--waze-header-height) - var(--waze-chat-offset-bottom));box-shadow:0 1px 2px 0 rgba(60,64,67,0.3),0 1px 3px 1px rgba(60,64,67,0.15);transform:translateX(100%);transition:all 0.3s ease 0s;transition-property:visibility, transform;visibility:hidden;z-index:var(--waze-chat-z-index)}._18oJSOFPVApLWzpTvysjrb{transform:translateX(0);visibility:visible}._2hSZ_d6Ih8DPXnZSzbiyev{top:var(--waze-viewport-offset-top, 0);height:var(--waze-viewport-height, 100%);z-index:var(--waze-chat-z-index-keyboard-open)}@media not screen and (max-width: 600px){.iEq5RN8t4YhcS87dFFLCN{--waze-header-height: 64px;--waze-chat-container-width: 375px}}.QHePh__PQbIugMr1SN6Sv{position:absolute;width:100%;height:100%;left:0;top:0;border:none}\n",""]),t.locals={container:"iEq5RN8t4YhcS87dFFLCN",containerOpen:"_18oJSOFPVApLWzpTvysjrb",containerKeyboardOpen:"_2hSZ_d6Ih8DPXnZSzbiyev",iframe:"QHePh__PQbIugMr1SN6Sv"},e.exports=t},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppMode=void 0,function(e){e.App="app",e.Embed="embed",e.MobileWeb="mobile-web"}(t.AppMode||(t.AppMode={}))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Orientation=t.DeviceType=void 0,function(e){e.IOS="ios",e.Android="android",e.Other="other"}(t.DeviceType||(t.DeviceType={})),function(e){e.Portrait="portrait",e.Landscape="landscape"}(t.Orientation||(t.Orientation={}))},function(e,t,i){"use strict";var n,o=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},r=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),s=[];function a(e){for(var t=-1,i=0;i<s.length;i++)if(s[i].identifier===e){t=i;break}return t}function c(e,t){for(var i={},n=[],o=0;o<e.length;o++){var r=e[o],c=t.base?r[0]+t.base:r[0],d=i[c]||0,h="".concat(c," ").concat(d);i[c]=d+1;var l=a(h),p={css:r[1],media:r[2],sourceMap:r[3]};-1!==l?(s[l].references++,s[l].updater(p)):s.push({identifier:h,updater:g(p,t),references:1}),n.push(h)}return n}function d(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var o=i.nc;o&&(n.nonce=o)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var s=r(e.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(t)}return t}var h,l=(h=[],function(e,t){return h[e]=t,h.filter(Boolean).join("\n")});function p(e,t,i,n){var o=i?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=l(t,o);else{var r=document.createTextNode(o),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}function u(e,t,i){var n=i.css,o=i.media,r=i.sourceMap;if(o?e.setAttribute("media",o):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var f=null,v=0;function g(e,t){var i,n,o;if(t.singleton){var r=v++;i=f||(f=d(t)),n=p.bind(null,i,r,!1),o=p.bind(null,i,r,!0)}else i=d(t),n=u.bind(null,i,t),o=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else o()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=o());var i=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<i.length;n++){var o=a(i[n]);s[o].references--}for(var r=c(e,t),d=0;d<i.length;d++){var h=a(i[d]);0===s[h].references&&(s[h].updater(),s.splice(h,1))}i=r}}}},function(e,t,i){"use strict";const n=i(5);let o;const r={create:function(e){if(!o){const t=new n.ChatSDK(e);o=t.bootstrap().then(()=>t)}return o}},s=Object.assign(Object.assign({},r),{reset:function(){o=null}});e.exports=s},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ChatSDK=void 0;const o=n(i(6)),r=i(8),s=i(1),a=i(9),c=i(10),d=i(11),h=i(15);class l{constructor(e){var t;this.options=e,this.callbacks=new Set,this.visible=!1,this.unreadCount=0,this.bootstrap=()=>(this.bootstrapPromise||(this.bootstrapPromise=new Promise((e,t)=>{this.initContainer(),this.initIFrame(),this.initMessageService(),this.initVisibilityMessageListener(),this.initUnreadCountMessageListener(),this.receiveReadyMessage().then(e,t)})),this.bootstrapPromise),this.getVisibility=()=>this.visible,this.setVisibility=e=>{this.nonEmptyMessageService.postMessage({type:h.MessageType.ChatSetVisibility,visible:e})},this.startChat=(e,{userName:t,userPhotoUrl:i}={})=>{this.nonEmptyMessageService.postMessage({type:h.MessageType.ChatOpenConversation,userId:e,userName:t,userPhotoUrl:i})},this.getUnreadChatCount=()=>this.unreadCount,this.subscribe=e=>{this.callbacks.add(e)},this.unsubscribe=e=>{this.callbacks.delete(e)},this.execCallbacks=()=>{this.callbacks.forEach(e=>e())},this.initUnreadCountMessageListener=()=>{this.logger.info("setting up listener"),this.nonEmptyMessageService.initListener(e=>{e.type===h.MessageType.ChatUnreadCount&&(this.unreadCount=e.count,this.execCallbacks())})},this.initVisibilityMessageListener=()=>{this.logger.info("setting up listener"),this.nonEmptyMessageService.initListener(e=>{e.type===h.MessageType.ChatVisibility&&(this.visible=e.visible,this.nonEmptyViewport.containerElement.classList.toggle(o.default.containerOpen,e.visible))})},this.receiveReadyMessage=async()=>{this.logger.info("waiting for ready event"),await this.nonEmptyMessageService.receiveMessage(e=>e.type===h.MessageType.ChatReady?e:void 0)},this.logger=new a.ClientLogger("SDK",null!==(t=this.options.verbose)&&void 0!==t&&t),null==this.options.appIdentifierName&&(this.options.appIdentifierName="APP_IDENTIFIER_UNSPECIFIED",this.logger.info(`'options.appIdentifierName' missing. Falling back to default '${this.options.appIdentifierName}'`))}static getBootstrapValue(e){if(void 0===e)throw new Error("please bootstrap first");return e}get nonEmptyViewport(){return l.getBootstrapValue(this.viewport)}get nonEmptyIFrame(){return l.getBootstrapValue(this.iframe)}get nonEmptyMessageService(){return l.getBootstrapValue(this.messageService)}initContainer(){var e;const t=new d.Viewport({className:o.default.container,classNameKeyboardOpen:o.default.containerKeyboardOpen});this.options.zIndex&&t.containerElement.style.setProperty("--waze-chat-z-index",this.options.zIndex),this.options.offsetBottom&&t.containerElement.style.setProperty("--waze-chat-offset-bottom",this.options.offsetBottom),t.init();(null!==(e=this.options.parentNode)&&void 0!==e?e:document.body).appendChild(t.containerElement),this.viewport=t}initIFrame(){this.logger.info("creating iframe");const e=document.createElement("iframe"),t=new URL(`/${r.ChatPathPrefix}/${s.AppMode.Embed}`,location.origin);this.options.locale&&t.searchParams.append("locale",this.options.locale),this.options.verbose&&t.searchParams.append("verbose","1"),this.options.theme&&t.searchParams.append("theme",this.options.theme),t.searchParams.append("app_id",this.options.appIdentifierName),e.src=t.toString(),e.className=o.default.iframe,this.nonEmptyViewport.contentElement.appendChild(e),this.iframe=e}initMessageService(){this.logger.info("creating message service");const e=this.nonEmptyIFrame.contentWindow,t=new URL(this.nonEmptyIFrame.src).origin;this.messageService=new c.MessageService(window,e,t,this.logger)}}t.ChatSDK=l},function(e,t,i){"use strict";i.r(t);var n=i(3),o=i.n(n),r=i(0),s=i.n(r),a={insert:"head",singleton:!1};o()(s.a,a);t.default=s.a.locals||{}},function(e,t,i){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=function(e,t){var i=e[1]||"",n=e[3];if(!n)return i;if(t&&"function"==typeof btoa){var o=(s=n,a=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),r=n.sources.map((function(e){return"/*# sourceURL=".concat(n.sourceRoot||"").concat(e," */")}));return[i].concat(r).concat([o]).join("\n")}var s,a,c;return[i].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(i,"}"):i})).join("")},t.i=function(e,i,n){"string"==typeof e&&(e=[[null,e,""]]);var o={};if(n)for(var r=0;r<this.length;r++){var s=this[r][0];null!=s&&(o[s]=!0)}for(var a=0;a<e.length;a++){var c=[].concat(e[a]);n&&o[c[0]]||(i&&(c[2]?c[2]="".concat(i," and ").concat(c[2]):c[2]=i),t.push(c))}},t}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatSdkPath=t.ChatApiPath=t.SdkPlaygroundPath=t.ChatPlaygroundPath=t.ChatMobileWebAppPath=t.ChatEmbedAppPath=t.ChatAppPath=t.ChatPathPrefix=void 0;const n=i(1);t.ChatPathPrefix="chat",t.ChatAppPath=`${t.ChatPathPrefix}/${n.AppMode.App}(/*)?`,t.ChatEmbedAppPath=`${t.ChatPathPrefix}/${n.AppMode.Embed}(/*)?`,t.ChatMobileWebAppPath=`${t.ChatPathPrefix}/${n.AppMode.MobileWeb}(/*)?`,t.ChatPlaygroundPath=t.ChatPathPrefix+"/playground",t.SdkPlaygroundPath=t.ChatPathPrefix+"/sdk-playground",t.ChatApiPath=t.ChatPathPrefix+"/api",t.ChatSdkPath=t.ChatPathPrefix+"/sdk"},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClientLogger=void 0;t.ClientLogger=class{constructor(e,t){this.name=e,this.verbose=t}info(...e){this.verbose&&console.info(`[${this.name}]`,...e)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MessageService=void 0;t.MessageService=class{constructor(e,t,i,n){this.currentWindow=e,this.targetWindow=t,this.targetOrigin=i,this.logger=n,this.initListener=e=>{const t=t=>{this.logger.info("got message",t.data),t.origin===this.targetOrigin&&e(t.data)};return this.currentWindow.addEventListener("message",t),()=>this.currentWindow.removeEventListener("message",t)},this.receiveMessage=e=>new Promise(t=>{const i=this.initListener(n=>{const o=e(n);o&&(i(),t(o))})}),this.postMessage=e=>{this.logger.info("sending message ",e),this.targetWindow.postMessage(e,this.targetOrigin)}}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Viewport=void 0;const n=i(12),o=i(14),r={interactiveWidgetWorkaroundAllowed:!0};t.Viewport=class{constructor(e){this.options=Object.assign(Object.assign(Object.assign({},r),e)),this.contentElement=document.createElement("div"),this.interactiveWidgetWorkaroundEnabled?(this.containerElement=document.createElement("div"),this.containerElement.appendChild(this.contentElement)):this.containerElement=this.contentElement,this.containerElement.className=e.className,this.visualViewportObserver=new o.VisualViewportObserver(this.containerElement,e)}init(){this.interactiveWidgetWorkaroundEnabled&&(this.setInteractiveWidgetWorkaroundStyle(),this.visualViewportObserver.init())}dispose(){this.interactiveWidgetWorkaroundEnabled&&this.visualViewportObserver.dispose()}get interactiveWidgetWorkaroundEnabled(){return(0,n.isApple)()&&this.options.interactiveWidgetWorkaroundAllowed}setInteractiveWidgetWorkaroundStyle(){this.containerElement.style.overflowY="scroll",this.containerElement.style.overscrollBehavior="none",this.contentElement.style.position="relative",this.contentElement.style.width="100%",this.contentElement.style.height="calc(100% + 1px)",this.contentElement.style.left="0",this.contentElement.style.top="0"}}},function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),o(i(2),t),o(i(13),t)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.identifyBrowser=t.getOrientation=t.isRetina=t.getWidth=t.isMobile=t.isApple=t.isAndroid=t.addDeviceTypeClassToBody=t.getDeviceType=t.identifyDevice=void 0;const n=i(2),o=new URLSearchParams(location.search);let r;function s(e=navigator.userAgent,t=o){const i=t.get("fake_device");return i===n.DeviceType.IOS||i===n.DeviceType.Android||i===n.DeviceType.Other?i:/(iPhone|iPad|iPod)/.test(e)?n.DeviceType.IOS:/Android/.test(e)?n.DeviceType.Android:n.DeviceType.Other}function a(){return null==r&&(r=s()),r}function c(){return a()===n.DeviceType.Android}function d(){return a()===n.DeviceType.IOS}function h(){return a()===n.DeviceType.IOS||a()===n.DeviceType.Android}function l(){return window.innerWidth}function p(){return window.devicePixelRatio>1}function u(){if(null!=window.orientation)return 90===window.orientation||-90===window.orientation?n.Orientation.Landscape:n.Orientation.Portrait}t.identifyDevice=s,t.getDeviceType=a,t.addDeviceTypeClassToBody=function(){document.body.classList.add("device-"+a())},t.isAndroid=c,t.isApple=d,t.isMobile=h,t.getWidth=l,t.isRetina=p,t.getOrientation=u,t.identifyBrowser=function(){return{deviceType:a(),isAndroid:c(),isApple:d(),isMobile:h(),isRetina:p(),orientation:u(),width:l()}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VisualViewportObserver=void 0;t.VisualViewportObserver=class{constructor(e,t={}){this.element=e,this.options=t}init(){this.setViewportPositionStyle(),this.animationFrameRequestId=window.requestAnimationFrame(()=>this.init())}dispose(){void 0!==this.animationFrameRequestId&&(window.cancelAnimationFrame(this.animationFrameRequestId),this.animationFrameRequestId=void 0)}get documentHeight(){return window.document.documentElement.clientHeight}get viewportHeight(){var e,t;return null!==(t=null===(e=window.visualViewport)||void 0===e?void 0:e.height)&&void 0!==t?t:this.documentHeight}get viewportOffsetTop(){var e,t;return null!==(t=null===(e=window.visualViewport)||void 0===e?void 0:e.offsetTop)&&void 0!==t?t:0}get keyboardOpen(){return this.viewportHeight<this.documentHeight}setViewportPositionStyle(){this.element.style.setProperty("--waze-viewport-height",this.viewportHeight+"px"),this.element.style.setProperty("--waze-viewport-offset-top",this.viewportOffsetTop+"px"),this.options.classNameKeyboardOpen&&this.element.classList.toggle(this.options.classNameKeyboardOpen,this.keyboardOpen)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MessageType=void 0,function(e){e.ChatReady="ChatReady",e.ChatUnreadCount="ChatUnreadCount",e.ChatVisibility="ChatVisibility",e.ChatSetVisibility="ChatSetVisibility",e.ChatOpenConversation="ChatOpenConversation"}(t.MessageType||(t.MessageType={}))}]);
const indicatorButtonID = "forum-unread-messages";
let WazeChatSdk;
function createChatSdk_() {
console.debug('wme-forum-chat-indicator: createChatSdk_ creating chat sdk...');
ChatSDK_.create({
locale:"en"
}).then(sdk => {
console.debug('wme-forum-chat-indicator: createChatSdk_ chat sdk created successfully.');
WazeChatSdk = sdk;
sdk.subscribe( () => {
getUnreadChatCount();
});
//getUnreadChatCount();
});
}
function getUnreadChatCount() {
console.debug('wme-forum-chat-indicator: getting unread count...');
let unreadChatCount = WazeChatSdk.getUnreadChatCount();
WazeChatSdk.setVisibility(false);
console.info('wme-forum-chat-indicator: got unread count: ' + unreadChatCount);
handleUI(unreadChatCount);
}
if (typeof W !== 'undefined' && W['userscripts'] && W['userscripts']['state'] && W['userscripts']['state']['isReady']) {
console.debug('wme-forum-chat-indicator: WME is ready.');
createChatSdk_();
} else {
console.debug('wme-forum-chat-indicator: WME is not ready. adding event listener.');
document.addEventListener("wme-ready", createChatSdk_, {
once: true,
});
}
function handleUI(unreadCount) {
console.debug('wme-forum-chat-indicator: handling UI...');
jQuery("#" + indicatorButtonID).remove();
if (unreadCount > 0) {
let clonedObj = jQuery('#save-button').clone().prop('id', indicatorButtonID );
clonedObj.css("align-items", "center");
jQuery(".secondary-toolbar-actions.user-toolbar").prepend(clonedObj);
clonedObj.attr('disabled', false)
let unreadDivI = jQuery('#forum-unread-messages');
unreadDivI.text(unreadCount + " Chat");
clonedObj.attr('title','Unread Chat Count');
clonedObj.on("click", function() {
window.open('https://www.waze.com/forum/', '_blank');
jQuery("#" + indicatorButtonID).remove();
return false;
});
}
console.info('wme-forum-chat-indicator: handling UI done.');
}
}.call(this));