// ==UserScript== // @name www. // @namespace http://tampermonkey.net/ // @version 0.1 // @description Track customer journey // @author You // @match *.* // @include <*yoursite.com>* // @grant none // ==/UserScript== var routingQueue=""; window._genesys = { widgets:{ main: { lang: "en", i18n: "https://apps.mypurecloud./widgets/9.0/i18n/widgets-en.i18n.json", theme: "light", debug: false, preload: [ "webchat", "webchatservice", "sidebar" ] }, webchat: { uploadsEnabled : true, autoInvite: { enabled: true, timeToInviteSeconds: 10, inviteTimeoutSeconds: 30 }, chatButton: { enabled: false }, transport: { type: "purecloud-v2-sockets", dataURL: "https://api.mypurecloud.", deploymentKey: "", orgGuid: "", interactionData: { routing: { targetType: "Queue", targetAddress: routingQueue, priority: 2 } } }, form: { wrapper: "
", inputs: [{ id: "cx_webchat_form_firstname", name: "firstname", maxlength: "100", placeholder: "@i18n:webchat.ChatFormPlaceholderFirstName", label: "@i18n:webchat.ChatFormFirstName", }, { id: "cx_webchat_form_lastname", name: "lastname", maxlength: "100", placeholder: "@i18n:webchat.ChatFormPlaceholderLastName", label: "@i18n:webchat.ChatFormLastName", }, { id: "cx_webchat_form_language_select", name: "preferredTheme", type: "select", label: "Select the Theme", options: [{name:"No Lang Preference",value:"General",text:"General"},{name:"English",value:"Hosting",text:"Hosting"},{name:"Chinese",value:"Server",text:"Server"},{name:"Bahasa",value:"SMB",text:"SMB"}] }] }, userData: { customField1Label: "Co-browse Page", customField1: "https://cobrowse.mypurecloud./v/?autoJoin=true", country : "UK", } }, sidebar: { showOnStartup: true, position: 'right', expandOnHover: true, channels: [{ name: 'chat', clickCommand: 'WebChat.open', readyEvent: 'WebChat.ready', displayName: "@i18n:webchat.ChatTitle", icon: "chat" }, { name: 'cobrowse', clickCommand: null, readyEvent: null, displayName: "@i18n:callus.CoBrowse", icon: "cobrowse", onClick: function() { startCoBrowse(); } }] } } }; var widgetBaseUrl = 'https://apps.mypurecloud./widgets/9.0/' , widgetScriptElement = document.createElement('script'); widgetScriptElement.setAttribute('src', widgetBaseUrl + 'cxbus.min.js'); widgetScriptElement.addEventListener('load', function () { CXBus.configure({ debug: false, pluginsPath: widgetBaseUrl + 'plugins/' }); CXBus.loadPlugin('widgets-core'); }); document.head.append(widgetScriptElement); var widgetScriptElement2 = document.createElement('script'); widgetScriptElement2.setAttribute('src', 'https://cobrowse.mypurecloud./cobrowse-jsapi-v1.js?deploymentKey='); widgetScriptElement2.addEventListener('load', function () { window.startCoBrowse = function() { window.PureCloud.cobrowse.startSharing({ locale: 'en', participant: { displayName: 'Customer' } }, function(err, sharerSession) { if (err) { console.error('Unable to share page', (err.stack || err)); } console.log('Co-browse initiated. Page is being shared.'); if (window._genesys.widgets !== 'undefined') { //var message = '**Customer has started a Co-browse session:** Please right click on this [link]('+ sharerSession.getViewerUrl() +') and select to open in a new browser tab'; var message = '** The customer requested a co-browse session: ** Please enter this session ID in your script window: ' + sharerSession.getCobrowseSession().data.code; CXBus.command('WebChatService.sendFilteredMessage', { message: message, regex: /\*\*The customer requested a co-browse session:\*\*.*/ }); } }); } }); document.head.append(widgetScriptElement2);