Skip to content

Instantly share code, notes, and snippets.

@michaelfm1211
Created February 5, 2023 17:09
Show Gist options
  • Save michaelfm1211/51739b09808b2814e26d2401187c2b12 to your computer and use it in GitHub Desktop.
Save michaelfm1211/51739b09808b2814e26d2401187c2b12 to your computer and use it in GitHub Desktop.
Tampermonkey script to show Explain XKCD links on xkcd.com
// ==UserScript==
// @name Explain XKCD shortcut
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Shows link to Explain XKCD on xkcd.com
// @author michaelfm1211
// @match https://xkcd.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
const ctitle = document.getElementById('ctitle');
const url = `https://www.explainxkcd.com/wiki/index.php/${location.href.split('/')[3]}`
ctitle.insertAdjacentHTML('beforebegin', `
<div>
<span id="ctitle">${ctitle.textContent}</span>
<a href="${url}" target="_blank" style="font-size: 12px;">explain</a>
</div>`);
ctitle.remove();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment