Skip to content

Commit

Permalink
added chapter links
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintBrit committed Jan 17, 2023
1 parent 1e03a1b commit c7cde9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions chapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function cleanHTML(html, i) {
function cleanHTML(html, i, link) {
var parser = new DOMParser();
console.log("got chapter, parsing");
var doc = parser.parseFromString(html, "text/html");
Expand Down Expand Up @@ -28,24 +28,24 @@ function cleanHTML(html, i) {
if (i != 1) {
// only add the existing notes
if (note1 != null && note2 != null) {
var chapter = "<hr>" + `<h2 class="font-black">${title}</h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML + note2.outerHTML;
var chapter = "<hr>" + `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML + note2.outerHTML;
} else if (note1 != null) {
var chapter = "<hr>" + `<h2 class="font-black">${title}</h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML;
var chapter = "<hr>" + `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML;
} else if (note2 != null) {
var chapter = "<hr>" + `<h2 class="font-black">${title}</h2>` + "<hr>" + chapterText.outerHTML + note2.outerHTML;
var chapter = "<hr>" + `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + chapterText.outerHTML + note2.outerHTML;
} else {
var chapter = "<hr>" + `<h2 class="font-black">${title}</h2>` + "<hr>" + chapterText.outerHTML;
var chapter = "<hr>" + `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + chapterText.outerHTML;
}
} else {
// only add the existing notes
if (note1 != null && note2 != null) {
var chapter = `<h2 class="font-black">${title}</h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML + note2.outerHTML;
var chapter = `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML + note2.outerHTML;
} else if (note1 != null) {
var chapter = `<h2 class="font-black">${title}</h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML;
var chapter = `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + note1.outerHTML + chapterText.outerHTML;
} else if (note2 != null) {
var chapter = `<h2 class="font-black">${title}</h2>` + "<hr>" + chapterText.outerHTML + note2.outerHTML;
var chapter = `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + chapterText.outerHTML + note2.outerHTML;
} else {
var chapter = `<h2 class="font-black">${title}</h2>` + "<hr>" + chapterText.outerHTML;
var chapter = `<h2 class="font-black"><a href="${link}">${title}</a></h2>` + "<hr>" + chapterText.outerHTML;
}
}

Expand Down Expand Up @@ -99,8 +99,8 @@ function prepPage() {
console.log("not signed in");
}

var newTitle = document.title.split(" - ")[1];
console.log("new title: " + newTitle);
var newTitle = document.title.split(" - ");
newTitle = newTitle[newTitle.length - 1];
document.title = newTitle;
var bod = document.querySelector(".portlet-body");
var buttons = bod.querySelector(".nav-buttons");
Expand Down Expand Up @@ -162,7 +162,7 @@ async function insertNewChapter(link, i, isStartingChapter) {
console.log("getting chapter");
const response = await fetch(link);
var html = await response.text();
var contents = cleanHTML(html, i);
var contents = cleanHTML(html, i, link);
var chapterContents = contents[0];
var nextLink = contents[1];

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "An addon that adds an option for reading the full text of a RoyalRoad story.",
"manifest_version": 2,
"name": "RoyalRoad Full Story",
"version": "1.4.0",
"version": "1.5.1",
"homepage_url": "https://github.com/QuintBrit/RoyalRoad-Addon",
"icons": {
"16": "icons/favicon-16x16.png",
Expand Down

0 comments on commit c7cde9a

Please sign in to comment.