Skip to content

Instantly share code, notes, and snippets.

@alexcberk
Created December 16, 2019 21:52
Show Gist options
  • Select an option

  • Save alexcberk/946f3ffd6f87702f78dd87deebbd20fd to your computer and use it in GitHub Desktop.

Select an option

Save alexcberk/946f3ffd6f87702f78dd87deebbd20fd to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name xkcd title text
// @version 1.0
// @description try to take over the world!
// @author aberk
// @match https://xkcd.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
try {
const custom_comic = document.getElementById('comic');
const custom_parent = document.getElementById('middleContainer');
const custom_hoverText = custom_comic.getElementsByTagName('img')[0].title;
// create a new div element
const newDiv = document.createElement("div");
newDiv.style.cssText = 'padding:20px 0;font-variant: none;font-family:Times;';
// and give it some content
const newContent = document.createTextNode(custom_hoverText);
// add the text node to the newly created div
newDiv.appendChild(newContent);
// add the newly created element and its content into the DOM
custom_parent.insertBefore(newDiv, custom_comic);
} catch (e) {
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment