Skip to content

Instantly share code, notes, and snippets.

@gregory-seidman
Created July 6, 2021 14:11
Show Gist options
  • Save gregory-seidman/7da728ed31846e7346cd4d2a6d2096f6 to your computer and use it in GitHub Desktop.
Save gregory-seidman/7da728ed31846e7346cd4d2a6d2096f6 to your computer and use it in GitHub Desktop.
// ==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