From 72f499af9e9590c2ec970e05f490a7b2e008d64a Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Wed, 13 Dec 2017 13:15:52 +0100 Subject: [PATCH 1/3] Fix invalid URL errors that prevent loading more than 2 pages Manga Loader on Mangafox on Firefox failed to load more than 2 pages, since it attempted to load `3.html` which is not a valid URL. This commit patches it. --- manga-loader.user.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manga-loader.user.js b/manga-loader.user.js index cc13138..72432eb 100644 --- a/manga-loader.user.js +++ b/manga-loader.user.js @@ -1358,7 +1358,11 @@ var extractInfo = function(selector, mod, context) { case 'a': if(mod.type === 'index') return parseInt(elem.textContent); - return elem.href || elem.getAttribute('href'); + var href = elem.href || elem.getAttribute('href'); + if (!href.startsWith('//') && !href.startsWith('http') && !href.startsWith('#')) { + return window.location.href + "/../" + href; + } + return href; case 'ul': return elem.children.length; case 'select': From 675242c435c5dcb8bd1b50d90edca722dc769c50 Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Thu, 14 Dec 2017 11:37:40 +0100 Subject: [PATCH 2/3] Fix Mangahere loading only 2 pages Mangahere loads page 3 without the protocol in the URL --- manga-loader.user.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manga-loader.user.js b/manga-loader.user.js index 72432eb..edb4230 100644 --- a/manga-loader.user.js +++ b/manga-loader.user.js @@ -1362,6 +1362,9 @@ var extractInfo = function(selector, mod, context) { if (!href.startsWith('//') && !href.startsWith('http') && !href.startsWith('#')) { return window.location.href + "/../" + href; } + if (href.startsWith('//')) { + return window.location.protocol + href; + } return href; case 'ul': return elem.children.length; From c1889d60f0b52a66a2b3b6bfc08140e1f2e51c64 Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Thu, 14 Dec 2017 11:56:39 +0100 Subject: [PATCH 3/3] Correctly derelativise some corner cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are the following cases to derelativise: * //a – just add the protocol to get https://a * /b – just add the host to get http://a/b * b – take everything up to the last slash of the path (the root document always has an implicit slash, so it's fine) from the current URL and add the relative URL – so http://a/b/ + c = http://a/b/c but http://a/b + c = http://a/c --- manga-loader.user.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manga-loader.user.js b/manga-loader.user.js index edb4230..29d9584 100644 --- a/manga-loader.user.js +++ b/manga-loader.user.js @@ -1359,12 +1359,16 @@ var extractInfo = function(selector, mod, context) { if(mod.type === 'index') return parseInt(elem.textContent); var href = elem.href || elem.getAttribute('href'); - if (!href.startsWith('//') && !href.startsWith('http') && !href.startsWith('#')) { - return window.location.href + "/../" + href; + if (!href.startsWith('/') && !href.startsWith('http') && !href.startsWith('#')) { + return /^[^\?\#]*\//.exec(window.location.href) + href; } if (href.startsWith('//')) { return window.location.protocol + href; } + if (href.startsWith('/')) { + // .host contains the port already + return window.location.protocol + '//' + window.location.host + href; + } return href; case 'ul': return elem.children.length;