NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name XKCD Alt Text and Forums Link // @namespace http://xkcd.com/ // @version 1.0 // @description Displays the Alt Text under the comic, and adds a Forums link under the Blag. // @author LeandroTLZ // @match http://xkcd.com/* // @grant none // ==/UserScript== (function() { 'use strict'; showAltText(); showForumLink(); })(); function showAltText() { var comicDiv = document.getElementById('comic'); if (!comic) return; var altText = comicDiv.getElementsByTagName('img')[0].title; if (!altText) return; var styleDiv = document.createElement('div'); styleDiv.style.margin = '10px 20px'; styleDiv.style.padding = '10px 10px'; styleDiv.style.fontVariant = 'normal'; styleDiv.style.backgroundColor = '#ddd'; styleDiv.style.borderRadius = '5px'; styleDiv.style.border = 'solid 1px #000'; styleDiv.appendChild(document.createTextNode(altText)); comicDiv.appendChild(styleDiv); } function showForumLink() { var topLeft = document.getElementById('topLeft').getElementsByTagName('ul')[0]; if (!topLeft) return; var listItem = document.createElement('li'); var forumLink = document.createElement('a'); forumLink.href = 'http://forums.xkcd.com/'; forumLink.appendChild(document.createTextNode('Forums')); listItem.appendChild(forumLink); topLeft.insertBefore(listItem, topLeft.getElementsByTagName('li')[3]); }