NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Ficbook downloader // @namespace http://tampermonkey.net/ // @version 0.2 // @description Add epub download button for ficbook // @author xomq // @match https://ficbook.net/* // @grant none // @license MIT // ==/UserScript== (function () { function addEpubDownloadButton(elem, url) { let re = new RegExp(/readfic\/([0-9A-z-]*)/); let download_url = url.replace(re, 'fanfic_download/$1/epub'); let btn = document.createElement("a"); btn.classList.add("btn", "btn-primary", "btn-with-description"); btn.href = download_url; let txt_elem = document.createElement("span"); txt_elem.classList.add("description"); txt_elem.innerHTML = "⭳ Epub"; btn.appendChild(txt_elem); elem.appendChild(btn); } let loc = document.location.href; if (loc.includes("ficbook.net/readfic")) { /* fic page */ let actions_container = document.getElementsByClassName("hat-actions-container hidden-xs")[0]; if (actions_container != undefined) { let button_container = actions_container.children[0]; addEpubDownloadButton(button_container, document.location.href); } } else { /* any page with fic list */ let fic_list = document.querySelectorAll("article.fanfic-inline"); fic_list.forEach(function (e) { let link_elem = e.getElementsByClassName("visit-link")[0]; if (link_elem !== undefined) { let item_header = e.getElementsByTagName("h3")[0]; addEpubDownloadButton(item_header, link_elem.href); } }); } })();