From e0470c994a875a7527c540cd9e838b1263ffdc6d Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 06:28:22 -0400 Subject: [PATCH 1/9] Update popup.html Removed QQParser from popup.html --- plugin/popup.html | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugin/popup.html b/plugin/popup.html index 15104b2e..ee900ddc 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -1,4 +1,4 @@ - + @@ -561,7 +561,6 @@

Instructions

- @@ -694,8 +693,6 @@

Instructions

- - From a58395300109a338345809a239bcee90b2c15fd6 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 06:29:21 -0400 Subject: [PATCH 2/9] Update SpacebattlesParser.js Switched QuestionableQuesting to Xenforo under SpaceBattlesParser. --- plugin/js/parsers/SpacebattlesParser.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/js/parsers/SpacebattlesParser.js b/plugin/js/parsers/SpacebattlesParser.js index c6a19463..50abcd83 100644 --- a/plugin/js/parsers/SpacebattlesParser.js +++ b/plugin/js/parsers/SpacebattlesParser.js @@ -3,6 +3,8 @@ parserFactory.register("forums.spacebattles.com", () => new SpacebattlesParser()); parserFactory.register("forums.sufficientvelocity.com", () => new SpacebattlesParser()); parserFactory.register("alternatehistory.com", () => new SpacebattlesParser()); +parserFactory.register("forum.questionablequesting.com", () => new SpacebattlesParser()); +parserFactory.register("questionablequesting.com", () => new SpacebattlesParser()); class SpacebattlesParser extends Parser{ constructor() { From d465a068b1fc95467edbfd117cd3a7ae93cfbaf5 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 06:30:22 -0400 Subject: [PATCH 3/9] Update Util.js Updated filename logic to recognize char 160, the "No-break space" as a separator to change to underscore. \s was an option, but would provide significant changes. --- plugin/js/Util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/js/Util.js b/plugin/js/Util.js index 7d002984..061a9ba6 100644 --- a/plugin/js/Util.js +++ b/plugin/js/Util.js @@ -742,8 +742,8 @@ var util = (function () { var safeForFileName = function (title, maxLength = 20) { if(title) { - // Allow only a-z regardless of case and numbers as well as hyphens and underscores; replace spaces with underscores - title = title.replace(/ /gi, "_").replace(/([^a-z0-9_-]+)/gi, ""); + // Allow only a-z regardless of case and numbers as well as hyphens and underscores; replace spaces and no-break spaces with underscores + title = title.replace(/ | /gi, "_").replace(/([^a-z0-9_-]+)/gi, ""); // There is technically a 255 character limit in windows for file paths. // So we will allow files to have 20 characters and when they go over we split them // we then truncate the middle so that the file name is always different From 747ddc9f6b99334530dce916bf12a63377e244e1 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 06:33:25 -0400 Subject: [PATCH 4/9] Update popup.html Re-adding missing parsers from PR --- plugin/popup.html | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/plugin/popup.html b/plugin/popup.html index ee900ddc..ab39d421 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -1,11 +1,12 @@ + WebToEpub - - + + @@ -125,7 +126,7 @@

Instructions

__MSG_label_Remove_Original__ - + __MSG_label_Password__ @@ -179,7 +180,8 @@

Instructions

- __MSG_label_Lib_Template_Story_URL__ + __MSG_label_Lib_Template_Story_URL__ + @@ -221,7 +223,7 @@

Instructions

- +
__MSG_label_Metadata_description__ __MSG_label_Lib_Warning_In_Progress___
@@ -243,8 +245,10 @@

Instructions

- + @@ -561,6 +565,7 @@

Instructions

+ @@ -693,6 +698,7 @@

Instructions

+ From f513fcc03df3dcf5c7cedc28b950593af0b128e1 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 06:34:23 -0400 Subject: [PATCH 5/9] Delete plugin/js/parsers/QuestionableQuestingParser.js Removed QQ Parser - now under Xenforo/SpacebattlesParser --- .../js/parsers/QuestionableQuestingParser.js | 117 ------------------ 1 file changed, 117 deletions(-) delete mode 100644 plugin/js/parsers/QuestionableQuestingParser.js diff --git a/plugin/js/parsers/QuestionableQuestingParser.js b/plugin/js/parsers/QuestionableQuestingParser.js deleted file mode 100644 index e38d4d85..00000000 --- a/plugin/js/parsers/QuestionableQuestingParser.js +++ /dev/null @@ -1,117 +0,0 @@ -"use strict"; - -parserFactory.register("forum.questionablequesting.com", () => new QuestionableQuestingParser()); -parserFactory.register("questionablequesting.com", () => new QuestionableQuestingParser()); - -class QuestionableQuestingParser extends Parser{ - constructor() { - super(); - this.cache = new FetchCache(); - } - - clampSimultanousFetchSize() { - return 1; - } - - async getChapterUrls(dom) { - let chapters = [...dom.querySelectorAll("div.threadmarkList a.PreviewTooltip")] - .map(a => this.linkToChapter(a)); - this.addAnchorToFirstChapter(chapters, dom); - return chapters; - }; - - addAnchorToFirstChapter(chapters, dom) { - if (chapters.length == 0) { - return; - } - let first = chapters[0]; - let url = new URL(first.sourceUrl); - if (url.hash == "") { - let message = dom.querySelector("li.message"); - if (message != null) { - url.hash = "#" + message.id; - first.sourceUrl = url.href; - } - } - } - - linkToChapter(link) { - let cleanUrl = new URL(link.href); - let path = cleanUrl.pathname.split("/").slice(3, 6).join("/"); - cleanUrl.pathname = path; - return { - sourceUrl: cleanUrl.href, - title: link.innerText.trim(), - newArc: null - }; - } - - findContent(dom) { - return Parser.findConstrutedContent(dom); - }; - - extractTitleImpl(dom) { - return dom.querySelector("div.titleBar h1"); - }; - - extractAuthor(dom) { - let authorLabel = dom.querySelector("a.username"); - return (authorLabel === null) ? super.extractAuthor(dom) : authorLabel.textContent; - }; - - async fetchChapter(url) { - let fetchedDom = await this.cache.fetch(url); - let newDoc = Parser.makeEmptyDocForContent(url); - let id = (new URL(url)).hash.substring(1); - let post = fetchedDom.getElementById(id); - let content = post.querySelector("article"); - this.addTitleToChapter(newDoc, post); - this.removeBlockquotes(content); - this.fixupImageUrls(content); - newDoc.content.appendChild(content); - return newDoc.dom; - } - - fixupImageUrls(content) { - for(let i of content.querySelectorAll("img")) { - let dataUrl = i.getAttribute("data-url"); - if (dataUrl && (i.src !== dataUrl)) { - i.src = dataUrl; - i.removeAttribute("data-url"); - i.removeAttribute("data-src"); - } - this.cleanupMangledImageSrc(i); - } - } - - cleanupMangledImageSrc(img) { - let url = new URL(img.src); - let hostname = url.hostname; - if (hostname.includes("questionablequesting")) { - let path = url.pathname; - let index = path.indexOf("/proxy.php"); - if (0 < index) { - url.pathname = path.substring(index); - } - img.src = url; - } - } - - addTitleToChapter(newDoc, post) { - let titleElement = post.querySelector("span.label"); - let strong = titleElement.querySelector("strong"); - if (strong !== null) { - strong.remove(); - } - let title = newDoc.dom.createElement("h1"); - title.textContent = titleElement.textContent.trim(); - newDoc.content.appendChild(title); - } - - removeBlockquotes(content) { - let blocks = [...content.querySelectorAll("blockquote")]; - for(let block of blocks) { - block.replaceWith(...block.childNodes); - } - } -} From 2c615b6b83c168c2cf32d8db7c0c80c40d478885 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 08:16:35 -0400 Subject: [PATCH 6/9] Update Util.js Replaced nbsp character with unicode identifier --- plugin/js/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/js/Util.js b/plugin/js/Util.js index 061a9ba6..5051f324 100644 --- a/plugin/js/Util.js +++ b/plugin/js/Util.js @@ -743,7 +743,7 @@ var util = (function () { var safeForFileName = function (title, maxLength = 20) { if(title) { // Allow only a-z regardless of case and numbers as well as hyphens and underscores; replace spaces and no-break spaces with underscores - title = title.replace(/ | /gi, "_").replace(/([^a-z0-9_-]+)/gi, ""); + title = title.replace(/ ||\u00a0/gi, "_").replace(/([^a-z0-9_-]+)/gi, ""); // There is technically a 255 character limit in windows for file paths. // So we will allow files to have 20 characters and when they go over we split them // we then truncate the middle so that the file name is always different From f60cffb3ca3b52f0a47e7228e33ee17115fa5d15 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 18:39:23 -0400 Subject: [PATCH 7/9] Update popup.html Reverting several unnecessary changes --- plugin/popup.html | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/plugin/popup.html b/plugin/popup.html index ab39d421..62b83458 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -1,12 +1,11 @@ - - +WebToEpub - - + + @@ -126,7 +125,7 @@

Instructions

- + @@ -180,8 +179,7 @@

Instructions

- -
__MSG_label_Metadata_URL__ - + + +
__MSG_label_Remove_Original__
__MSG_label_Lib_Template_Story_URL__ + __MSG_label_Lib_Template_Story_URL__ @@ -565,7 +563,6 @@

Instructions

- @@ -698,7 +695,6 @@

Instructions

- From 20b510b24ee36d736eecf36a10768ba95d50d878 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 18:43:01 -0400 Subject: [PATCH 8/9] Update popup.html Troubleshooting git's detected changes that don't exist. --- plugin/popup.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/popup.html b/plugin/popup.html index 62b83458..ca5b8b49 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -221,7 +221,7 @@

Instructions

- +
__MSG_label_Metadata_description__ __MSG_label_Lib_Warning_In_Progress___
@@ -243,10 +243,8 @@

Instructions

- + @@ -563,6 +561,7 @@

Instructions

+ @@ -695,6 +694,7 @@

Instructions

+ From 77aef50d6ab0565bde61c4bdbb2492531987d7c2 Mon Sep 17 00:00:00 2001 From: Kiradien <68683574+Kiradien@users.noreply.github.com> Date: Wed, 8 May 2024 06:28:22 -0400 Subject: [PATCH 9/9] Update popup.html Troubleshooting git's detected changes that don't exist. Removed QQParser from popup.html Update Util.js Replaced nbsp character with unicode identifier Delete plugin/js/parsers/QuestionableQuestingParser.js Removed QQ Parser - now under Xenforo/SpacebattlesParser Update Util.js Updated filename logic to recognize char 160, the "No-break space" as a separator to change to underscore. \s was an option, but would provide significant changes. Update SpacebattlesParser.js Switched QuestionableQuesting to Xenforo under SpaceBattlesParser. --- plugin/js/Util.js | 4 +- .../js/parsers/QuestionableQuestingParser.js | 117 ------------------ plugin/js/parsers/SpacebattlesParser.js | 2 + plugin/popup.html | 1 - 4 files changed, 4 insertions(+), 120 deletions(-) delete mode 100644 plugin/js/parsers/QuestionableQuestingParser.js diff --git a/plugin/js/Util.js b/plugin/js/Util.js index 7d002984..5051f324 100644 --- a/plugin/js/Util.js +++ b/plugin/js/Util.js @@ -742,8 +742,8 @@ var util = (function () { var safeForFileName = function (title, maxLength = 20) { if(title) { - // Allow only a-z regardless of case and numbers as well as hyphens and underscores; replace spaces with underscores - title = title.replace(/ /gi, "_").replace(/([^a-z0-9_-]+)/gi, ""); + // Allow only a-z regardless of case and numbers as well as hyphens and underscores; replace spaces and no-break spaces with underscores + title = title.replace(/ ||\u00a0/gi, "_").replace(/([^a-z0-9_-]+)/gi, ""); // There is technically a 255 character limit in windows for file paths. // So we will allow files to have 20 characters and when they go over we split them // we then truncate the middle so that the file name is always different diff --git a/plugin/js/parsers/QuestionableQuestingParser.js b/plugin/js/parsers/QuestionableQuestingParser.js deleted file mode 100644 index e38d4d85..00000000 --- a/plugin/js/parsers/QuestionableQuestingParser.js +++ /dev/null @@ -1,117 +0,0 @@ -"use strict"; - -parserFactory.register("forum.questionablequesting.com", () => new QuestionableQuestingParser()); -parserFactory.register("questionablequesting.com", () => new QuestionableQuestingParser()); - -class QuestionableQuestingParser extends Parser{ - constructor() { - super(); - this.cache = new FetchCache(); - } - - clampSimultanousFetchSize() { - return 1; - } - - async getChapterUrls(dom) { - let chapters = [...dom.querySelectorAll("div.threadmarkList a.PreviewTooltip")] - .map(a => this.linkToChapter(a)); - this.addAnchorToFirstChapter(chapters, dom); - return chapters; - }; - - addAnchorToFirstChapter(chapters, dom) { - if (chapters.length == 0) { - return; - } - let first = chapters[0]; - let url = new URL(first.sourceUrl); - if (url.hash == "") { - let message = dom.querySelector("li.message"); - if (message != null) { - url.hash = "#" + message.id; - first.sourceUrl = url.href; - } - } - } - - linkToChapter(link) { - let cleanUrl = new URL(link.href); - let path = cleanUrl.pathname.split("/").slice(3, 6).join("/"); - cleanUrl.pathname = path; - return { - sourceUrl: cleanUrl.href, - title: link.innerText.trim(), - newArc: null - }; - } - - findContent(dom) { - return Parser.findConstrutedContent(dom); - }; - - extractTitleImpl(dom) { - return dom.querySelector("div.titleBar h1"); - }; - - extractAuthor(dom) { - let authorLabel = dom.querySelector("a.username"); - return (authorLabel === null) ? super.extractAuthor(dom) : authorLabel.textContent; - }; - - async fetchChapter(url) { - let fetchedDom = await this.cache.fetch(url); - let newDoc = Parser.makeEmptyDocForContent(url); - let id = (new URL(url)).hash.substring(1); - let post = fetchedDom.getElementById(id); - let content = post.querySelector("article"); - this.addTitleToChapter(newDoc, post); - this.removeBlockquotes(content); - this.fixupImageUrls(content); - newDoc.content.appendChild(content); - return newDoc.dom; - } - - fixupImageUrls(content) { - for(let i of content.querySelectorAll("img")) { - let dataUrl = i.getAttribute("data-url"); - if (dataUrl && (i.src !== dataUrl)) { - i.src = dataUrl; - i.removeAttribute("data-url"); - i.removeAttribute("data-src"); - } - this.cleanupMangledImageSrc(i); - } - } - - cleanupMangledImageSrc(img) { - let url = new URL(img.src); - let hostname = url.hostname; - if (hostname.includes("questionablequesting")) { - let path = url.pathname; - let index = path.indexOf("/proxy.php"); - if (0 < index) { - url.pathname = path.substring(index); - } - img.src = url; - } - } - - addTitleToChapter(newDoc, post) { - let titleElement = post.querySelector("span.label"); - let strong = titleElement.querySelector("strong"); - if (strong !== null) { - strong.remove(); - } - let title = newDoc.dom.createElement("h1"); - title.textContent = titleElement.textContent.trim(); - newDoc.content.appendChild(title); - } - - removeBlockquotes(content) { - let blocks = [...content.querySelectorAll("blockquote")]; - for(let block of blocks) { - block.replaceWith(...block.childNodes); - } - } -} diff --git a/plugin/js/parsers/SpacebattlesParser.js b/plugin/js/parsers/SpacebattlesParser.js index c6a19463..50abcd83 100644 --- a/plugin/js/parsers/SpacebattlesParser.js +++ b/plugin/js/parsers/SpacebattlesParser.js @@ -3,6 +3,8 @@ parserFactory.register("forums.spacebattles.com", () => new SpacebattlesParser()); parserFactory.register("forums.sufficientvelocity.com", () => new SpacebattlesParser()); parserFactory.register("alternatehistory.com", () => new SpacebattlesParser()); +parserFactory.register("forum.questionablequesting.com", () => new SpacebattlesParser()); +parserFactory.register("questionablequesting.com", () => new SpacebattlesParser()); class SpacebattlesParser extends Parser{ constructor() { diff --git a/plugin/popup.html b/plugin/popup.html index 15104b2e..ca5b8b49 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -695,7 +695,6 @@

Instructions

-
__MSG_label_Metadata_URL__ - - - +