Skip to content

Instantly share code, notes, and snippets.

@einars
Created May 23, 2018 15:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einars/c6a20fbce6cc83b4473e66182e0e6ba3 to your computer and use it in GitHub Desktop.
Save einars/c6a20fbce6cc83b4473e66182e0e6ba3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Restore title to workflowy tags
// @namespace Violentmonkey Scripts
// @match https://workflowy.com/*/*
// @grant none
// ==/UserScript==
let timer = void 0
const update_tags = () => {
const elems = document.getElementsByClassName('contentTag')
Array.prototype.map.call(elems, (e) => {
if ( ! e.class_added) {
e.class_added = true
const child = Array.prototype.find.call(e.childNodes, (n) => (n.className == 'contentTagText'))
if (child) {
e.className = 'contentTag ' + ('tag-' + child.innerHTML).replace(/[#@]/g, '')
}
}
})
}
const queue_tag_update = () => {
window.clearTimeout(timer)
timer = window.setTimeout(update_tags, 300)
}
window.onload = () => {
queue_tag_update()
window.addEventListener('keydown', queue_tag_update, { passive: true, capture: true })
window.addEventListener('click', queue_tag_update, { passive: true, capture: true })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment