I don't program in JS and much less have experience in JQuery, but I'm taking a look at it. For the most part, some of the Batoto mirror functionality still works (searching for manga), and the code for said mirror is freely available at:
https://github.com/AllMangasReader-dev/mirrors/blob/master/Batoto.js
which means that theres no need to write one from scratch, just update the existing one. Theres also the developer documentation which covers how to add a new mirror (Development tab in AMR extension). The biggest hurdle appears to actually be getting the new mirror to work since the documentation appears to be outdated (makes a reference to a nonexistent JSON object in mgEntry.js?) so using a local mirror isn't directly evident. The only -obvious- option would be to add the mirror to the repository from which the plugin fetches, which would mean contacting the developer to either accept a push to git or add it to the homesites repository. As for the codebase, it doesn't appear all that complex, mostly iterators and jquery selectors.
It's important to note that if one pursues the route of editing Batoto.js and trying to use it locally (without having it uploaded to repo or git), then it will be necessary to also checkout the AMRs project source at:
https://github.com/AllMangasReader-dev/AMR
And run it as a local plugin using Chromes/Chromiums developer mode. Packaging it as a extension and distributing it may also be an option, but that lies beyond my current knowledge.
October 23, 2015
Looking at how it fetches it's mirror lists, it would appear that the software now actually works exclusively with the remote mirrors listed in their website.json. The particular points which make this evident is the call to the JSON file on line 64 of mgEntry.js, verbatim:
$.ajax({
url : amrc_repository + "websites.json",
success : function (resp) {
var ws = resp,
i;
for (i = 0; i < ws.length; i += 1) {
console.log("Load JS from repository for " + ws[i].mirrorName);
loadJSFromRepository(ws[i]);
}
waitForFinishRepository(ws, callback);
},
and yet again when the JSON object is used to build a URL pointing to an external JS resource to be retrieved in loadJSFromRepository:
function loadJSFromRepository(description) {
"use strict";
//New way (CSP with manifest 2) --> store link to js on https to include when needed...
description.jsCode = amrc_repository + description.jsFile;
console.log("insert or update " + description.mirrorName + " in database");
amrcsql.webdb.storeWebsite(description, function () {
description.loaded = true;
});
}
Seeing as theres no fallback for scanning local directories for such a file, it would appear that ones mission, should they choose to accept it, would be to add a condition for the existence of a local repository of mirrors. After that, they would be able to start with the actual work of upgrading the batoto mirror.
It's also interesting to note that should the GET for the website.json file on the home site fail, the fallback on the github site will fail inconditionally due to the fact that the 'amrc_repository = amrc_repository_backup;' on line 124, together with the string concatenation 'amrc_repository + "websites.json?1",' on line 129 will lead to the inexistent content pointed to by the URL 'https://raw.github.com/AllMangasReader-dev/mirrors/master/website.json?1'.
One possible solution to resolving the website.json problem is to add an option to ad an open file dialog on the Supported Websites tab, then insert the content therein into the webdb instance by creating a amrcObject to be used in conjuntion with the storeWebsite() call in amrcsql.js. Afterward it would reload the website listing by refreshing the page.\
October 24, 2015
HTML text is stored in messages.json. Each text is associated with HTML through the u18n attribute in the HTML elements tag. Therefore to add a front-end element one would edit the appropriate HTML file (each navbar entry has an appropriately named HTML file, eg: Options is options.html), using the u18n tag with a unique identifier for any text to be displayed (the HTML is essentially just structure). Afterwards the appropriate text would be placed in messages.json in the _locales folder with the following format:
"u18n_id" : {
"message": "",
"description": ""
},
where u18n_id is the value used for the u18n attribute in the HTML file.
Did a diff (NOTE: URL is only valid for a month) of the manga reader HTML provided by Himena here with the HTML of the same manga page but with the new reader (left-hand side is old page, right-hand side new page). Immediately noticeable is the lack of the 'moderation_bar rounded clear' and associated elements. This (sub)string and the (associated?) select-options structure appears to be part of infrastructure upon which Batoto.js is based (lines 65, 74, 90, 91, and 194 of Batoto.js).
Not sure what is up with the constant use of objResponse.repalce( /<img/gi, '<noload'). There doesn't appear to exist a noload tag in HTML, and I don't understand what purpose removing/invalidating a img tag could serve.
New Batoto reader appears to be based on editing the DOM using JQuery, and some sort of hashing sprinkled in. So it's not actually that the HTML structure isn't there, it's that its there only at runtime. That means just loading the content at the URL is not enough, one has to execute (parse? interpret? Don't know what word to use) it as well. Another possibility is that the page IS being loaded and executed, but that the content being displayed is simply the 'No content selected' page due to the window.location.hash property. EDIT: Read around a bit and it _appears_ that the AJAX call will not evaluate the Javascript within an element as per this question on StackOverflow.
The new Batoto readers readerVerify(n) function is just the Fibonacci sequence. It also redefines the window.alert() function to an empty one, thus suppressing it.
Here iss a function that you can use in your web-browsers JavaScript console to get the HTML that is added during run-time (It's just the readers JS code with a different return value so you can actually see it):
Quote
function loadReader() {
if (window.location.hash.length <= 1) return false;
var split = window.location.hash.substring(1).split('_');
var id = '';
var page = '1';
var suppress = '';
if (split.length === 0) {
return false;
} else if (split.length >= 2) {
page = split[1];
if (split.length === 3) {
suppress = '&supress_webtoon=' + split[2];
}
}
id = split[0];
jQuery.get("/areader?id=" + id + "&p=" + page + suppress, function (data) {
console.log(data);
});
}
That means that the important thing for retrieving the -complete- HTML from Batoto is to run the page in a context where window.location.hash is set to the appropriate value, in this case, the one that appears in your URL when you load the manga.
October 27, 2015
I'll update this post as I review the code. If I get anything real done I'll be sure to share.
P.S.: Sorry for the really slow progress, I'm not all that great with web technology, and easily distracted v_v
Edited by aviar, 25 October 2015 - 04:56 AM.