Skip to content

Instantly share code, notes, and snippets.

@t-katsushima
Created June 4, 2021 05:05
Show Gist options
  • Save t-katsushima/817cf1ae040b16d92f2dbdf19e6dc21f to your computer and use it in GitHub Desktop.
Save t-katsushima/817cf1ae040b16d92f2dbdf19e6dc21f to your computer and use it in GitHub Desktop.
Toggl にプロジェクト名コピーボタンを生やす
// ==UserScript==
// @name toggl project name extractor
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Toggl にプロジェクト名コピーボタンを生やす
// @author t.katsushima
// @match https://track.toggl.com/timer
// @icon https://www.google.com/s2/favicons?domain=toggl.com
// @grant GM.setClipboard
// ==/UserScript==
(function() {
'use strict';
let button = document.createElement('button');
button.onclick = () => {GM.setClipboard(document.querySelector("span[class*='-ProjectName'] > :first-child").innerText.slice(2))};
button.textContent = "copy";
const setButton = () => {
let a = document.querySelector("[class*='-Container-shrinkableStyles']");
if (a !== null && a.childElementCount >= 3) {
a.removeChild(a.children[2]);
}
if (a !== null) {
a.appendChild(button);
}
}
setInterval(setButton, 500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment