NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name fivethirtyeight_footnone_expander // @namespace https://fivethirtyeight.com // @description Expands all footnote in fivethirtyeight articles; works even if espn.com is blocked by a Javascript blocker // @include https://fivethirtyeight.com/* // ==/UserScript== var footnote_links = document.getElementsByClassName("espn-footnote-link"); var footnotes = document.getElementsByClassName("espn-footnote-item"); if (footnote_links.length == footnotes.length) { // espn.com not blocked for(var i=0; i < footnotes.length; i++) { footnotes[i].className += " espn-footnote-item-displayed espn-footnote-item-expanded"; } } else { // espn.com is blocked for(var i=0; i < footnote_links.length; i++) { var the_link = footnote_links[i]; var fid = the_link.getAttribute("data-footnote-id"); var fn_outer = document.createElement("span"); fn_outer.className = "espn-footnote-item espn-footnote-item-displayed espn-footnote-item-expanded"; var fn_inner = document.createElement("span"); fn_inner.className = "espn-footnote-item-inner"; var fn_content = document.getElementById("fn-" + fid); fn_inner.appendChild(fn_content.firstChild.cloneNode(true)); fn_outer.appendChild(fn_inner); the_link.parentNode.insertBefore(fn_outer, the_link.nextSibling); } } // if espn.com is disabled: // // 1. find // <a class="espn-footnote-link" data-footnote-id="x" ...> // // 2. after the link, insert // <span class = "espn-footnote-item espn-footnote-item-displayed espn-footnote-item-expanded"> // <span class="espn-footnote-item-inner"> // x_content // </span> // </span> // // 3. set x_content to inner HTML of <li id="fn-x">