Created
June 4, 2021 05:05
-
-
Save t-katsushima/817cf1ae040b16d92f2dbdf19e6dc21f to your computer and use it in GitHub Desktop.
Toggl にプロジェクト名コピーボタンを生やす
This file contains hidden or 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 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