diff --git a/plugin/_locales/en/messages.json b/plugin/_locales/en/messages.json index 5ea8862e..f623c7e7 100644 --- a/plugin/_locales/en/messages.json +++ b/plugin/_locales/en/messages.json @@ -255,6 +255,10 @@ "message": "CSS selector for element(s) to remove:", "description": "Label in front input for CCS selector for elements to remove" }, + "__MSG_label_Edit_URLs_Hint__": { + "message": "You can edit the URLs in html format or as a simle URL list (one URL per line).", + "description": "Label in Edit Chapter URLs to help the user." + }, "__MSG_label_Element_With_Chapter_Content__": { "message": "Element with Chapter Content:", "description": "Label in front input for type of element holding each chapter's content" diff --git a/plugin/js/ChapterUrlsUI.js b/plugin/js/ChapterUrlsUI.js index cd8eaee0..af61518f 100644 --- a/plugin/js/ChapterUrlsUI.js +++ b/plugin/js/ChapterUrlsUI.js @@ -280,6 +280,7 @@ class ChapterUrlsUI { document.getElementById("coverUrlSection").hidden = !toTable; document.getElementById("chapterSelectControlsDiv").hidden = !toTable; ChapterUrlsUI.modifyApplyChangesButtons(button => button.hidden = toTable); + document.getElementById("editURLsHint").hidden = toTable; } /** @@ -287,7 +288,15 @@ class ChapterUrlsUI { */ setTableMode() { try { - let chapters = this.htmlToChapters(ChapterUrlsUI.getEditChaptersUrlsInput().value); + let inputvalue = ChapterUrlsUI.getEditChaptersUrlsInput().value; + let chapters; + let lines = inputvalue.split("\n"); + lines = lines.filter(a => a.trim() != "").map(a => a.trim()); + if (URL.canParse(lines[0])) { + chapters = this.URLsToChapters(lines); + } else { + chapters = this.htmlToChapters(inputvalue); + } this.parser.setPagesToFetch(chapters); this.populateChapterUrlsTable(chapters); this.usingTable = true; @@ -318,6 +327,17 @@ class ChapterUrlsUI { return [...doc.body.querySelectorAll("a")].map(a => util.hyperLinkToChapter(a)); } + /** + * @private + */ + URLsToChapters(URLs) { + let returnchapters = URLs.map(e => ({ + sourceUrl: e, + title: "[placeholder]" + })); + return returnchapters; + } + /** @private */ copyUrlsToClipboard() { let text = this.chaptersToHTML([...this.parser.getPagesToFetch().values()]); diff --git a/plugin/js/DefaultParserUI.js b/plugin/js/DefaultParserUI.js index b7f4335b..a82a5963 100644 --- a/plugin/js/DefaultParserUI.js +++ b/plugin/js/DefaultParserUI.js @@ -133,6 +133,7 @@ class DefaultParserUI { if (isVisible) { ChapterUrlsUI.getEditChaptersUrlsInput().hidden = true; ChapterUrlsUI.modifyApplyChangesButtons(button => button.hidden = true); + document.getElementById("editURLsHint").hidden = true; } document.getElementById("defaultParserSection").hidden = !isVisible; } diff --git a/plugin/js/Parser.js b/plugin/js/Parser.js index cd109c4e..40e903d9 100644 --- a/plugin/js/Parser.js +++ b/plugin/js/Parser.js @@ -112,12 +112,19 @@ class Parser { if (title instanceof HTMLElement) { title = title.textContent; } + if (webPage.title == "[placeholder]") { + webPage.title = title.trim(); + } if (!this.titleAlreadyPresent(title, content)) { let titleElement = webPage.rawDom.createElement("h1"); titleElement.appendChild(webPage.rawDom.createTextNode(title.trim())); content.insertBefore(titleElement, content.firstChild); } - }; + } else { + if (webPage.title == "[placeholder]") { + webPage.title = webPage.rawDom.title; + } + } } titleAlreadyPresent(title, content) { diff --git a/plugin/popup.html b/plugin/popup.html index 86419990..810d1a51 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -490,6 +490,7 @@
__MSG_label_Edit_URLs_Hint__