Last active
July 7, 2019 17:34
-
-
Save dashedstripes/a6662dab84308eb7c03eb241345ef1d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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