<commit_before>console.log("starting ficlet");

var urlSplit = document.URL.split('/');
urlSplit.length = 5;
if (urlSplit[2] != "www.fanfiction.net" && urlSplit[2] != "www.fictionpress.com" || urlSplit[3] != "s") {
    alert("Please run this ficlet on a story on www.fanfiction.net or www.fictionpress.com");
    throw("Incompatible webpage.");
}
var baseUrl = urlSplit.join('/') + '/';

var documentTitle = document.title;

var chapStrRaw = document.getElementById('content_wrapper_inner').getElementsByClassName('xgray xcontrast_txt')[0].innerHTML;
var chapStrClean = chapStrRaw.substring(chapStrRaw.indexOf("Chapters"));
chapStrClean = chapStrClean.substring(10, chapStrClean.indexOf(" -"));
var numChapters = parseInt(chapStrClean);

var titleStr = document.getElementsByClassName("xcontrast_txt")[4].innerHTML;
var authorStr = document.getElementsByClassName("xcontrast_txt")[6].innerHTML;

var chapterIdx = 1;
var chapterText = new Array();
var chapterHTML = new Array();
var chapterTitle = new Array();

var downloadFrame = document.createElement('iframe');
downloadFrame.width = screen.availWidth;
downloadFrame.height = 480;
document.body.appendChild(downloadFrame);
downloadFrame.onload = function() {
    chapterText[chapterIdx] = downloadFrame.contentDocument.getElementById("storytext").innerHTML;
    chapterTitle[chapterIdx] = document.getElementById("chap_select").options.item(chapterIdx - 1).innerHTML;
    chapterHTML[chapterIdx] = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" encoding="UTF-8"><head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/><link rel="stylesheet" type="text/css" href="../style.css"/><title>' + chapterTitle[chapterIdx] + '</title></head><body>\n  <h1>' + chapterTitle[chapterIdx] + '</h1><div id="chapterText" class="chapterText">' + chapterText[chapterIdx] + '</div></body></html>';
    console.log("Downloaded chapter " + String(chapterIdx) + "/" + String(numChapters) + ".");
    document.title = '[Downloading][' + String(chapterIdx) + "/" + String(numChapters) + ']' + documentTitle;<commit_msg>Update ficlet.js<commit_after>console.log("starting ficlet");

var urlSplit = document.URL.split('/');
urlSplit.length = 5;
if (urlSplit[2] != "www.fanfiction.net" && urlSplit[2] != "www.fictionpress.com" || urlSplit[3] != "s") {
    alert("Please run ficlet on a story on www.fanfiction.net or www.fictionpress.com");
    throw("Incompatible webpage.");
}
var baseUrl = urlSplit.join('/') + '/';

var documentTitle = document.title;

var chapStrRaw = document.getElementById('content_wrapper_inner').getElementsByClassName('xgray xcontrast_txt')[0].innerHTML;
var chapStrClean = chapStrRaw.substring(chapStrRaw.indexOf("Chapters"));
chapStrClean = chapStrClean.substring(10, chapStrClean.indexOf(" -"));
var numChapters = parseInt(chapStrClean);

var titleStr = document.getElementsByClassName("xcontrast_txt")[4].innerHTML;
var authorStr = document.getElementsByClassName("xcontrast_txt")[6].innerHTML;

var chapterIdx = 1;
var chapterText = new Array();
var chapterHTML = new Array();
var chapterTitle = new Array();

var downloadFrame = document.createElement('iframe');
downloadFrame.width = screen.availWidth;
downloadFrame.height = 480;
document.body.appendChild(downloadFrame);
downloadFrame.onload = function() {
    chapterText[chapterIdx] = downloadFrame.contentDocument.getElementById("storytext").innerHTML;
    chapterTitle[chapterIdx] = document.getElementById("chap_select").options.item(chapterIdx - 1).innerHTML;
    chapterHTML[chapterIdx] = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" encoding="UTF-8"><head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/><link rel="stylesheet" type="text/css" href="../style.css"/><title>' + chapterTitle[chapterIdx] + '</title></head><body>\n  <h1>' + chapterTitle[chapterIdx] + '</h1><div id="chapterText" class="chapterText">' + chapterText[chapterIdx] + '</div></body></html>';
    console.log("Downloaded chapter " + String(chapterIdx) + "/" + String(numChapters) + ".");
    document.title = '[Downloading][' + String(chapterIdx) + "/" + String(numChapters) + ']' + documentTitle;
{'fraction_non_alphanumeric': 0.1807897071872227, 'fraction_numerical': 0.01685891748003549, 'mean_word_length': 6.27258064516129, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 2, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7333443', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1379, 'n_words': 237}