Skip to content

Instantly share code, notes, and snippets.

@justinkelly
Last active January 25, 2025 10:34
Show Gist options
  • Save justinkelly/6270613b2bd272e305f79409c4239dc5 to your computer and use it in GitHub Desktop.
Save justinkelly/6270613b2bd272e305f79409c4239dc5 to your computer and use it in GitHub Desktop.
Flatnotes - custom tags UI
// ==UserScript==
// @name Flatnotes - tags UI
// @namespace http://tampermonkey.net/
// @version 1.01
// @description Start note name with {yag}.{sub_tag} -- {name} - like "Work.todo -- Finish website" and i'll be converted to "#Work > todo Finish website"
// @author Justin Kelly
// @match *://192.168.0.2:32771*
// @include *://192.168.0.2:32771*
// @icon https://www.google.com/s2/favicons?sz=64&domain=0.2
// @grant none
// ==/UserScript==
(function() {
'use strict';
function transformSpans() {
const spans = document.querySelectorAll('.items-center span, span.mr-2');
spans.forEach(span => {
const parts = span.textContent.split(' -- ');
const codePart = parts[0];
const description = parts.slice(1).join(' ');
const codeSegments = codePart.split('.');
const hashtag = codeSegments.length > 1
? `#${codeSegments[0]} ${codeSegments.slice(1).map(seg => `> ${seg}`).join(' ')}`
: `#${codeSegments[0]}`;
const newSpan = document.createElement('span');
newSpan.className = 'text-theme-text-muted';
newSpan.textContent = hashtag;
span.innerHTML = '';
span.appendChild(newSpan);
span.appendChild(document.createTextNode(' ' + description));
});
console.log("Executed ully loaded and parsed");
}
window.clearTimeout = window.clearTimeout.bind(window);
window.clearInterval = window.clearInterval.bind(window);
window.setTimeout = window.setTimeout.bind(window);
window.setInterval = window.setInterval.bind(window);
setTimeout(transformSpans, 750);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment