Last active
September 10, 2022 08:49
-
-
Save mikhailsdv/812bcbee9ec43168972323828d639462 to your computer and use it in GitHub Desktop.
This file contains 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 Tailwind copy classes | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Copy Tailwind classes to clipboard by clicking them. | |
// @author https://github.com/mikhailsdv | |
// @match https://tailwindcss.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=tailwindcss.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
"use strict"; | |
const classSelector = "table tr td:nth-child(1)" | |
const style = document.createElement("style") | |
style.innerHTML = ` | |
${classSelector} { | |
cursor: pointer; | |
} | |
` | |
document.head.appendChild(style) | |
document.documentElement.addEventListener("click", e => { | |
const classes = Array.from(document.querySelectorAll(classSelector)) | |
if (classes.includes(e.target)) { | |
navigator.clipboard.writeText(e.target.innerText) | |
} | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment