From fce223b83a314543a787c8923d81f22665c37e9d Mon Sep 17 00:00:00 2001 From: Tony Luo Date: Wed, 27 Sep 2017 23:47:35 -0700 Subject: [PATCH 1/3] Fixed fetching the urls. --- MangaHere.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/MangaHere.js b/MangaHere.js index ae04742..1655a78 100644 --- a/MangaHere.js +++ b/MangaHere.js @@ -17,7 +17,7 @@ var MangaHere = { //This function must call callback("Mirror name", [returned list]); getMangaList: function (search, callback) { $.ajax({ - url: "http://www.mangahere.co/search.php?name=" + search, + url: "https://www.mangahere.co/search.php?name=" + search, beforeSend: function (xhr) { xhr.setRequestHeader("Cache-Control", "no-cache"); xhr.setRequestHeader("Pragma", "no-cache"); @@ -27,7 +27,7 @@ var MangaHere = { div.innerHTML = objResponse; var res = []; $(".result_search dl dt a:first-child", div).each(function (index) { - res[res.length] = [$(this).text().trim(), $(this).attr("href")]; + res[res.length] = [$(this).text().trim(), this.href]; }); callback("Manga Here", res); } @@ -50,7 +50,8 @@ var MangaHere = { div.innerHTML = objResponse; var res = []; $(".detail_list ul li span.left a", div).each(function (index) { - res[res.length] = [$(this).text().trim(), $(this).attr("href")]; + url = this.href.replace("chrome-extension", "https") + res[res.length] = [$(this).text().trim(), url]; }); callback(res, obj); } @@ -72,9 +73,9 @@ var MangaHere = { name = name.substr(0, name.length - 5).trim(); } currentChapter = $($(".readpage_top .title a", doc)[0]).text(); - currentChapterURL = $($(".readpage_top .title a", doc)[0]).attr("href"); - console.log(currentChapterURL); - currentMangaURL = $($(".readpage_top .title a", doc)[1]).attr("href"); + currentChapterURL = $(".readpage_top .title a", doc)[0].href; + console.log(currentChapterURL); + currentMangaURL = $(".readpage_top .title a", doc)[1].href; callback({ "name": name, "currentChapter": currentChapter, @@ -119,9 +120,9 @@ var MangaHere = { //This method is called before displaying full chapters in the page doSomethingBeforeWritingScans: function (doc, curUrl) { //This function runs in the DOM of the current consulted page. - $("#viewer", doc).empty().append($("
")); - $(".go_page.clearfix", doc).empty(); - $("").appendTo($(".amrcontainer", doc)); + $("#viewer", doc).empty().append($("
")); + $(".go_page.clearfix", doc).empty(); + $("").appendTo($(".amrcontainer", doc)); $("
").appendTo($(".amrcontainer", doc)); $("").appendTo($(".amrcontainer", doc)); }, @@ -176,13 +177,13 @@ var MangaHere = { doAfterMangaLoaded: function (doc, curUrl) { //This function runs in the DOM of the current consulted page. $("body > div:empty", doc).remove(); - var script = doc.createElement('script'); + var script = doc.createElement('script'); script.innerText = "Hotkeys.hotkeys.clear();"; doc.body.appendChild(script); - $(".spanForImg").css("text-align", "left"); + $(".spanForImg").css("text-align", "left"); } }; // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { - registerMangaObject("Manga Here", MangaHere); + registerMangaObject("Manga Here", MangaHere); } From 41871c0e35491a9bf1c34c7e93333c8169755019 Mon Sep 17 00:00:00 2001 From: Tony Luo Date: Thu, 28 Sep 2017 01:53:01 -0700 Subject: [PATCH 2/3] Fixed some issues with fetching image URL --- MangaHere.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MangaHere.js b/MangaHere.js index 1655a78..520f614 100644 --- a/MangaHere.js +++ b/MangaHere.js @@ -27,7 +27,8 @@ var MangaHere = { div.innerHTML = objResponse; var res = []; $(".result_search dl dt a:first-child", div).each(function (index) { - res[res.length] = [$(this).text().trim(), this.href]; + url = this.href.replace("chrome-extension", "https") + res[res.length] = [$(this).text().trim(), url]; }); callback("Manga Here", res); } @@ -73,9 +74,9 @@ var MangaHere = { name = name.substr(0, name.length - 5).trim(); } currentChapter = $($(".readpage_top .title a", doc)[0]).text(); - currentChapterURL = $(".readpage_top .title a", doc)[0].href; + currentChapterURL = $(".readpage_top .title a", doc)[0].href.replace("chrome-extension", "https"); console.log(currentChapterURL); - currentMangaURL = $(".readpage_top .title a", doc)[1].href; + currentMangaURL = $(".readpage_top .title a", doc)[1].href.replace("chrome-extension", "https"); callback({ "name": name, "currentChapter": currentChapter, @@ -90,7 +91,7 @@ var MangaHere = { //This function runs in the DOM of the current consulted page. var res = []; $("select.wid60:first option", doc).each(function (index) { - res[res.length] = $(this).val(); + res[res.length] = $(test).context.URL; }); return res; }, From 6739a442defa4c0c95c0984d231eb7eaed6f054d Mon Sep 17 00:00:00 2001 From: Tony Luo Date: Thu, 28 Sep 2017 02:52:05 -0700 Subject: [PATCH 3/3] Fixed some issues. Now it passes all the Lab tests --- MangaHere.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MangaHere.js b/MangaHere.js index 520f614..29b67a2 100644 --- a/MangaHere.js +++ b/MangaHere.js @@ -91,7 +91,7 @@ var MangaHere = { //This function runs in the DOM of the current consulted page. var res = []; $("select.wid60:first option", doc).each(function (index) { - res[res.length] = $(test).context.URL; + res[res.length] = "https:" + $(this).val(); }); return res; },