Skip to content

Instantly share code, notes, and snippets.

@oal
Created February 12, 2016 15:53
Show Gist options
  • Save oal/8953fa2a9aff5129570c to your computer and use it in GitHub Desktop.
Save oal/8953fa2a9aff5129570c to your computer and use it in GitHub Desktop.
Quick and dirty userscript that inlines footnotes so I don't have to scroll to the bottom and up again.
// ==UserScript==
// @name Safari Books Online
// @namespace https://www.safaribooksonline.com/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.safaribooksonline.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
setTimeout(function() {
var pointers = document.querySelectorAll('.totri-footnote');
console.log(pointers);
for(var i = 0; i < pointers.length; i++) {
var pointer = pointers[i];
var fnId = pointer.href.split('#')[1];
console.log(fnId);
var fnText = document.querySelector('#'+fnId).innerHTML;
console.log(fnText);
var el = document.createElement('em');
el.innerHTML = fnText;
pointer.parentElement.parentElement.appendChild(el);
}
}, 1500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment