Skip to content

Instantly share code, notes, and snippets.

@karacas
Last active February 7, 2020 23:05
Show Gist options
  • Save karacas/755dc3fb478d72f188d792c401f236f3 to your computer and use it in GitHub Desktop.
Save karacas/755dc3fb478d72f188d792c401f236f3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name clickup
// @namespace http://tampermonkey.net/
// @version 0.02
// @description clickup tampermonkey time tracker patch ids
// @author Karacas
// @match *://app.clickup.com/*
// @grant none
// @updateURL https://gist.github.com/karacas/755dc3fb478d72f188d792c401f236f3
// @downloadURL https://gist.github.com/karacas/755dc3fb478d72f188d792c401f236f3
// ==/UserScript==
(function() {
"use strict";
const nameLog = "[clickup tampermonkey time tracker patch ids]";
const patch = () => {
let checkExist = setInterval(function() {
let tasks = document.querySelectorAll("a.cu-reporting__task-info");
tasks.forEach(task => {
if (task.classList.contains("monkied")) return;
task.classList.add("monkied");
const link = task.getAttribute("href");
if (!link) return;
const idLastSlash = link.lastIndexOf("/");
if (idLastSlash < 0) return;
const id = link.slice(idLastSlash + 1);
let title = task.querySelector(".cu-reporting__task-name");
if (!title) return;
title.insertAdjacentHTML(
"afterbegin",
'<div style="display: inline-block; font-size: 14px; font-family: monospace; }">' +
id +
"</div>"
);
// console.log(link, id);
});
}, 100);
console.log(nameLog, "patch");
};
const startCheck = () => {
let checkExist = setInterval(function() {
if (
document.querySelector(
".cu-reporting .time-tracking .cu-reporting__user-name"
)
) {
setTimeout(patch, 100);
clearInterval(checkExist);
}
}, 100);
};
function init() {
console.log(nameLog, "start");
startCheck();
}
window.onload = init;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment