Skip to content

Instantly share code, notes, and snippets.

@dashedstripes
Last active July 7, 2019 17:34
Show Gist options
  • Save dashedstripes/a6662dab84308eb7c03eb241345ef1d0 to your computer and use it in GitHub Desktop.
Save dashedstripes/a6662dab84308eb7c03eb241345ef1d0 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Zendesk Help Center - Live Update
// @namespace http://pateo.co
// @version 0.1
// @description Fetch local CSS file to render on Zendesk help center
// @author Adam Gray
// @match https://*.zendesk.com/hc/en-us*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let lastSheet = generateStyleID();
function generateStyleID() {
return 'http://localhost:8000/style.css?r=' + Math.random() * 100000000000000000;
}
function appendStyleSheet(url) {
$('body').append('<link rel="stylesheet" href="' + url + '">');
}
function removeStyleSheet(url) {
$('link[rel=stylesheet][href~="' + url + '"]').remove();
}
function reload() {
let thisSheet = generateStyleID();
appendStyleSheet(thisSheet);
setTimeout(() => {
removeStyleSheet(lastSheet);
lastSheet = thisSheet;
}, 100);
}
appendStyleSheet(lastSheet);
setInterval(reload, 2000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment