Skip to content

Instantly share code, notes, and snippets.

View Sarapulov's full-sized avatar

Andrey Sarapulov Sarapulov

  • EMEA
View GitHub Profile
@Sarapulov
Sarapulov / widget_jumbo_script_public.html
Last active June 21, 2023 20:17
Zendesk Widget customisation allowing to deeplink particular Widget channels [PUBLIC]. Version of Zendesk Guide.
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<script >
// This is upgraded Zendesk Widget handler script. Ver: 1.11 Updated: 2020-01-14
// It is intended to simplify the control of Widget behaviour through custom JavaScript configuration
// Script is using Widget JS API https://developer.zendesk.com/embeddables/docs/widget/introduction
// Script expects integrated Chat experience to be available
// To run the script follow the steps below:
// 1. update WIDGET_KEY
// 2. Decide which part of the Widget you want to run using runWidgetLogic().init({settings object});
@Sarapulov
Sarapulov / copy_article_url.js
Created November 22, 2019 21:00
Zendesk Help Center JS to inject Copy URL button into article page
// Copy URL sharing button. CSS dependency: .share-url
(function() {
'use strict';
if (window.location.href.indexOf('/articles/') > -1) { // only run on article page
if ( !$('.btn-copy').length ) { // add button if doesn't exist
$('.article-share .share').prepend('<li><a class="btn-copy share-url">Copy URL</a></li>');
$('.btn-copy').on('click', copyStringToClipboard);
}
function copyStringToClipboard(event) { // copy article URL
@Sarapulov
Sarapulov / chat_visilbity_logic.html
Last active April 28, 2020 06:18
Hide/show chat/HC/form based on custom settings
<!-- Custom chat script begin -->
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=3c32985e-0ce9-42ed-9c6f-82ac021f84e7"> </script>
<script>
// This is upgraded Zendesk Widget handler script. Ver: 1.2 Updated: 2019-01-02
// It is intended to simplify the control of Widget behaviour through custom JavaScript configuration
// Script is using Widget JS API https://developer.zendesk.com/embeddables/docs/widget/introduction
// Script expects integrated Chat experience to be available
// To run the script follow the steps below:
// 1. Decide which part of the Widget you want to run using runWidgetLogic().init(true, true, true);
@Sarapulov
Sarapulov / guide_add_test_if_ticket_form.js
Created December 3, 2018 14:24
Guide - add some text/html/image around Attachments area on certain ticket form [LIGHT VERSION]
// Guide form handler script
// Applies light customisation around Attachment area on a specific ticket form
var zdFormHandler = function(){
'use strict';
// Parse URL for form ID
function _getUrlParameter(name, url) {
url = url || window.location.href;
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)','g'), result = regex.exec(url);
return result && result.length ? result[1] : null;
@Sarapulov
Sarapulov / web_widget_chat_departments_filtering_per_tag.js
Created November 27, 2018 12:21
Zendesk Web Widget Chat departments filtering v 1.0.0
/*
Zendesk Web Widget Chat departments filtering v 1.0.0
Script contains of 2 parts:
1. "departments_config" variable that contains JSON configuration
2. Executable JavaScript
departments_config JSON structure (example):
@Sarapulov
Sarapulov / web_widget_idesign.html
Created November 23, 2018 14:46
Example of Web Widget config
<script>
window.zESettings = {
webWidget: {
contactOptions: {
enabled: true
},
contactForm: {
suppress: false,
selectTicketForm: {
'*': 'Vælg dit problem'
@Sarapulov
Sarapulov / web_widget_api_wrapper.js
Last active November 19, 2018 13:24
Zendesk Web Widget API JS wrapper
//// OPTION 1 /////
function ww(prop, params, action) {
return zE('webWidget' + (action ? ':' + action : ''), prop, params);
}
ww('prefill', {
name: {
value: 'isamu',
readOnly: true // optional
@Sarapulov
Sarapulov / show_attachments_email.html
Last active September 22, 2020 18:20
show_attachments_email.html
{% for comment in ticket.comments %}{% capture indent %}{% assign current_index = forloop.index %}{% for i in (1..current_index) %}{% endfor %}{% endcapture %}{{indent}}- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br><i>{{comment.author.name}} wrote on {{comment.created_at}}:</i><br>{{indent}}{{ comment.value_rich }}{% if comment.attachments.size > 0 %}<br>{{indent}}<i>Attachments:</i><br>{% for attachment in comment.attachments %}{{indent}}<a href="{{ attachment.url }}" title="{{ attachment.filename }}">{{ attachment.filename }}</a>{% endfor %}<br>{% endif %}{% endfor %}
@Sarapulov
Sarapulov / full_garden.html
Created August 11, 2018 11:52
Full Zendesk Garden HTML link
<link rel="stylesheet" href="https://cdn.jsdelivr.net/combine/npm/@zendeskgarden/css-utilities@3.0.2,npm/@zendeskgarden/css-tooltips@4.0.5,npm/@zendeskgarden/css-tags@4.0.5,npm/@zendeskgarden/css-tabs@5.0.5,npm/@zendeskgarden/css-tables@3.0.7,npm/@zendeskgarden/css-pagination@3.0.5,npm/@zendeskgarden/css-modals@6.2.2,npm/@zendeskgarden/css-menus@7.0.6,npm/@zendeskgarden/css-grid@0.1.8,npm/@zendeskgarden/css-forms@6.0.7,npm/@zendeskgarden/css-chrome@3.0.7,npm/@zendeskgarden/css-callouts@3.0.5,npm/@zendeskgarden/css-buttons@6.0.5,npm/@zendeskgarden/css-bedrock@7.0.5,npm/@zendeskgarden/css-avatars@3.0.5,npm/@zendeskgarden/css-arrows@3.1.1">
@Sarapulov
Sarapulov / activate_zendesk_brands.js
Created March 14, 2018 14:20
Activate Zendesk brands - run in console
// Activate inactive brands
// run in console
(function() {
function fetchAllBrandsAndActivate (url) {
jQuery.ajax({
url: url,
async: false
}).done(function(data) {
jQuery.each(data.brands,function(i,v){
console.log("CURRENT BRAND: " + v.name + " ::: " + v.brand_url + " ||| " + v.subdomain + " >>> " + v.help_center_state + " <<< " + v.active + " ~~~ " + v.id);