Created
July 6, 2021 14:11
-
-
Save gregory-seidman/7da728ed31846e7346cd4d2a6d2096f6 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 XKCD hover text | |
// @version 1 | |
// @include https://xkcd.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const id = "comic-title"; | |
const css = ` | |
#${id} { | |
border: 4px solid gray; | |
color: gray; | |
background: gray; | |
margin: 10px; | |
} | |
#${id}:hover { | |
opacity: 1.0; | |
border-color: green; | |
color: black; | |
background: #DDDDDD; | |
} | |
`; | |
const div = document.getElementById("comic"); | |
const img = div.firstElementChild; | |
const text = document.createElement("h2"); | |
const style = document.createElement("style"); | |
text.innerText = img.title; | |
text.id = id; | |
div.appendChild(text); | |
style.innerText = css; | |
document.head.appendChild(style); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment