Skip to content

Instantly share code, notes, and snippets.

@mikhailsdv
Last active September 10, 2022 08:49
Show Gist options
  • Save mikhailsdv/812bcbee9ec43168972323828d639462 to your computer and use it in GitHub Desktop.
Save mikhailsdv/812bcbee9ec43168972323828d639462 to your computer and use it in GitHub Desktop.
// ==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