From e8f2fcc4e697c13505415ff7b7fb2b440b1bfd3c Mon Sep 17 00:00:00 2001 From: Daku Date: Mon, 25 Jan 2016 07:10:45 +0000 Subject: [PATCH] normalize line endings with .gitattributes + remove any trailing whitespace This avoids issues with committing via different kinds of OS's. --- .gitattributes | 2 + AdultManga.js | 439 ++++++++++++++++------------------ AkumaScan.js | 255 ++++++++++---------- AnarchyScans.js | 255 ++++++++++---------- AngelScanlator.js | 424 ++++++++++++++++----------------- AnimeA.js | 245 ++++++++++--------- AnimeStory.js | 428 ++++++++++++++++----------------- Animexis.js | 420 +++++++++++++++------------------ Animextremist.js | 575 +++++++++++++++++++++------------------------ BacaManga.js | 422 +++++++++++++++------------------ Batoto.js | 412 ++++++++++++++++---------------- CXCScans.js | 258 ++++++++++---------- CentralDeMangas.js | 451 +++++++++++++++++------------------ CityManga.js | 443 ++++++++++++++++------------------ ClockworkLies.js | 85 ++++--- DragonFlyScans.js | 265 +++++++++++---------- DynastyScans.js | 243 ++++++++++--------- EJapanzai.js | 333 +++++++++++++------------- EasyGoing.js | 259 ++++++++++---------- EatManga.js | 465 +++++++++++++++++------------------- EvilFlowers.js | 255 ++++++++++---------- ExtrasScans.js | 263 +++++++++++---------- FTHScans.js | 263 +++++++++++---------- FoolRulez.js | 251 ++++++++++---------- GaoSubs.js | 281 +++++++++++----------- GodHandScans.js | 424 ++++++++++++++++----------------- GoodManga.js | 243 ++++++++++--------- Haruka.js | 423 ++++++++++++++++----------------- HimawariMangas.js | 512 +++++++++++++++++++--------------------- Imangascans.js | 283 +++++++++++----------- ImperialScans.js | 458 +++++++++++++++++------------------- ItaScan.js | 429 ++++++++++++++++----------------- Japanzai.js | 323 +++++++++++++------------ KawaiiScans.js | 263 +++++++++++---------- LICENSE | 123 +--------- MCReborn.js | 420 +++++++++++++++------------------ Manga24.js | 518 +++++++++++++++++++--------------------- Manga2u.js | 317 +++++++++++++------------ MangaAccess.js | 415 +++++++++++++++----------------- MangaAr.js | 271 +++++++++++---------- MangaChapter.js | 407 ++++++++++++++++---------------- MangaEden_en.js | 469 +++++++++++++++++------------------- MangaEden_it.js | 469 +++++++++++++++++------------------- MangaExceed.js | 9 +- MangaFox.js | 417 ++++++++++++++++---------------- MangaHead_en.js | 483 ++++++++++++++++++------------------- MangaHead_raw.js | 483 ++++++++++++++++++------------------- MangaHere.js | 392 ++++++++++++++---------------- MangaIR.js | 437 ++++++++++++++++------------------ MangaInn.js | 269 +++++++++++---------- MangaKong.js | 415 +++++++++++++++----------------- MangaLib.js | 275 +++++++++++----------- MangaPirate.js | 253 ++++++++++---------- MangaReader.js | 249 ++++++++++---------- MangaStream.js | 289 ++++++++++++----------- MangaTraders.js | 491 ++++++++++++++++++-------------------- MangaTurk.js | 422 +++++++++++++++------------------ MangaYobai.js | 275 ++++++++++------------ Mangable.js | 452 ++++++++++++++++------------------- Mangacurse.js | 423 ++++++++++++++++----------------- Mangaholic.js | 263 +++++++++++---------- Mangajoy.js | 357 ++++++++++++++-------------- MangasProject.js | 538 ++++++++++++++++++++---------------------- MenudoFansub.js | 263 +++++++++++---------- MudaScantrad.js | 263 +++++++++++---------- Otakuyo.js | 423 ++++++++++++++++----------------- OurManga.js | 299 ++++++++++++----------- PunchMangas.js | 423 +++++++++++++++------------------ Pururin.js | 423 ++++++++++++++++----------------- ReadManga.js | 277 +++++++++++----------- Redhawkscans.js | 265 +++++++++++---------- S2scans.js | 281 +++++++++++----------- SimpleScans.js | 259 ++++++++++---------- StopTazmo.js | 267 +++++++++++---------- SubManga.js | 442 ++++++++++++++++------------------ TenManga.js | 568 +++++++++++++++++++++----------------------- ThHour.js | 264 +++++++++++---------- TheSpectrum.js | 409 ++++++++++++++++---------------- Titania.js | 478 ++++++++++++++++++------------------- Trinitybakuma.js | 359 ++++++++++++++-------------- TwinDragons.js | 414 +++++++++++++++----------------- UnixManga.js | 562 +++++++++++++++++++++----------------------- VNSharing.js | 450 ++++++++++++++++------------------- Vortex.js | 269 +++++++++++---------- WhuaMangas.js | 251 ++++++++++---------- amanteanime.js | 207 ++++++++-------- kireicake.js | 259 ++++++++++---------- mangapanda.js | 305 ++++++++++++------------ 88 files changed, 14651 insertions(+), 15980 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cf604fa --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set the default line endings. This avoids issues with committing via different kinds of OS's. +* text=auto \ No newline at end of file diff --git a/AdultManga.js b/AdultManga.js index f80b5af..f29387f 100644 --- a/AdultManga.js +++ b/AdultManga.js @@ -1,238 +1,209 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var AdultManga = { - //Name of the mirror - mirrorName : "AdultManga", - //True if the mirror can list all of its mangas. - canListFullMangas : false, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/readmanga.png", - //Languages of scans for the mirror - languages : "ru", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("adultmanga.ru/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://adultmanga.ru/search", - type: 'POST', - data: {q: search}, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#mangaResults td a:first-child", div).each(function(index) { - var tit = $($(this).contents()[0]).text(); - titsp = tit.split("|"); - res[res.length] = [titsp[0].trim(), "http://adultmanga.ru" + $(this).attr("href")]; - }); - callback("AdultManga", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga+"?mature=1", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - var mng_nm = (urlManga.split('/')).pop(); - - $("div.expandable td > a", div).each( - function(index){ - var str = $(this).attr("href"); - str = str.split('/')[1]; - if(str == mng_nm) { - res[res.length] = [$($(this).contents()[0]).text(), "http://adultmanga.ru" + $(this).attr("href")]; - } - } - ); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $($("#mangaBox h1 a:first-child", doc).contents()[0]).text(); - var nameurl = "http://adultmanga.ru" + $("#mangaBox h1 a:first-child", doc).attr("href"); - var curChapName = $("#chapterSelectorSelect:first option:selected", doc).text(); - var chapurl = "http://adultmanga.ru" + $("#chapterSelectorSelect:first option:selected", doc).val(); - - callback({"name": name, - "currentChapter": curChapName, - "currentMangaURL": nameurl, - "currentChapterURL": chapurl}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl2) { - //This function runs in the DOM of the current consulted page. - var res = []; - var dir = ""; - var scansstr = ""; - $("script", doc).each(function(index) { - if ($(this).text().indexOf("var pictures = [{") != -1) { - var possc = $(this).text().indexOf("var pictures = [{") + 12; - var finsc = $(this).text().indexOf("]", possc); - scansstr = $(this).text().substring(possc, finsc); - var pos = scansstr.indexOf("\""); - while (pos != -1) { - var end = scansstr.indexOf("\"", pos + 1); - res[res.length] = scansstr.substring(pos + 1, end); - pos = scansstr.indexOf("\"", end + 1); - } - } - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".baner", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#mangaBox", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - //return $("select[name='series']").parent().parent(); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("img#mangaPicture", doc).size() > 0); - }, - - //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. - $("#mangaBox", doc).prev().remove(); - $("#mangaBox", doc).empty(); - $(".footerControl", doc).remove(); - $("#mangaBox", doc).css("width", "100%"); - $("#mangaBox", doc).css("padding", "0"); - $("#mangaBox", doc).css("padding-top", "10px"); - $("#mangaBox", doc).css("padding-bottom", "10px"); - $("#mangaBox", doc).css("border", "0"); - - $("#mangaBox", doc).css("background-color", "black"); - $("#mangaBox", doc).before($("")); - $("#mangaBox", doc).after($("")); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $( image ).attr( "src", urlImg ) - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#chapterSelectorSelect option", doc).each(function(index) { - $(this).val("http://adultmanga.ru" + $(this).val()); - }); - - return $($("#chapterSelectorSelect", doc)[0]); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var AdultManga = { + //Name of the mirror + mirrorName : "AdultManga", + //True if the mirror can list all of its mangas. + canListFullMangas : false, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/readmanga.png", + //Languages of scans for the mirror + languages : "ru", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("adultmanga.ru/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://adultmanga.ru/search", + type: 'POST', + data: {q: search}, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#mangaResults td a:first-child", div).each(function(index) { + var tit = $($(this).contents()[0]).text(); + titsp = tit.split("|"); + res[res.length] = [titsp[0].trim(), "http://adultmanga.ru" + $(this).attr("href")]; + }); + callback("AdultManga", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga+"?mature=1", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + var mng_nm = (urlManga.split('/')).pop(); + $("div.expandable td > a", div).each( + function(index){ + var str = $(this).attr("href"); + str = str.split('/')[1]; + if(str == mng_nm) { + res[res.length] = [$($(this).contents()[0]).text(), "http://adultmanga.ru" + $(this).attr("href")]; + } + } + ); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $($("#mangaBox h1 a:first-child", doc).contents()[0]).text(); + var nameurl = "http://adultmanga.ru" + $("#mangaBox h1 a:first-child", doc).attr("href"); + var curChapName = $("#chapterSelectorSelect:first option:selected", doc).text(); + var chapurl = "http://adultmanga.ru" + $("#chapterSelectorSelect:first option:selected", doc).val(); + callback({"name": name, + "currentChapter": curChapName, + "currentMangaURL": nameurl, + "currentChapterURL": chapurl}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl2) { + //This function runs in the DOM of the current consulted page. + var res = []; + var dir = ""; + var scansstr = ""; + $("script", doc).each(function(index) { + if ($(this).text().indexOf("var pictures = [{") != -1) { + var possc = $(this).text().indexOf("var pictures = [{") + 12; + var finsc = $(this).text().indexOf("]", possc); + scansstr = $(this).text().substring(possc, finsc); + var pos = scansstr.indexOf("\""); + while (pos != -1) { + var end = scansstr.indexOf("\"", pos + 1); + res[res.length] = scansstr.substring(pos + 1, end); + pos = scansstr.indexOf("\"", end + 1); + } + } + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".baner", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#mangaBox", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + //return $("select[name='series']").parent().parent(); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("img#mangaPicture", doc).size() > 0); + }, + //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. + $("#mangaBox", doc).prev().remove(); + $("#mangaBox", doc).empty(); + $(".footerControl", doc).remove(); + $("#mangaBox", doc).css("width", "100%"); + $("#mangaBox", doc).css("padding", "0"); + $("#mangaBox", doc).css("padding-top", "10px"); + $("#mangaBox", doc).css("padding-bottom", "10px"); + $("#mangaBox", doc).css("border", "0"); + $("#mangaBox", doc).css("background-color", "black"); + $("#mangaBox", doc).before($("")); + $("#mangaBox", doc).after($("")); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $( image ).attr( "src", urlImg ) + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#chapterSelectorSelect option", doc).each(function(index) { + $(this).val("http://adultmanga.ru" + $(this).val()); + }); + return $($("#chapterSelectorSelect", doc)[0]); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("AdultManga", AdultManga); diff --git a/AkumaScan.js b/AkumaScan.js index 4021ae3..bd7b8d9 100644 --- a/AkumaScan.js +++ b/AkumaScan.js @@ -1,132 +1,131 @@ -var AkumaScan = { - mirrorName : "Akuma Scan", - canListFullMangas : false, - mirrorIcon : "img/akumascan.png", - languages : "pt", - isMe : function (url) { - return (url.indexOf("leitor.akumascan.com.br") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://leitor.akumascan.com.br/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - callback("Akuma Scan", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) {}, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('leitor.akumascan.com.br/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR", doc).css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var AkumaScan = { + mirrorName : "Akuma Scan", + canListFullMangas : false, + mirrorIcon : "img/akumascan.png", + languages : "pt", + isMe : function (url) { + return (url.indexOf("leitor.akumascan.com.br") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://leitor.akumascan.com.br/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback("Akuma Scan", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) {}, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('leitor.akumascan.com.br/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR", doc).css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Akuma Scan", AkumaScan); diff --git a/AnarchyScans.js b/AnarchyScans.js index 29ae6e4..d7c3e91 100644 --- a/AnarchyScans.js +++ b/AnarchyScans.js @@ -1,132 +1,131 @@ -var AnarchyScans = { - mirrorName : "Anarchy Scans", - canListFullMangas : false, - mirrorIcon : "img/anarchyscans.png", - languages : "pt", - isMe : function (url) { - return (url.indexOf("online.anarchyscans.com") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://online.anarchyscans.com/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Anarchy Scans", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads.iframe.banner", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('online.anarchyscans.com/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - var script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR", doc).css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var AnarchyScans = { + mirrorName : "Anarchy Scans", + canListFullMangas : false, + mirrorIcon : "img/anarchyscans.png", + languages : "pt", + isMe : function (url) { + return (url.indexOf("online.anarchyscans.com") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://online.anarchyscans.com/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Anarchy Scans", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads.iframe.banner", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('online.anarchyscans.com/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + var script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR", doc).css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Anarchy Scans", AnarchyScans); diff --git a/AngelScanlator.js b/AngelScanlator.js index 4d581f0..4e0f691 100644 --- a/AngelScanlator.js +++ b/AngelScanlator.js @@ -1,229 +1,203 @@ -var AngelScanlator = -{ - mirrorName: "Angel Scanlator", - canListFullMangas: true, - mirrorIcon: "img/angelscanlator.png", - languages: "pt", - - isMe: function(url) - { - return (url.indexOf("angelscanlator.com") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://angelscanlator.com/online/", - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $("select[name='manga'] option", div).each(function(index) - { - if ($(this).attr('value') != 0) - { - res.push([$(this).text(), 'http://angelscanlator.com/online/' + $(this).attr('value') + '/01']); - } - }); - - callback("Angel Scanlator", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var currentMangaURL = 'http://angelscanlator.com/online/' + $("select[name='manga']:first option[selected]", div).attr('value'); - - var res = []; - $("select[name='chapter']:first option", div).each(function(index) - { - res.push([$(this).text(), currentMangaURL + '/' + $(this).attr('value')]); - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name = $("select[name='manga']:first option[selected]", doc).text(); - var currentChapter = $("select[name='chapter']:first option[selected]", doc).text(); - var currentMangaURL = 'http://angelscanlator.com/online/' + $("select[name='manga']:first option[selected]", doc).attr('value'); - var currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL + '/01', - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages: function(doc, curUrl) - { - var currentMangaURL = 'http://angelscanlator.com/online/' + $("select[name='manga']:first option[selected]", doc).attr('value'); - var currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); - - var res = []; - $("select[name='page']:first option", doc).each(function() - { - if ($(this).attr('value') == '') return true; - res.push(currentChapterURL + '/' + $(this).attr('value')); - }); - return res; - }, - - removeBanners: function(doc, curUrl) - { - //a lot of banners, huh? - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans: function(doc, curUrl) - { - return $('.imgAMR', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return ($("select[name='chapter']", doc).length > 0); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans: function(doc, curUrl) - { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - $('td.mid', doc).empty(); - $('td.mid', doc).append($("")); - $('td.mid', doc).append($("
")); - $('td.mid', doc).append($("")); - $(".navAMR").css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $.ajax( - { - url: urlImg, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var src = 'http://angelscanlator.com/online/' + $('img.picture', div).attr('src'); - - $(image).attr("src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol: function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - $("body", doc).css('background-color', '#f5f5f5'); - } +var AngelScanlator = +{ + mirrorName: "Angel Scanlator", + canListFullMangas: true, + mirrorIcon: "img/angelscanlator.png", + languages: "pt", + isMe: function(url) + { + return (url.indexOf("angelscanlator.com") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://angelscanlator.com/online/", + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("select[name='manga'] option", div).each(function(index) + { + if ($(this).attr('value') != 0) + { + res.push([$(this).text(), 'http://angelscanlator.com/online/' + $(this).attr('value') + '/01']); + } + }); + callback("Angel Scanlator", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var currentMangaURL = 'http://angelscanlator.com/online/' + $("select[name='manga']:first option[selected]", div).attr('value'); + var res = []; + $("select[name='chapter']:first option", div).each(function(index) + { + res.push([$(this).text(), currentMangaURL + '/' + $(this).attr('value')]); + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name = $("select[name='manga']:first option[selected]", doc).text(); + var currentChapter = $("select[name='chapter']:first option[selected]", doc).text(); + var currentMangaURL = 'http://angelscanlator.com/online/' + $("select[name='manga']:first option[selected]", doc).attr('value'); + var currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL + '/01', + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages: function(doc, curUrl) + { + var currentMangaURL = 'http://angelscanlator.com/online/' + $("select[name='manga']:first option[selected]", doc).attr('value'); + var currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); + var res = []; + $("select[name='page']:first option", doc).each(function() + { + if ($(this).attr('value') == '') return true; + res.push(currentChapterURL + '/' + $(this).attr('value')); + }); + return res; + }, + removeBanners: function(doc, curUrl) + { + //a lot of banners, huh? + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans: function(doc, curUrl) + { + return $('.imgAMR', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return ($("select[name='chapter']", doc).length > 0); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans: function(doc, curUrl) + { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + $('td.mid', doc).empty(); + $('td.mid', doc).append($("")); + $('td.mid', doc).append($("
")); + $('td.mid', doc).append($("")); + $(".navAMR").css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $.ajax( + { + url: urlImg, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = 'http://angelscanlator.com/online/' + $('img.picture', div).attr('src'); + $(image).attr("src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol: function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + $("body", doc).css('background-color', '#f5f5f5'); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Angel Scanlator", AngelScanlator); diff --git a/AnimeA.js b/AnimeA.js index e93b7a1..bc7cb0c 100644 --- a/AnimeA.js +++ b/AnimeA.js @@ -1,127 +1,126 @@ -var AnimeA = { - mirrorName: "AnimeA", - canListFullMangas: false, - mirrorIcon: "img/animea.png", - languages: "en", - isMe: function (url) { - return (url.indexOf("manga.animea.net/") !== -1); - }, - getMangaList: function (search, callback) { - $.ajax({ - url: "http://manga.animea.net/browse.html?input=Search&title=" + search, - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - xhr.setRequestHeader("X-Set-Cookie", "skip=1"); - xhr.withCredentials = true; - }, - success: function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ a", div).each(function () { - res[res.length] = [$(this).text(), "http://manga.animea.net" + $(this).attr("href")]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage: function (doc, curUrl, callback) { - var name = $(".description h1 a", doc).text(), - currentMangaURL = "http://manga.animea.net" + $(".description h1 a", doc).attr("href"), - chapter = $('.description h1', doc).text(), - currentChapter = chapter.replace(/Page.*/,'').trim(), - currentChapterURL = "http://manga.animea.net/" + $('.scan a', doc).attr('href').replace(/-page.*/, '') + '.html'; - callback({ - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - getListImages: function (doc, curUrl) { - var ref = curUrl; - var pos = ref.search(/.html|-page/g); - ref = ref.substr(0, pos) + "-page-"; - var res = []; - $("select.mangaselecter.pageselect option", doc).each(function (index) { - res[index] = ref + $(this).val() + ".html"; - }); - return res; - }, - removeBanners: function (doc, curUrl) { - $("iframe", doc).remove(); - $(".ads300", doc).remove(); - }, - whereDoIWriteScans: function (doc, curUrl) { - return $(".h_contentmp", doc); - }, - whereDoIWriteNavigation: function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage: function (doc, curUrl) { - return ($("img.scanmr", doc).size() > 0); - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - $(".hca", doc).remove(); - $(".h_contentmp", doc).empty(); - $(".h_contentmp", doc).before($("
").addClass("navAMR")); - $(".h_contentmp", doc).after($("
").addClass("navAMR")); - }, - nextChapterUrl: function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - $.ajax({ - url: urlImg, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("img.scanmr", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol: function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var AnimeA = { + mirrorName: "AnimeA", + canListFullMangas: false, + mirrorIcon: "img/animea.png", + languages: "en", + isMe: function (url) { + return (url.indexOf("manga.animea.net/") !== -1); + }, + getMangaList: function (search, callback) { + $.ajax({ + url: "http://manga.animea.net/browse.html?input=Search&title=" + search, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + xhr.setRequestHeader("X-Set-Cookie", "skip=1"); + xhr.withCredentials = true; + }, + success: function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ a", div).each(function () { + res[res.length] = [$(this).text(), "http://manga.animea.net" + $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage: function (doc, curUrl, callback) { + var name = $(".description h1 a", doc).text(), + currentMangaURL = "http://manga.animea.net" + $(".description h1 a", doc).attr("href"), + chapter = $('.description h1', doc).text(), + currentChapter = chapter.replace(/Page.*/,'').trim(), + currentChapterURL = "http://manga.animea.net/" + $('.scan a', doc).attr('href').replace(/-page.*/, '') + '.html'; + callback({ + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + getListImages: function (doc, curUrl) { + var ref = curUrl; + var pos = ref.search(/.html|-page/g); + ref = ref.substr(0, pos) + "-page-"; + var res = []; + $("select.mangaselecter.pageselect option", doc).each(function (index) { + res[index] = ref + $(this).val() + ".html"; + }); + return res; + }, + removeBanners: function (doc, curUrl) { + $("iframe", doc).remove(); + $(".ads300", doc).remove(); + }, + whereDoIWriteScans: function (doc, curUrl) { + return $(".h_contentmp", doc); + }, + whereDoIWriteNavigation: function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage: function (doc, curUrl) { + return ($("img.scanmr", doc).size() > 0); + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + $(".hca", doc).remove(); + $(".h_contentmp", doc).empty(); + $(".h_contentmp", doc).before($("
").addClass("navAMR")); + $(".h_contentmp", doc).after($("
").addClass("navAMR")); + }, + nextChapterUrl: function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + $.ajax({ + url: urlImg, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("img.scanmr", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol: function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("AnimeA", AnimeA); diff --git a/AnimeStory.js b/AnimeStory.js index 767d080..da27509 100644 --- a/AnimeStory.js +++ b/AnimeStory.js @@ -1,233 +1,203 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var AnimeStory = { - //Name of the mirror - mirrorName : "AnimeStory", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/animestory.png", - //Languages of scans for the mirror - languages : "fr", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return ((url.indexOf("anime-story.com") != -1) || (url.indexOf("instantmanga.com") != -1)); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.anime-story.com/mangas/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#mangalist li a", div).each(function(index) { - var txt = ""; - $(this).contents().each( - function(index){if (index == 0) txt += $(this).text(); - }); - res[res.length] = [txt.trim(), "http://www.anime-story.com/" + $(this).attr("href")]; - }); - callback("AnimeStory", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $(".listchapseries li", div).each(function(index) { - var txt = $(".chapter_series", $(this)).text(); - txt = txt.trim().replace(mangaName, ""); - res[res.length] = [txt, $("div:first a:last", $(this)).attr("href")]; - }); - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("#serie option:selected", doc).text(); - //currentMangaURL = $("#serie option:selected", doc).val().replace("http://www.anime-story.com/", "http://www.anime-story.com/mangas/"); - currentMangaURL = 'http://www.anime-story.com/mangas/' + $('#serie option:selected', doc).val(); - currentChapter = $("#pagenumber option:selected", doc).text(); - currentChapterURL = $("#pagenumber option:selected", doc).val(); - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - $("#page:first select option", doc).each( - function(index){ - res[index] = $(this).val(); - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#ad").remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#scansAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#nav", doc).add($("#navAMR", doc)); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#auto img", doc).size() > 0); - }, - - //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. - $("#nav", doc).next().remove(); - $("#nav", doc).after($("
")); - $("#nav", doc).empty(); - $("#nav", doc).css("text-align", "center"); - - $("#scansAMR", doc).after($("")); - $("#navAMR", doc).css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: 'http://www.instantmanga.com/' + urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = $("#auto a[rel=next] img", div).attr("src"); - - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#pagenumber:first", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var AnimeStory = { + //Name of the mirror + mirrorName : "AnimeStory", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/animestory.png", + //Languages of scans for the mirror + languages : "fr", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return ((url.indexOf("anime-story.com") != -1) || (url.indexOf("instantmanga.com") != -1)); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.anime-story.com/mangas/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#mangalist li a", div).each(function(index) { + var txt = ""; + $(this).contents().each( + function(index){if (index == 0) txt += $(this).text(); + }); + res[res.length] = [txt.trim(), "http://www.anime-story.com/" + $(this).attr("href")]; + }); + callback("AnimeStory", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $(".listchapseries li", div).each(function(index) { + var txt = $(".chapter_series", $(this)).text(); + txt = txt.trim().replace(mangaName, ""); + res[res.length] = [txt, $("div:first a:last", $(this)).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("#serie option:selected", doc).text(); + //currentMangaURL = $("#serie option:selected", doc).val().replace("http://www.anime-story.com/", "http://www.anime-story.com/mangas/"); + currentMangaURL = 'http://www.anime-story.com/mangas/' + $('#serie option:selected', doc).val(); + currentChapter = $("#pagenumber option:selected", doc).text(); + currentChapterURL = $("#pagenumber option:selected", doc).val(); + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + $("#page:first select option", doc).each( + function(index){ + res[index] = $(this).val(); + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#ad").remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#scansAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#nav", doc).add($("#navAMR", doc)); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#auto img", doc).size() > 0); + }, + //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. + $("#nav", doc).next().remove(); + $("#nav", doc).after($("
")); + $("#nav", doc).empty(); + $("#nav", doc).css("text-align", "center"); + $("#scansAMR", doc).after($("")); + $("#navAMR", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: 'http://www.instantmanga.com/' + urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = $("#auto a[rel=next] img", div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#pagenumber:first", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("AnimeStory", AnimeStory); diff --git a/Animexis.js b/Animexis.js index 12b9965..23a6c7c 100644 --- a/Animexis.js +++ b/Animexis.js @@ -1,229 +1,199 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) Enter here your copyright mention... // -// // -///////////////////////////////////////////////////////////////////////////// -*/ - -//This class is an example of manga site following implementation for All Manga Reader. -//To test this class, just modify the json variable in mgEntry.js. -//If your implementation works and has been fully tested, send it to me with an -//icon (png with transparency file, 16x16) for your mirror -//at pl dot duhoux (at) gmail dot com. I will add it in the extension. -//If you have problems implementing your mirror, send me a mail... i will be glad to help you... - -//CHANGE here the classname -var Animexis = { - //CHANGE : Name of the mirror - mirrorName : "Animexis Scans", - //CHANGE : True if the mirror can list all of its mangas. - canListFullMangas : false, - //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) - mirrorIcon : "img/animexis.png", - languages: "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("manga.animexis.org/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - //CHANGE URL HERE - url: "http://manga.animexis.org/reader/search/", - type: 'POST', - data: - { - 'search': search - }, - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback("Animexis Scans", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - //CHANGE URL HERE - url: urlManga, - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $('.list > .element > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback(res, obj); - } - }); - }, - - /******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). - ********************************************************************************************************/ - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - var res = []; - eval($('body', doc).html().match(/var pages = .*\n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - return $('#page', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) - //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return (curUrl.search('manga.animexis.org/reader/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans : function(doc, curUrl) { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - $('#page').css("max-width", (screen.width - 150) + 'px'); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR").css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES - $("body > div:empty", doc).remove(); - - //DO ANYTHING ELSE YOU NEED - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) Enter here your copyright mention... // +// // +///////////////////////////////////////////////////////////////////////////// +*/ +//This class is an example of manga site following implementation for All Manga Reader. +//To test this class, just modify the json variable in mgEntry.js. +//If your implementation works and has been fully tested, send it to me with an +//icon (png with transparency file, 16x16) for your mirror +//at pl dot duhoux (at) gmail dot com. I will add it in the extension. +//If you have problems implementing your mirror, send me a mail... i will be glad to help you... +//CHANGE here the classname +var Animexis = { + //CHANGE : Name of the mirror + mirrorName : "Animexis Scans", + //CHANGE : True if the mirror can list all of its mangas. + canListFullMangas : false, + //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) + mirrorIcon : "img/animexis.png", + languages: "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("manga.animexis.org/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + //CHANGE URL HERE + url: "http://manga.animexis.org/reader/search/", + type: 'POST', + data: + { + 'search': search + }, + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Animexis Scans", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + //CHANGE URL HERE + url: urlManga, + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + /******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). + ********************************************************************************************************/ + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + var res = []; + eval($('body', doc).html().match(/var pages = .*\n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + return $('#page', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) + //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return (curUrl.search('manga.animexis.org/reader/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans : function(doc, curUrl) { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + $('#page').css("max-width", (screen.width - 150) + 'px'); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR").css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES + $("body > div:empty", doc).remove(); + //DO ANYTHING ELSE YOU NEED + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Animexis Scans", Animexis); diff --git a/Animextremist.js b/Animextremist.js index 49f8ba9..5760951 100644 --- a/Animextremist.js +++ b/Animextremist.js @@ -1,315 +1,268 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// // -// Developped by jknito (keliasjes@gmail.com) // -// twitter account (http://twitter.com/jknito) // -// // -/////////////////////////////////////////////////////////////////////////////*/ -function formatMgName(name) { - if (name == undefined || name == null || name == "null") return ""; - return name.trim().replace(/[^0-9A-Za-z]/g, '').toUpperCase(); -} - -var Animextremist = { - - mirrorName : "Animextremist", - - canListFullMangas : true, - - mirrorIcon : "img/animextremist.png", - - //Languages of scans for the mirror - languages : "es", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("animextremist.com/mangas-online") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.animextremist.com/mangas-online/mns.htm", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - - $("option", div).each(function(index) { - if( $(this).attr("value") == "00") return; - res[res.length] = [$(this).text(), "http://www.animextremist.com/"+$(this).attr("value")]; - }); - - callback("Animextremist", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("#Layer17 #tomos a", div).each(function(index) { - if( ! $(this).text()) return; - var ref = $(this).attr("href"); - if( ref.indexOf("capitulo") == -1 ) return; - - var texto = ref.replace(".html", "-1.html"); - - res[res.length] = [texto.replace(/(http:\/\/.*capitulo-)/,"").replace(/(\/.*)/,""), texto]; - }); - if( ! res.length ){ - $("#Layer10 table a", div).each(function(index) { - if( ! $(this).text()) return; - var ref = $(this).attr("href"); - if( ref.indexOf("capitulo") == -1 ) return; - - var texto = ref; - - res[res.length] = [texto.replace(/(http:\/\/.*capitulo-)/,"").replace(/(\/.*)/,""), texto]; - }); - } - - res.sort(function( a, b){ - var x = parseInt(a[0]); - var y = parseInt(b[0]); - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - //FILL THE ABOVE VARIABLES HERE... - var manga = $("head title", doc).text(); - var pos = manga.indexOf(" - "); - name = manga.substr(0, pos); - /*var mangaExist = manga.lastIndexOf(" ") == (manga.length - 6) ? manga.lastIndexOf(" ") : manga.length; - name = manga.substr(manga.indexOf(" ")+1, mangaExist - manga.indexOf(" ") - 1);*/ - currentChapter = $("#photo", doc).attr("src").replace(/(http:\/\/.*capitulo-)/,"").replace(/(\/.*)/,""); - currentChapterURL = curUrl; - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: "http://www.animextremist.com/mangas-online/mns.htm", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var sent = false; - $("option", div).each(function(index) { - if( $(this).attr("value") == "00") return; - var tmpname = $(this).text(); - if (!sent && formatMgName(tmpname) == formatMgName(name)) { - currentMangaURL = "http://www.animextremist.com/"+$(this).attr("value"); - sent = true; - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - } - }); - } - }); - - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - - $("#nav-jump option", doc).each( - function(index){ - res[index] = "http://www.animextremist.com/" + $(this).val(); - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#publi", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#div-photo", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#nav", doc).add($("#sub-nav", doc)); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return $("#photo",doc).size() > 0; - }, - - //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. - //PREPARE THE PAGE TO HOST NAVIGATION AND THE FULL CHAPTER - //you may need to change elements in the page, add elements, remove others and change css - $("#wrapper").css("width", "auto"); - $("#nav", doc).empty(); - $("#sub-nav", doc).empty(); - $("#div-photo", doc).empty(); - - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //IF URL IS IMAGE URL --> $( image ).attr( "src", urlImg ); - $.ajax({ - url: urlImg, - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = $("#photo",div).attr("src"); - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var select = $(""); - var listOptions = []; - - var URL = curUrl.substr(0,curUrl.lastIndexOf("/")); - $("iframe", doc).each(function(index){ - if( index == 1 ) - URL = URL + "/" + $(this).attr("src"); - }); - - $.ajax({ - url: URL, - async: false, - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - $("select option",div).each(function(index){ - var thisUrl = curUrl.substr(0,curUrl.lastIndexOf("/")); - thisUrl = thisUrl.substr(0,thisUrl.lastIndexOf("/")); - if(index != 0){ - listOptions[listOptions.length] = thisUrl + "/"+ $(this).attr("value"); - var option = $("").text($(this).text()).attr("value",listOptions[listOptions.length-1]); - if( listOptions[listOptions.length-1] == curUrl ) - $(option).attr("selected","selected"); - $(select).prepend(option); - } - }); - } - }); - - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //$("body > div:empty", doc).remove(); - $($("table > tbody > tr > td > center")[0]).remove(); - return; - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// // +// Developped by jknito (keliasjes@gmail.com) // +// twitter account (http://twitter.com/jknito) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +function formatMgName(name) { + if (name == undefined || name == null || name == "null") return ""; + return name.trim().replace(/[^0-9A-Za-z]/g, '').toUpperCase(); +} +var Animextremist = { + mirrorName : "Animextremist", + canListFullMangas : true, + mirrorIcon : "img/animextremist.png", + //Languages of scans for the mirror + languages : "es", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("animextremist.com/mangas-online") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.animextremist.com/mangas-online/mns.htm", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("option", div).each(function(index) { + if( $(this).attr("value") == "00") return; + res[res.length] = [$(this).text(), "http://www.animextremist.com/"+$(this).attr("value")]; + }); + callback("Animextremist", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#Layer17 #tomos a", div).each(function(index) { + if( ! $(this).text()) return; + var ref = $(this).attr("href"); + if( ref.indexOf("capitulo") == -1 ) return; + var texto = ref.replace(".html", "-1.html"); + res[res.length] = [texto.replace(/(http:\/\/.*capitulo-)/,"").replace(/(\/.*)/,""), texto]; + }); + if( ! res.length ){ + $("#Layer10 table a", div).each(function(index) { + if( ! $(this).text()) return; + var ref = $(this).attr("href"); + if( ref.indexOf("capitulo") == -1 ) return; + var texto = ref; + res[res.length] = [texto.replace(/(http:\/\/.*capitulo-)/,"").replace(/(\/.*)/,""), texto]; + }); + } + res.sort(function( a, b){ + var x = parseInt(a[0]); + var y = parseInt(b[0]); + return ((x < y) ? 1 : ((x > y) ? -1 : 0)); + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + //FILL THE ABOVE VARIABLES HERE... + var manga = $("head title", doc).text(); + var pos = manga.indexOf(" - "); + name = manga.substr(0, pos); + /*var mangaExist = manga.lastIndexOf(" ") == (manga.length - 6) ? manga.lastIndexOf(" ") : manga.length; + name = manga.substr(manga.indexOf(" ")+1, mangaExist - manga.indexOf(" ") - 1);*/ + currentChapter = $("#photo", doc).attr("src").replace(/(http:\/\/.*capitulo-)/,"").replace(/(\/.*)/,""); + currentChapterURL = curUrl; + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: "http://www.animextremist.com/mangas-online/mns.htm", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var sent = false; + $("option", div).each(function(index) { + if( $(this).attr("value") == "00") return; + var tmpname = $(this).text(); + if (!sent && formatMgName(tmpname) == formatMgName(name)) { + currentMangaURL = "http://www.animextremist.com/"+$(this).attr("value"); + sent = true; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + } + }); + } + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + $("#nav-jump option", doc).each( + function(index){ + res[index] = "http://www.animextremist.com/" + $(this).val(); + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#publi", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#div-photo", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#nav", doc).add($("#sub-nav", doc)); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return $("#photo",doc).size() > 0; + }, + //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. + //PREPARE THE PAGE TO HOST NAVIGATION AND THE FULL CHAPTER + //you may need to change elements in the page, add elements, remove others and change css + $("#wrapper").css("width", "auto"); + $("#nav", doc).empty(); + $("#sub-nav", doc).empty(); + $("#div-photo", doc).empty(); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //IF URL IS IMAGE URL --> $( image ).attr( "src", urlImg ); + $.ajax({ + url: urlImg, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = $("#photo",div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var select = $(""); + var listOptions = []; + var URL = curUrl.substr(0,curUrl.lastIndexOf("/")); + $("iframe", doc).each(function(index){ + if( index == 1 ) + URL = URL + "/" + $(this).attr("src"); + }); + $.ajax({ + url: URL, + async: false, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + $("select option",div).each(function(index){ + var thisUrl = curUrl.substr(0,curUrl.lastIndexOf("/")); + thisUrl = thisUrl.substr(0,thisUrl.lastIndexOf("/")); + if(index != 0){ + listOptions[listOptions.length] = thisUrl + "/"+ $(this).attr("value"); + var option = $("").text($(this).text()).attr("value",listOptions[listOptions.length-1]); + if( listOptions[listOptions.length-1] == curUrl ) + $(option).attr("selected","selected"); + $(select).prepend(option); + } + }); + } + }); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //$("body > div:empty", doc).remove(); + $($("table > tbody > tr > td > center")[0]).remove(); + return; + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Animextremist", Animextremist); diff --git a/BacaManga.js b/BacaManga.js index 55fccad..64b2e04 100644 --- a/BacaManga.js +++ b/BacaManga.js @@ -1,231 +1,199 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var BacaManga = { - //Name of the mirror - mirrorName : "BacaManga", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/bacamanga.png", - //Languages of scans for the mirror - languages : "id", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("komikid.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://komikid.com/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("select[name='manga']:first option", div).each(function(index) { - if (index > 0) { - res[res.length] = [$(this).text().trim(), "http://komikid.com/" + $(this).val()]; - } - }); - callback("BacaManga", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("select[name='chapter']:first option", div).each( - function(index){ - res[res.length] = [$(this).text(), urlManga + "/" + $(this).val()]; - } - ); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $("select[name='manga']:first option:selected", doc).text(); - var nameurl = "http://komikid.com/" + $("select[name='manga']:first option:selected", doc).val(); - var curChapName = $("select[name='chapter']:first option:selected", doc).text(); - var chapurl = nameurl + "/" + $("select[name='chapter']:first option:selected", doc).val(); - - callback({"name": name, - "currentChapter": curChapName, - "currentMangaURL": nameurl, - "currentChapterURL": chapurl}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl2) { - //This function runs in the DOM of the current consulted page. - var nameurl = "http://komikid.com/" + $("select[name='manga']:first option:selected", doc).val(); - var chapurl = nameurl + "/" + $("select[name='chapter']:first option:selected", doc).val(); - - var res = []; - $("select[name='page']:first option", doc).each(function(index) { - res[res.length] = chapurl + "/" + $(this).val(); - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".baner", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - //return $("select[name='series']").parent().parent(); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("img.picture", doc).size() > 0); - }, - - //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. - $("#omv > table", doc).remove(); - $("#omv > div:empty", doc).remove(); - $("#header", doc).after($("")); - $("#header", doc).after($("
")); - $("#header", doc).after($("")); - $(".navAMR", doc).css("text-align", "center"); - $(".scanAMR", doc).css("background-color", "black"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = "http://komikid.com/" + $("img.picture", div).attr("src"); - - $( image ).attr( "src", src ); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var nameurl = "http://komikid.com/" + $("select[name='manga']:first option:selected", doc).val(); - - $("select[name='chapter']:first option", doc).each(function(index) { - $(this).val(nameurl + "/" + $(this).val()); - }); - - return $("select[name='chapter']:first", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - $("#omv .scanAMR table").css("background-color", "black"); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var BacaManga = { + //Name of the mirror + mirrorName : "BacaManga", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/bacamanga.png", + //Languages of scans for the mirror + languages : "id", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("komikid.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://komikid.com/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("select[name='manga']:first option", div).each(function(index) { + if (index > 0) { + res[res.length] = [$(this).text().trim(), "http://komikid.com/" + $(this).val()]; + } + }); + callback("BacaManga", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("select[name='chapter']:first option", div).each( + function(index){ + res[res.length] = [$(this).text(), urlManga + "/" + $(this).val()]; + } + ); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $("select[name='manga']:first option:selected", doc).text(); + var nameurl = "http://komikid.com/" + $("select[name='manga']:first option:selected", doc).val(); + var curChapName = $("select[name='chapter']:first option:selected", doc).text(); + var chapurl = nameurl + "/" + $("select[name='chapter']:first option:selected", doc).val(); + callback({"name": name, + "currentChapter": curChapName, + "currentMangaURL": nameurl, + "currentChapterURL": chapurl}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl2) { + //This function runs in the DOM of the current consulted page. + var nameurl = "http://komikid.com/" + $("select[name='manga']:first option:selected", doc).val(); + var chapurl = nameurl + "/" + $("select[name='chapter']:first option:selected", doc).val(); + var res = []; + $("select[name='page']:first option", doc).each(function(index) { + res[res.length] = chapurl + "/" + $(this).val(); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".baner", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + //return $("select[name='series']").parent().parent(); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("img.picture", doc).size() > 0); + }, + //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. + $("#omv > table", doc).remove(); + $("#omv > div:empty", doc).remove(); + $("#header", doc).after($("")); + $("#header", doc).after($("
")); + $("#header", doc).after($("")); + $(".navAMR", doc).css("text-align", "center"); + $(".scanAMR", doc).css("background-color", "black"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = "http://komikid.com/" + $("img.picture", div).attr("src"); + $( image ).attr( "src", src ); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var nameurl = "http://komikid.com/" + $("select[name='manga']:first option:selected", doc).val(); + $("select[name='chapter']:first option", doc).each(function(index) { + $(this).val(nameurl + "/" + $(this).val()); + }); + return $("select[name='chapter']:first", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + $("#omv .scanAMR table").css("background-color", "black"); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("BacaManga", BacaManga); diff --git a/Batoto.js b/Batoto.js index 69fad4f..e1b8337 100644 --- a/Batoto.js +++ b/Batoto.js @@ -1,211 +1,209 @@ -var Batoto = { - mirrorName: "Batoto", - canListFullMangas: false, - mirrorIcon: "img/Batoto.png", - languages: "en,fr,de,es,pt,tr,id,el,tl", - isMe: function (url) { - "use strict"; - return (url.match(/ba(to)+.(com|net|to)/gi) !== null); - }, - getMangaList: function (search, callback) { - "use strict"; - $.ajax({ - url: 'http://bato.to/search?name=' + search + '&name_cond=c', - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/= 0) { - i--; - } - if (lang != "English" && lang != "") { - name += " (" + lang + ")"; - } - } - var currentChapter = chapter.text(); - var pos = $("[name='chapter_select'] option:last", mod_bar).val().lastIndexOf("/"); - var currentMangaURL = $("[name='chapter_select'] option:last", mod_bar).val(); - var currentChapterURL = chapter.val(); - callback({ - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - getListImages: function (doc, curUrl) { - "use strict"; - var res = []; - if ($(".moderation_bar:first #page_select option", doc).size() > 0) { - $(".moderation_bar:first #page_select option", doc).each(function (index) { - res[index] = $(this).val(); - }); - } else { - $('#content > div > img', doc).each(function (index) { - res[index] = $(this).attr('src'); - }); - } - return res; - }, - removeBanners: function (doc, curUrl) { - "use strict"; - }, - whereDoIWriteScans: function (doc, curUrl) { - "use strict"; - return $(".scanAMR", doc); - }, - whereDoIWriteNavigation: function (doc, curUrl) { - "use strict"; - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage: function (doc, curUrl) { - "use strict"; - return ($("#comic_page", doc).size() > 0 || $("#full_image", doc).size() > 0 || curUrl.indexOf(/read/) !== - -1); - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - "use strict"; - if ($("#full_image", doc).size() > 0) { - $("#full_image", doc).after($("
")); - $("#full_image", doc).remove(); - } else { - $('#content > div > img', doc).parent().empty().append($("
")); - } - var mod_bar = $(".moderation_bar", doc); - $("li:not(:first)", mod_bar).remove(); - mod_bar.css("height", "8px"); - mod_bar.css("margin-bottom", "0px"); - mod_bar.css("padding-top", "0px"); - - if ($("#comic_page", doc).parent().size() > 0) { - $("#comic_page", doc).parent().remove(); - $("
").appendTo($(".amrcontainer", doc)); - } - $("").appendTo($(".amrcontainer", doc)); - $("
").appendTo($(".amrcontainer", doc)); - $("").appendTo($(".amrcontainer", doc)); - $("#content", doc).css("width", "auto !important"); - $("#content", doc).css("background-color", "black"); - $("#content", doc).css("text-align", "center"); - $("#ipbwrapper", doc).css("background", "black") - $("#full_image", doc).css("display", ""); - $("select[name=chapter_select]", doc).attr("style", ""); - }, - nextChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - "use strict"; - if ($(".AMRcomic", doc).size() !== 0) { - $.ajax({ - url: urlImg, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("img#comic_page", div).attr("src"); - $(image).attr("src", src); - } - }); - } else { - $(image).attr("src", urlImg); - } - }, - isImageInOneCol: function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - "use strict"; - return $(".moderation_bar:first [name='chapter_select']", doc); - }, - doAfterMangaLoaded: function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - $("#full_image", doc).css("display", ""); - $("#content", doc).css("width", "auto !important"); - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "Hotkeys.hotkeys.clear();"; - doc.body.appendChild(script); - } - } +var Batoto = { + mirrorName: "Batoto", + canListFullMangas: false, + mirrorIcon: "img/Batoto.png", + languages: "en,fr,de,es,pt,tr,id,el,tl", + isMe: function (url) { + "use strict"; + return (url.match(/ba(to)+.(com|net|to)/gi) !== null); + }, + getMangaList: function (search, callback) { + "use strict"; + $.ajax({ + url: 'http://bato.to/search?name=' + search + '&name_cond=c', + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/= 0) { + i--; + } + if (lang != "English" && lang != "") { + name += " (" + lang + ")"; + } + } + var currentChapter = chapter.text(); + var pos = $("[name='chapter_select'] option:last", mod_bar).val().lastIndexOf("/"); + var currentMangaURL = $("[name='chapter_select'] option:last", mod_bar).val(); + var currentChapterURL = chapter.val(); + callback({ + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + getListImages: function (doc, curUrl) { + "use strict"; + var res = []; + if ($(".moderation_bar:first #page_select option", doc).size() > 0) { + $(".moderation_bar:first #page_select option", doc).each(function (index) { + res[index] = $(this).val(); + }); + } else { + $('#content > div > img', doc).each(function (index) { + res[index] = $(this).attr('src'); + }); + } + return res; + }, + removeBanners: function (doc, curUrl) { + "use strict"; + }, + whereDoIWriteScans: function (doc, curUrl) { + "use strict"; + return $(".scanAMR", doc); + }, + whereDoIWriteNavigation: function (doc, curUrl) { + "use strict"; + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage: function (doc, curUrl) { + "use strict"; + return ($("#comic_page", doc).size() > 0 || $("#full_image", doc).size() > 0 || curUrl.indexOf(/read/) !== + -1); + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + "use strict"; + if ($("#full_image", doc).size() > 0) { + $("#full_image", doc).after($("
")); + $("#full_image", doc).remove(); + } else { + $('#content > div > img', doc).parent().empty().append($("
")); + } + var mod_bar = $(".moderation_bar", doc); + $("li:not(:first)", mod_bar).remove(); + mod_bar.css("height", "8px"); + mod_bar.css("margin-bottom", "0px"); + mod_bar.css("padding-top", "0px"); + if ($("#comic_page", doc).parent().size() > 0) { + $("#comic_page", doc).parent().remove(); + $("
").appendTo($(".amrcontainer", doc)); + } + $("").appendTo($(".amrcontainer", doc)); + $("
").appendTo($(".amrcontainer", doc)); + $("").appendTo($(".amrcontainer", doc)); + $("#content", doc).css("width", "auto !important"); + $("#content", doc).css("background-color", "black"); + $("#content", doc).css("text-align", "center"); + $("#ipbwrapper", doc).css("background", "black") + $("#full_image", doc).css("display", ""); + $("select[name=chapter_select]", doc).attr("style", ""); + }, + nextChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + "use strict"; + if ($(".AMRcomic", doc).size() !== 0) { + $.ajax({ + url: urlImg, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("img#comic_page", div).attr("src"); + $(image).attr("src", src); + } + }); + } else { + $(image).attr("src", urlImg); + } + }, + isImageInOneCol: function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + "use strict"; + return $(".moderation_bar:first [name='chapter_select']", doc); + }, + doAfterMangaLoaded: function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + $("#full_image", doc).css("display", ""); + $("#content", doc).css("width", "auto !important"); + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "Hotkeys.hotkeys.clear();"; + doc.body.appendChild(script); + } + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Batoto", Batoto); diff --git a/CXCScans.js b/CXCScans.js index 51927b9..f29a53d 100644 --- a/CXCScans.js +++ b/CXCScans.js @@ -1,134 +1,132 @@ -var CXCScans = { - mirrorName : "CXC Scans", - canListFullMangas : false, - mirrorIcon : "img/cxcscans.png", - languages: "en", - isMe : function(url) { - return (url.indexOf("manga.cxcscans.com") != -1); - }, - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://manga.cxcscans.com/search", - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); - }, - type: 'POST', - data: { - 'search': search - }, - success: function(objResponse){ - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ .title a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback("CXC Scans", res); - } - }); - }, - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - data : { - 'adult' : true - }, - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); - }, - success: function(objResponse){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse.replace(/ -1); - }, - doSomethingBeforeWritingScans : function(doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function() { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function(select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function(select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function(img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function(doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function(doc, curUrl) { - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - } +var CXCScans = { + mirrorName : "CXC Scans", + canListFullMangas : false, + mirrorIcon : "img/cxcscans.png", + languages: "en", + isMe : function(url) { + return (url.indexOf("manga.cxcscans.com") != -1); + }, + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://manga.cxcscans.com/search", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); + }, + type: 'POST', + data: { + 'search': search + }, + success: function(objResponse){ + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ .title a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("CXC Scans", res); + } + }); + }, + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + data : { + 'adult' : true + }, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); + }, + success: function(objResponse){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse.replace(/ -1); + }, + doSomethingBeforeWritingScans : function(doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function() { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function(select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function(select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function(img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function(doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function(doc, curUrl) { + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("CXC Scans", CXCScans); diff --git a/CentralDeMangas.js b/CentralDeMangas.js index ab81e66..8c12d1d 100644 --- a/CentralDeMangas.js +++ b/CentralDeMangas.js @@ -1,244 +1,215 @@ -var CentralDeMangas = -{ - mirrorName: "Central De Mangas", - canListFullMangas: true, - mirrorIcon: "img/centraldemangas.png", - languages: "pt", - - isMe: function(url) - { - return (url.indexOf("centraldemangas.com.br/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://centraldemangas.com.br/mangas", - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $("#conteudo table.tbl_mangas tbody tr td:first-child a", div).each(function(index) - { - res[res.length] = [$(this).text(), $(this).attr("href")]; - }); - - callback("Central De Mangas", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function( objResponse ) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $("div a", $("#conteudo .bloco:last-child", div)).each(function(index) - { - res[res.length] = [$(this).text(), $(this).attr("href") + '#1']; - }); - res.reverse(); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - var pos; - - name = $("label[for='capitulos']", doc).text(); - pos = name.indexOf(":"); - name = name.substring(pos + 1, name.length).trim(); - - currentChapter = $("#capitulos option:selected", doc).text(); - currentChapterURL = $("#capitulos option:selected", doc).val() + '#1'; - pos = currentChapterURL.lastIndexOf("/"); - currentMangaURL = currentChapterURL.substr(0, pos); - - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - //This function runs in the DOM of the current consulted page. - getListImages: function(doc, curUrl) - { - var res; - - $("script", doc).each(function(index) - { - if ($(this).text().indexOf("var pags = ") != -1) - { - var posdeb = $(this).text().indexOf("var pags = "); - var posfin = $(this).text().indexOf("]", posdeb); - - res = eval($(this).text().substring(posdeb + 11, posfin + 1)); - } - }); - - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - $("#anuncio_a").remove(); - $("#anuncio_b").remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteScans: function(doc, curUrl) - { - return $(".pagina", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return ($("#img_pag", doc).size() > 0); - }, - - //This method is called before displaying full chapters in the page - //This function runs in the DOM of the current consulted page. - doSomethingBeforeWritingScans: function(doc, curUrl) - { - $("label[for='capitulos']", doc).remove(); - $("select[name='capitulos']", doc).remove(); - $("select[name='paginas']", doc).remove(); - $("ul.seletores", doc).remove(); - $("iframe", doc).remove(); - - $(".pagina", doc).empty(); - $(".pagina", doc).css("background-color", "black"); - $(".pagina", doc).css("padding-top", "10px"); - $(".pagina", doc).before($("")); - $(".pagina", doc).after($("")); - $(".navAMR", doc).css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $(image).attr( "src", urlImg ) - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol: function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null;//$("#capitulos", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - if (typeof doc.createElement == 'function') - { - script = doc.createElement('script'); - script.innerText = "document.styleSheets[0].cssRules[0].selectorText = document.styleSheets[0].cssRules[0].selectorText"; - doc.body.appendChild(script); - } - $("body > div:empty", doc).remove(); - } +var CentralDeMangas = +{ + mirrorName: "Central De Mangas", + canListFullMangas: true, + mirrorIcon: "img/centraldemangas.png", + languages: "pt", + isMe: function(url) + { + return (url.indexOf("centraldemangas.com.br/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://centraldemangas.com.br/mangas", + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("#conteudo table.tbl_mangas tbody tr td:first-child a", div).each(function(index) + { + res[res.length] = [$(this).text(), $(this).attr("href")]; + }); + callback("Central De Mangas", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("div a", $("#conteudo .bloco:last-child", div)).each(function(index) + { + res[res.length] = [$(this).text(), $(this).attr("href") + '#1']; + }); + res.reverse(); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + var pos; + name = $("label[for='capitulos']", doc).text(); + pos = name.indexOf(":"); + name = name.substring(pos + 1, name.length).trim(); + currentChapter = $("#capitulos option:selected", doc).text(); + currentChapterURL = $("#capitulos option:selected", doc).val() + '#1'; + pos = currentChapterURL.lastIndexOf("/"); + currentMangaURL = currentChapterURL.substr(0, pos); + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + //This function runs in the DOM of the current consulted page. + getListImages: function(doc, curUrl) + { + var res; + $("script", doc).each(function(index) + { + if ($(this).text().indexOf("var pags = ") != -1) + { + var posdeb = $(this).text().indexOf("var pags = "); + var posfin = $(this).text().indexOf("]", posdeb); + res = eval($(this).text().substring(posdeb + 11, posfin + 1)); + } + }); + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + $("#anuncio_a").remove(); + $("#anuncio_b").remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteScans: function(doc, curUrl) + { + return $(".pagina", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return ($("#img_pag", doc).size() > 0); + }, + //This method is called before displaying full chapters in the page + //This function runs in the DOM of the current consulted page. + doSomethingBeforeWritingScans: function(doc, curUrl) + { + $("label[for='capitulos']", doc).remove(); + $("select[name='capitulos']", doc).remove(); + $("select[name='paginas']", doc).remove(); + $("ul.seletores", doc).remove(); + $("iframe", doc).remove(); + $(".pagina", doc).empty(); + $(".pagina", doc).css("background-color", "black"); + $(".pagina", doc).css("padding-top", "10px"); + $(".pagina", doc).before($("")); + $(".pagina", doc).after($("")); + $(".navAMR", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $(image).attr( "src", urlImg ) + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol: function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null;//$("#capitulos", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + if (typeof doc.createElement == 'function') + { + script = doc.createElement('script'); + script.innerText = "document.styleSheets[0].cssRules[0].selectorText = document.styleSheets[0].cssRules[0].selectorText"; + doc.body.appendChild(script); + } + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Central De Mangas", CentralDeMangas); diff --git a/CityManga.js b/CityManga.js index 5bf8491..cde2003 100644 --- a/CityManga.js +++ b/CityManga.js @@ -1,241 +1,210 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var CityManga = { - //Name of the mirror - mirrorName : "CityManga", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/citymanga.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("citymanga.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.citymanga.com/manga-list/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#main_container #allwide .roww2 .coll1 a", div).each(function(index) { - res[res.length] = [$(this).text(), "http://www.citymanga.com" + $(this).attr("href")]; - }); - callback("CityManga", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $("#main_container #fullwidth .roww2 .coll1 a", div).each(function(index) { - res[res.length] = [$(this).attr("title").replace(mangaName, "").trim(), $(this).attr("href")]; - }); - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("#main_container #linkkkk span a", doc).text().trim(); - currentMangaURL = "http://www.citymanga.com" + $("#main_container #linkkkk > span a", doc).attr("href"); - - currentChapter = $("#main_container #linkkkk > h1", doc).text().replace(name, "").trim(); - var ref = curUrl; - var pos = ref.lastIndexOf("chapter-"); - var slash = ref.indexOf("/", pos); - ref = ref.substr(0, slash) + "/"; - currentChapterURL = ref; - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var ref = curUrl; - var pos = ref.lastIndexOf("chapter-"); - var slash = ref.indexOf("/", pos); - ref = ref.substr(0, slash) + "/"; - var res = []; - $("#pageselector:first option", doc).each( - function(index){ - res[index] = ref + $(this).val() + "/"; - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#seventwentyeight", doc).remove(); - $("#seventwentyeight300", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#main_container2", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#selector", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#main_container2 img.image", doc).size() > 0); - }, - - //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. - $("#selector", doc).empty(); - $("#main_container2", doc).empty(); - $("#selector", doc).css("text-align", "center"); - $("#selector", doc).css("height", "auto"); - $("#main_container", doc).css("width", "auto"); - $("#main_container #linkkkk", doc).css("background-color", "black"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = "http://www.citymanga.com" + $("#main_container2 img.image", div).attr("src"); - - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var ref = curUrl; - var pos = ref.lastIndexOf("chapter-"); - $("#chapterselector:first option", doc).each(function(index) { - $(this).val(ref.substr(0, pos) + "chapter-" + $(this).val() + "/"); - }); - - return $("#chapterselector:first", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var CityManga = { + //Name of the mirror + mirrorName : "CityManga", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/citymanga.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("citymanga.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.citymanga.com/manga-list/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#main_container #allwide .roww2 .coll1 a", div).each(function(index) { + res[res.length] = [$(this).text(), "http://www.citymanga.com" + $(this).attr("href")]; + }); + callback("CityManga", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#main_container #fullwidth .roww2 .coll1 a", div).each(function(index) { + res[res.length] = [$(this).attr("title").replace(mangaName, "").trim(), $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("#main_container #linkkkk span a", doc).text().trim(); + currentMangaURL = "http://www.citymanga.com" + $("#main_container #linkkkk > span a", doc).attr("href"); + currentChapter = $("#main_container #linkkkk > h1", doc).text().replace(name, "").trim(); + var ref = curUrl; + var pos = ref.lastIndexOf("chapter-"); + var slash = ref.indexOf("/", pos); + ref = ref.substr(0, slash) + "/"; + currentChapterURL = ref; + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var ref = curUrl; + var pos = ref.lastIndexOf("chapter-"); + var slash = ref.indexOf("/", pos); + ref = ref.substr(0, slash) + "/"; + var res = []; + $("#pageselector:first option", doc).each( + function(index){ + res[index] = ref + $(this).val() + "/"; + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#seventwentyeight", doc).remove(); + $("#seventwentyeight300", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#main_container2", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#selector", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#main_container2 img.image", doc).size() > 0); + }, + //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. + $("#selector", doc).empty(); + $("#main_container2", doc).empty(); + $("#selector", doc).css("text-align", "center"); + $("#selector", doc).css("height", "auto"); + $("#main_container", doc).css("width", "auto"); + $("#main_container #linkkkk", doc).css("background-color", "black"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = "http://www.citymanga.com" + $("#main_container2 img.image", div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var ref = curUrl; + var pos = ref.lastIndexOf("chapter-"); + $("#chapterselector:first option", doc).each(function(index) { + $(this).val(ref.substr(0, pos) + "chapter-" + $(this).val() + "/"); + }); + return $("#chapterselector:first", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("CityManga", CityManga); diff --git a/ClockworkLies.js b/ClockworkLies.js index 9617e0a..500efc0 100644 --- a/ClockworkLies.js +++ b/ClockworkLies.js @@ -1,47 +1,46 @@ -var ClockworkLies = { - mirrorName: "Clockwork Lies", - canListFullMangas: false, - mirrorIcon: "img/clockworklies.png", - languages: "en", - isMe: function (url) { - return false; - }, -getMangaList: function (search, callback) { - }, - getListChaps: function (urlManga, mangaName, obj, callback) { - }, - getInformationsFromCurrentPage: function (doc, curUrl, callback) { - }, - getListImages: function (doc, curUrl) { - }, - removeBanners: function (doc, curUrl) { - }, - whereDoIWriteScans: function (doc, curUrl) { - }, - whereDoIWriteNavigation: function (doc, curUrl) { - }, - isCurrentPageAChapterPage: function (doc, curUrl) { - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - }, - nextChapterUrl: function (select, doc, curUrl) { - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - }, - isImageInOneCol: function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - } +var ClockworkLies = { + mirrorName: "Clockwork Lies", + canListFullMangas: false, + mirrorIcon: "img/clockworklies.png", + languages: "en", + isMe: function (url) { + return false; + }, +getMangaList: function (search, callback) { + }, + getListChaps: function (urlManga, mangaName, obj, callback) { + }, + getInformationsFromCurrentPage: function (doc, curUrl, callback) { + }, + getListImages: function (doc, curUrl) { + }, + removeBanners: function (doc, curUrl) { + }, + whereDoIWriteScans: function (doc, curUrl) { + }, + whereDoIWriteNavigation: function (doc, curUrl) { + }, + isCurrentPageAChapterPage: function (doc, curUrl) { + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + }, + nextChapterUrl: function (select, doc, curUrl) { + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + }, + isImageInOneCol: function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Clockwork Lies", ClockworkLies); diff --git a/DragonFlyScans.js b/DragonFlyScans.js index 58180e2..d7b06bc 100644 --- a/DragonFlyScans.js +++ b/DragonFlyScans.js @@ -1,137 +1,136 @@ -var DragonFlyScans = { - mirrorName : "Dragon & Fly Scans", - canListFullMangas : true, - mirrorIcon : "img/dragonflyscans.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("dragonflyscans.org") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://dragonflyscans.org", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"), - res = [], - name, - url, - list; - div.innerHTML = objResponse; - list = $('.rightcol h2:contains(Manga List)', div); - while ((list = list.next()).length > 0) { - if (list.is('h3')) { - name = list.text(); - list = list.next(); - if (!list.is('ul')) { - break; - } - url = $('a:first', list).attr('href'); - n = url.indexOf("\/", 33); - url = url.substring(0, n); - res.push([name, url + "/"]); - } - } - callback("Dragon & Fly Scans", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ 0; - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $('.controls', doc).remove(); - $('#tips', doc).remove(); - $('#chapter_list', doc).hide(); - $('#page', doc).empty(); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $('#page', doc).css('padding', '20px 0'); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $('#page img', div).attr('src'); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var DragonFlyScans = { + mirrorName : "Dragon & Fly Scans", + canListFullMangas : true, + mirrorIcon : "img/dragonflyscans.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("dragonflyscans.org") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://dragonflyscans.org", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"), + res = [], + name, + url, + list; + div.innerHTML = objResponse; + list = $('.rightcol h2:contains(Manga List)', div); + while ((list = list.next()).length > 0) { + if (list.is('h3')) { + name = list.text(); + list = list.next(); + if (!list.is('ul')) { + break; + } + url = $('a:first', list).attr('href'); + n = url.indexOf("\/", 33); + url = url.substring(0, n); + res.push([name, url + "/"]); + } + } + callback("Dragon & Fly Scans", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ 0; + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $('.controls', doc).remove(); + $('#tips', doc).remove(); + $('#chapter_list', doc).hide(); + $('#page', doc).empty(); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $('#page', doc).css('padding', '20px 0'); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $('#page img', div).attr('src'); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Dragon & Fly Scans", DragonFlyScans); diff --git a/DynastyScans.js b/DynastyScans.js index 67ba550..3bad20b 100644 --- a/DynastyScans.js +++ b/DynastyScans.js @@ -1,126 +1,125 @@ -var DynastyScans = { - mirrorName : "Dynasty Scans", - canListFullMangas : false, - mirrorIcon : "img/dynastyscans.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("dynasty-scans.com/") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://dynasty-scans.com/search?q=" + search + "&type=series", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "$(document).unbind('keyup');"; - doc.body.appendChild(script); - } - $('#reader', doc).empty(); - $('#reader', doc).css('background-color', '#f4f4f4'); - $('#reader', doc).append(""); - $('#reader', doc).append("
"); - $('#reader', doc).append(""); - $(".navAMR", doc).css("text-align", "center"); - $(".spanForImg", doc).css("float", "none"); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var DynastyScans = { + mirrorName : "Dynasty Scans", + canListFullMangas : false, + mirrorIcon : "img/dynastyscans.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("dynasty-scans.com/") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://dynasty-scans.com/search?q=" + search + "&type=series", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "$(document).unbind('keyup');"; + doc.body.appendChild(script); + } + $('#reader', doc).empty(); + $('#reader', doc).css('background-color', '#f4f4f4'); + $('#reader', doc).append(""); + $('#reader', doc).append("
"); + $('#reader', doc).append(""); + $(".navAMR", doc).css("text-align", "center"); + $(".spanForImg", doc).css("float", "none"); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Dynasty Scans", DynastyScans); diff --git a/EJapanzai.js b/EJapanzai.js index 3ea9e58..7eec164 100644 --- a/EJapanzai.js +++ b/EJapanzai.js @@ -1,171 +1,170 @@ -var EJapanzai = { - mirrorName: "Ecchi Japanzai", - canListFullMangas: false, - mirrorIcon: "img/japanzai.png", - languages: "en", - isMe: function (url) { - "use strict"; - return (url.indexOf("ecchi.japanzai.com/") !== -1); - }, - getMangaList: function (search, callback) { - "use strict"; - $.ajax({ - url: "http://ecchi.japanzai.com/search/", - type: 'POST', - data: { - 'search': search - }, - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ -1); - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - "use strict"; - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; - script.type = 'text/javascript'; - doc.body.appendChild(script); - } - $('#page').css("max-width", "none"); - $('#page').css("width", "100%"); - $("#page", doc).before(""); - $("#page", doc).after(""); - $("#page", doc).empty(); - }, - nextChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - "use strict"; - $(image).attr("src", urlImg); - }, - isImageInOneCol: function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - "use strict"; - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - } +var EJapanzai = { + mirrorName: "Ecchi Japanzai", + canListFullMangas: false, + mirrorIcon: "img/japanzai.png", + languages: "en", + isMe: function (url) { + "use strict"; + return (url.indexOf("ecchi.japanzai.com/") !== -1); + }, + getMangaList: function (search, callback) { + "use strict"; + $.ajax({ + url: "http://ecchi.japanzai.com/search/", + type: 'POST', + data: { + 'search': search + }, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ -1); + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + "use strict"; + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; + script.type = 'text/javascript'; + doc.body.appendChild(script); + } + $('#page').css("max-width", "none"); + $('#page').css("width", "100%"); + $("#page", doc).before(""); + $("#page", doc).after(""); + $("#page", doc).empty(); + }, + nextChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + "use strict"; + $(image).attr("src", urlImg); + }, + isImageInOneCol: function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + "use strict"; + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Ecchi Japanzai", EJapanzai); diff --git a/EasyGoing.js b/EasyGoing.js index 2242773..4018295 100644 --- a/EasyGoing.js +++ b/EasyGoing.js @@ -1,134 +1,133 @@ -var EasyGoing = { - mirrorName : "Easy Going", - canListFullMangas : true, - mirrorIcon : "img/easygoing.png", - languages : "en", - isMe : function (url) { - "use strict"; - return (url.match(/read\.egscans\.(com|org)/gi) !== null); - }, - getMangaList : function (search, callback) { - "use strict"; - $.ajax({ - url : "http://read.egscans.com/", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > script:nth-child(2)", doc).html(); - txt = JSON.stringify(txt); - img = txt.match(/img_url\.push\(\'.+?\' \)/g); - for (i = 0; img.length > i; i += 1) { - res.push("http://read.egscans.com/" + img[i].match(/'(.*?)'/ig)[0].replace(/'/g, "")); - } - return res; - }, - whereDoIWriteScans : function (doc, curUrl) { - "use strict"; - return $('.imgAMR', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - "use strict"; - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - "use strict"; - return ($("select[name='chapter']", doc).length > 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - "use strict"; - $('td.mid', doc).empty(); - $('td.mid', doc).append($("")); - $('td.mid', doc).append($("
")); - $('td.mid', doc).append($("")); - $(".navAMR").css("text-align", "center"); - }, - nextChapterUrl : function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - "use strict"; - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - "use strict"; - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - $('select', doc).css('background-color', 'white'); - $('option', doc).css('background-color', 'white').css('color', 'black'); - } +var EasyGoing = { + mirrorName : "Easy Going", + canListFullMangas : true, + mirrorIcon : "img/easygoing.png", + languages : "en", + isMe : function (url) { + "use strict"; + return (url.match(/read\.egscans\.(com|org)/gi) !== null); + }, + getMangaList : function (search, callback) { + "use strict"; + $.ajax({ + url : "http://read.egscans.com/", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > script:nth-child(2)", doc).html(); + txt = JSON.stringify(txt); + img = txt.match(/img_url\.push\(\'.+?\' \)/g); + for (i = 0; img.length > i; i += 1) { + res.push("http://read.egscans.com/" + img[i].match(/'(.*?)'/ig)[0].replace(/'/g, "")); + } + return res; + }, + whereDoIWriteScans : function (doc, curUrl) { + "use strict"; + return $('.imgAMR', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + "use strict"; + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + "use strict"; + return ($("select[name='chapter']", doc).length > 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + "use strict"; + $('td.mid', doc).empty(); + $('td.mid', doc).append($("")); + $('td.mid', doc).append($("
")); + $('td.mid', doc).append($("")); + $(".navAMR").css("text-align", "center"); + }, + nextChapterUrl : function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + "use strict"; + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + "use strict"; + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + $('select', doc).css('background-color', 'white'); + $('option', doc).css('background-color', 'white').css('color', 'black'); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Easy Going", EasyGoing); diff --git a/EatManga.js b/EatManga.js index 16d8aa8..f099057 100644 --- a/EatManga.js +++ b/EatManga.js @@ -1,252 +1,221 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var EatManga = { - //Name of the mirror - mirrorName : "EatManga", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/eatmanga.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("eatmanga.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://eatmanga.com/Manga-Scan/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#updates tr th a:first-child", div).each(function(index) { - res[res.length] = [$(this).text().trim(), "http://eatmanga.com" + $(this).attr("href")]; - }); - callback("EatManga", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("#updates tr th a:first-child", div).each(function(index) { - if (index == 0) { - var _self = this; - $.ajax( - { - async: false, - url: "http://eatmanga.com" + $(_self).attr("href"), - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - if ($("img.eatmanga_bigimage", div).size() > 0) { - res[res.length] = [$(_self).text().trim(), "http://eatmanga.com" + $(_self).attr("href")]; - } - } - }); - } else { - res[res.length] = [$(this).text().trim(), "http://eatmanga.com" + $(this).attr("href")]; - } - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $("#breadcrumbs li:nth-child(3) a", doc).text(); - var nameurl = "http://eatmanga.com" + $("#breadcrumbs li:nth-child(3) a", doc).attr("href"); - var curChapName = $("head title", doc).text();//$("select#chapters:first option:selected", doc).text(); - var pos = curChapName.indexOf("-"); - if (pos != -1) { - curChapName = curChapName.substr(0, pos).trim(); - } - var chapurl;//"http://eatmanga.com" + $("select#chapters:first option:selected", doc).val(); - var tmpu = curUrl.replace(nameurl, ""); - var p = tmpu.indexOf("/"); - if (p != -1) { - chapurl = nameurl + tmpu.substr(0, p) + "/"; - } else { - chapurl = nameurl + tmpu + "/"; - } - - callback({"name": name, - "currentChapter": curChapName, - "currentMangaURL": nameurl, - "currentChapterURL": chapurl}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl2) { - //This function runs in the DOM of the current consulted page. - var res = []; - $("select#pages:first option", doc).each(function(index) { - res[res.length] = "http://eatmanga.com" + $(this).val(); - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".baner", doc).remove(); - $("iframe", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#eatmanga_image_big", doc).size() > 0); - }, - - //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. - $("#main_inner", doc).empty(); - $("").appendTo($("#main_inner", doc)); - $("
").appendTo($("#main_inner", doc)); - $("").appendTo($("#main_inner", doc)); - $(".navAMR", doc).css("text-align", "center"); - $(".scanAMR", doc).css("background-color", "black"); - $(".scanAMR", doc).css("width", "100%"); - $("#main_inner", doc).css("width", "100%"); - $("#main_inner", doc).css("padding", "0"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = $("[id^='eatmanga_image']", div).attr("src"); - - $( image ).attr( "src", src ); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - /*$("select#chapters:first option", doc).each(function(index) { - $(this).val("http://eatmanga.com" + $(this).val()); - }); - - return $("select#chapters:first", doc);*/ - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var EatManga = { + //Name of the mirror + mirrorName : "EatManga", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/eatmanga.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("eatmanga.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://eatmanga.com/Manga-Scan/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#updates tr th a:first-child", div).each(function(index) { + res[res.length] = [$(this).text().trim(), "http://eatmanga.com" + $(this).attr("href")]; + }); + callback("EatManga", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#updates tr th a:first-child", div).each(function(index) { + if (index == 0) { + var _self = this; + $.ajax( + { + async: false, + url: "http://eatmanga.com" + $(_self).attr("href"), + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + if ($("img.eatmanga_bigimage", div).size() > 0) { + res[res.length] = [$(_self).text().trim(), "http://eatmanga.com" + $(_self).attr("href")]; + } + } + }); + } else { + res[res.length] = [$(this).text().trim(), "http://eatmanga.com" + $(this).attr("href")]; + } + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $("#breadcrumbs li:nth-child(3) a", doc).text(); + var nameurl = "http://eatmanga.com" + $("#breadcrumbs li:nth-child(3) a", doc).attr("href"); + var curChapName = $("head title", doc).text();//$("select#chapters:first option:selected", doc).text(); + var pos = curChapName.indexOf("-"); + if (pos != -1) { + curChapName = curChapName.substr(0, pos).trim(); + } + var chapurl;//"http://eatmanga.com" + $("select#chapters:first option:selected", doc).val(); + var tmpu = curUrl.replace(nameurl, ""); + var p = tmpu.indexOf("/"); + if (p != -1) { + chapurl = nameurl + tmpu.substr(0, p) + "/"; + } else { + chapurl = nameurl + tmpu + "/"; + } + callback({"name": name, + "currentChapter": curChapName, + "currentMangaURL": nameurl, + "currentChapterURL": chapurl}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl2) { + //This function runs in the DOM of the current consulted page. + var res = []; + $("select#pages:first option", doc).each(function(index) { + res[res.length] = "http://eatmanga.com" + $(this).val(); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".baner", doc).remove(); + $("iframe", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#eatmanga_image_big", doc).size() > 0); + }, + //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. + $("#main_inner", doc).empty(); + $("").appendTo($("#main_inner", doc)); + $("
").appendTo($("#main_inner", doc)); + $("").appendTo($("#main_inner", doc)); + $(".navAMR", doc).css("text-align", "center"); + $(".scanAMR", doc).css("background-color", "black"); + $(".scanAMR", doc).css("width", "100%"); + $("#main_inner", doc).css("width", "100%"); + $("#main_inner", doc).css("padding", "0"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = $("[id^='eatmanga_image']", div).attr("src"); + $( image ).attr( "src", src ); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + /*$("select#chapters:first option", doc).each(function(index) { + $(this).val("http://eatmanga.com" + $(this).val()); + }); + return $("select#chapters:first", doc);*/ + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("EatManga", EatManga); diff --git a/EvilFlowers.js b/EvilFlowers.js index ba69dd9..b910393 100644 --- a/EvilFlowers.js +++ b/EvilFlowers.js @@ -1,132 +1,131 @@ -var EvilFlowers = { - mirrorName : "Evil Flowers", - canListFullMangas : false, - mirrorIcon : "img/evilflowers.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("reader.evilflowers.com/") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://reader.evilflowers.com/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Evil Flowers", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('reader.evilflowers.com/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - $('#page').css("max-width", "none"); - $('#page').css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $('#page').css("max-width", "none"); - $('#page').css("width", "100%"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var EvilFlowers = { + mirrorName : "Evil Flowers", + canListFullMangas : false, + mirrorIcon : "img/evilflowers.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("reader.evilflowers.com/") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://reader.evilflowers.com/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Evil Flowers", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('reader.evilflowers.com/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + $('#page').css("max-width", "none"); + $('#page').css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $('#page').css("max-width", "none"); + $('#page').css("width", "100%"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Evil Flowers", EvilFlowers); diff --git a/ExtrasScans.js b/ExtrasScans.js index 324c745..3ed6834 100644 --- a/ExtrasScans.js +++ b/ExtrasScans.js @@ -1,136 +1,135 @@ -var ExtrasScans = { - mirrorName : "Extras Scans", - canListFullMangas : false, - mirrorIcon : "img/ExtrasScans.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("slide.extrascans.net") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://slide.extrascans.net/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Extras Scans", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .release > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $("title", doc).text().split(" :: ")[0]; - var currentChapter = $(".btn-group:eq(0) button.dropdown-toggle", doc).text().trim(); - var currentMangaURL = $(".controls > a", doc).attr("href"); - var currentChapterURL = $("a[title=\""+currentChapter+"\"]", doc).attr("href"); - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement("div"); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('.content', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('slide.extrascans.net/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - script.type = "text/javascript"; - doc.body.appendChild(script); - } - $(".content", doc).before(""); - $(".content", doc).after(""); - $(".content", doc).empty(); - $(".content", doc).css("width", "auto"); - $(".content", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(".controls").hide() - $(window).resize(function () { - $(".content", doc).css("max-width", "none"); - $(".content", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var ExtrasScans = { + mirrorName : "Extras Scans", + canListFullMangas : false, + mirrorIcon : "img/ExtrasScans.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("slide.extrascans.net") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://slide.extrascans.net/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Extras Scans", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .release > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $("title", doc).text().split(" :: ")[0]; + var currentChapter = $(".btn-group:eq(0) button.dropdown-toggle", doc).text().trim(); + var currentMangaURL = $(".controls > a", doc).attr("href"); + var currentChapterURL = $("a[title=\""+currentChapter+"\"]", doc).attr("href"); + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement("div"); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('.content', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('slide.extrascans.net/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + script.type = "text/javascript"; + doc.body.appendChild(script); + } + $(".content", doc).before(""); + $(".content", doc).after(""); + $(".content", doc).empty(); + $(".content", doc).css("width", "auto"); + $(".content", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(".controls").hide() + $(window).resize(function () { + $(".content", doc).css("max-width", "none"); + $(".content", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Extras Scans", ExtrasScans); diff --git a/FTHScans.js b/FTHScans.js index 278f8c5..540e773 100644 --- a/FTHScans.js +++ b/FTHScans.js @@ -1,136 +1,135 @@ -var FTHScans = { - mirrorName : "For The Halibut", - canListFullMangas : false, - mirrorIcon : "img/fthscans.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("reader.fth-scans.com/") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://reader.fth-scans.com/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("For The Halibut", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - type : 'POST', - data : { - 'adult' : true - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('reader.fth-scans.com/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var FTHScans = { + mirrorName : "For The Halibut", + canListFullMangas : false, + mirrorIcon : "img/fthscans.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("reader.fth-scans.com/") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://reader.fth-scans.com/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("For The Halibut", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + type : 'POST', + data : { + 'adult' : true + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('reader.fth-scans.com/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("For The Halibut", FTHScans); diff --git a/FoolRulez.js b/FoolRulez.js index 0a328ec..84252e2 100644 --- a/FoolRulez.js +++ b/FoolRulez.js @@ -1,130 +1,129 @@ -var FoolRulez = { - mirrorName : "FoOlRulez", - canListFullMangas : true, - mirrorIcon : "img/foolrulez.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("foolrulez.org") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://foolrulez.org/slide/reader/list/", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list.series > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("FoOlRulez", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads.iframe.banner", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('foolrulez.org/slide/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR", doc).css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - }, +var FoolRulez = { + mirrorName : "FoOlRulez", + canListFullMangas : true, + mirrorIcon : "img/foolrulez.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("foolrulez.org") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://foolrulez.org/slide/reader/list/", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list.series > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("FoOlRulez", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads.iframe.banner", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('foolrulez.org/slide/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR", doc).css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("FoOlRulez", FoolRulez); diff --git a/GaoSubs.js b/GaoSubs.js index 9037537..a6631af 100644 --- a/GaoSubs.js +++ b/GaoSubs.js @@ -1,145 +1,144 @@ -var GaoSubs = { - mirrorName: "Gao-subs", - canListFullMangas: false, - mirrorIcon: "img/gaosubs.png", - languages: "en", - isMe: function (url) { - "use strict"; - return (url.search(/(gao-subs|gaomanga)\.com/g) > -1); - }, - getMangaList: function (search, callback) { - "use strict"; - $.ajax({ - url: "http://www.gaomanga.com/search/search.php?search=" + search, - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ 0); - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - "use strict"; - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "document['onkeyup'] = {};"; - doc.body.appendChild(script); - } - $('.chapterTitle', doc).css('min-width', ''); - $('.chapterTitle', doc).css('width', '100%'); - $('.pageNavigator', doc).hide(); - $('#midManga', doc).hide(); - $('.note', doc).hide(); - $("#belowTitle", doc).prepend($("")); - $("#belowTitle", doc).prepend($("
")); - $("#belowTitle", doc).prepend($("")); - $(".navAMR", doc).css("text-align", "center"); - }, - nextChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() > 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() > 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - "use strict"; - $(image).attr("src", urlImg); - }, - isImageInOneCol: function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - "use strict"; - var chpinfo = []; - $("#select_ch option").each(function () { - $(this).val().split(';') - chpinfo.push($(this).val().split(';')) - }); - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - } +var GaoSubs = { + mirrorName: "Gao-subs", + canListFullMangas: false, + mirrorIcon: "img/gaosubs.png", + languages: "en", + isMe: function (url) { + "use strict"; + return (url.search(/(gao-subs|gaomanga)\.com/g) > -1); + }, + getMangaList: function (search, callback) { + "use strict"; + $.ajax({ + url: "http://www.gaomanga.com/search/search.php?search=" + search, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ 0); + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + "use strict"; + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "document['onkeyup'] = {};"; + doc.body.appendChild(script); + } + $('.chapterTitle', doc).css('min-width', ''); + $('.chapterTitle', doc).css('width', '100%'); + $('.pageNavigator', doc).hide(); + $('#midManga', doc).hide(); + $('.note', doc).hide(); + $("#belowTitle", doc).prepend($("")); + $("#belowTitle", doc).prepend($("
")); + $("#belowTitle", doc).prepend($("")); + $(".navAMR", doc).css("text-align", "center"); + }, + nextChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() > 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() > 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + "use strict"; + $(image).attr("src", urlImg); + }, + isImageInOneCol: function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + "use strict"; + var chpinfo = []; + $("#select_ch option").each(function () { + $(this).val().split(';') + chpinfo.push($(this).val().split(';')) + }); + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Gao-subs", GaoSubs); diff --git a/GodHandScans.js b/GodHandScans.js index cabf1a4..ab769e2 100644 --- a/GodHandScans.js +++ b/GodHandScans.js @@ -1,229 +1,203 @@ -var GodHandScans = -{ - mirrorName: "God Hand Scans", - canListFullMangas: true, - mirrorIcon: "img/godhandscans.png", - languages: "pt", - - //Return true if the url corresponds to the mirror - isMe: function(url) - { - return (url.indexOf("godhandscans.com.br/manga/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://godhandscans.com.br/directory/", - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('tr:has(td.chapter) td.series a', div).each(function(index) - { - res.push([$(this).text(), $(this).attr('href')]); - }); - - callback("God Hand Scans", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('td.series a', div).each(function(index) - { - res.push([$(this).text(), $(this).attr('href')]); - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name = $('h2', doc).text(); - var currentChapter = $('select.viewerChapter:first option:selected', doc).text(); - var currentMangaURL = $('h2 a', doc).attr('href'); - var currentChapterURL = currentMangaURL + $('select.viewerChapter:first option:selected', doc).attr('value') + '/'; - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages: function(doc, curUrl) - { - var currentMangaURL = $('h2 a', doc).attr('href'); - var currentChapterURL = currentMangaURL + $('select.viewerChapter:first option:selected', doc).attr('value') + '/'; - - var res = []; - $('select.viewerPage:first option', doc).each(function() - { - res.push(currentChapterURL + $(this).attr('value') + '/'); - }); - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - $("iframe", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans: function(doc, curUrl) - { - return $('.imgAMR', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - if ($('#imageWrapper', doc)) - { - return true; - } - return false; - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans: function(doc, curUrl) - { - doc.onkeyup = null; - $(doc.body).css('background-color', '#f4f4f4'); - $("#content table", doc).remove(); - $("#content", doc).append($("")); - $("#content", doc).append($("
")); - $("#content", doc).append($("")); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $.ajax( - { - url: urlImg, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var src = $('#imageWrapper img', div).attr('src'); - - $(image).attr("src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol : function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - } +var GodHandScans = +{ + mirrorName: "God Hand Scans", + canListFullMangas: true, + mirrorIcon: "img/godhandscans.png", + languages: "pt", + //Return true if the url corresponds to the mirror + isMe: function(url) + { + return (url.indexOf("godhandscans.com.br/manga/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://godhandscans.com.br/directory/", + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('tr:has(td.chapter) td.series a', div).each(function(index) + { + res.push([$(this).text(), $(this).attr('href')]); + }); + callback("God Hand Scans", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('td.series a', div).each(function(index) + { + res.push([$(this).text(), $(this).attr('href')]); + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name = $('h2', doc).text(); + var currentChapter = $('select.viewerChapter:first option:selected', doc).text(); + var currentMangaURL = $('h2 a', doc).attr('href'); + var currentChapterURL = currentMangaURL + $('select.viewerChapter:first option:selected', doc).attr('value') + '/'; + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages: function(doc, curUrl) + { + var currentMangaURL = $('h2 a', doc).attr('href'); + var currentChapterURL = currentMangaURL + $('select.viewerChapter:first option:selected', doc).attr('value') + '/'; + var res = []; + $('select.viewerPage:first option', doc).each(function() + { + res.push(currentChapterURL + $(this).attr('value') + '/'); + }); + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + $("iframe", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans: function(doc, curUrl) + { + return $('.imgAMR', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + if ($('#imageWrapper', doc)) + { + return true; + } + return false; + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans: function(doc, curUrl) + { + doc.onkeyup = null; + $(doc.body).css('background-color', '#f4f4f4'); + $("#content table", doc).remove(); + $("#content", doc).append($("")); + $("#content", doc).append($("
")); + $("#content", doc).append($("")); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $.ajax( + { + url: urlImg, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $('#imageWrapper img', div).attr('src'); + $(image).attr("src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol : function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("God Hand Scans", GodHandScans); diff --git a/GoodManga.js b/GoodManga.js index afa007e..1ce8469 100644 --- a/GoodManga.js +++ b/GoodManga.js @@ -1,126 +1,125 @@ -var GoodManga = { - mirrorName : "GoodManga", - canListFullMangas : false, - mirrorIcon : "img/goodmanga.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("www.goodmanga.net/") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://www.goodmanga.net/manga-search?key=" + search + "&search=Go" + "", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $("#manga_nav_top", doc).remove(); - $("#manga_nav_bottom", doc).remove(); - $("#manga_viewer", doc).empty(); - $("#manga_viewer", doc).before(""); - $("#manga_viewer", doc).after(""); - $(".navAMR", doc).css("text-align", "center"); - $("#content", doc).css("background-color", "black"); - $("#manga_viewer", doc).css("padding-top", "10px"); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("#manga_viewer img", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - $("select#bottom_chapter_list:first option", doc).each(function (index) { - $(this).val("http://www.goodmanga.net" + $(this).val()); - }); - return $("select.chapter_select:first", doc); - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var GoodManga = { + mirrorName : "GoodManga", + canListFullMangas : false, + mirrorIcon : "img/goodmanga.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("www.goodmanga.net/") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://www.goodmanga.net/manga-search?key=" + search + "&search=Go" + "", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $("#manga_nav_top", doc).remove(); + $("#manga_nav_bottom", doc).remove(); + $("#manga_viewer", doc).empty(); + $("#manga_viewer", doc).before(""); + $("#manga_viewer", doc).after(""); + $(".navAMR", doc).css("text-align", "center"); + $("#content", doc).css("background-color", "black"); + $("#manga_viewer", doc).css("padding-top", "10px"); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("#manga_viewer img", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + $("select#bottom_chapter_list:first option", doc).each(function (index) { + $(this).val("http://www.goodmanga.net" + $(this).val()); + }); + return $("select.chapter_select:first", doc); + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("GoodManga", GoodManga); diff --git a/Haruka.js b/Haruka.js index 6cd042b..e144e43 100644 --- a/Haruka.js +++ b/Haruka.js @@ -1,227 +1,204 @@ -var Haruka = -{ - mirrorName: "Haru-ka", - canListFullMangas: false, - mirrorIcon: "img/haruka.png", - languages: "pt", - - //Return true if the url corresponds to the mirror - isMe: function(url) - { - return (url.indexOf("leitor.haru-ka.net") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://leitor.haru-ka.net/reader/search/", - type: 'POST', - data: - { - 'search': search - }, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('.list > .group > .title > a', div).each(function(index) - { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - - callback("Haru-ka", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('.list > .element > .title > a', div).each(function(index) - { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages: function(doc, curUrl) - { - var res = []; - eval($('body', doc).html().match(/var pages = .*\n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - // No ads here - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans: function(doc, curUrl) - { - return $('#page', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return (curUrl.search('leitor.haru-ka.net/reader/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans: function(doc, curUrl) - { - if (typeof doc.createElement == 'function') - { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR", doc).css("text-align", "center"); - $(window).resize(function() - { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol : function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - } +var Haruka = +{ + mirrorName: "Haru-ka", + canListFullMangas: false, + mirrorIcon: "img/haruka.png", + languages: "pt", + //Return true if the url corresponds to the mirror + isMe: function(url) + { + return (url.indexOf("leitor.haru-ka.net") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://leitor.haru-ka.net/reader/search/", + type: 'POST', + data: + { + 'search': search + }, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function(index) + { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback("Haru-ka", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function(index) + { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages: function(doc, curUrl) + { + var res = []; + eval($('body', doc).html().match(/var pages = .*\n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + // No ads here + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans: function(doc, curUrl) + { + return $('#page', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return (curUrl.search('leitor.haru-ka.net/reader/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans: function(doc, curUrl) + { + if (typeof doc.createElement == 'function') + { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR", doc).css("text-align", "center"); + $(window).resize(function() + { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol : function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Haru-ka", Haruka); diff --git a/HimawariMangas.js b/HimawariMangas.js index faf0872..338a039 100644 --- a/HimawariMangas.js +++ b/HimawariMangas.js @@ -1,271 +1,249 @@ -var HimawariMangas = -{ - mirrorName: "Himawari Mangás", - canListFullMangas: true, - mirrorIcon: "img/himawarimangas.png", - languages: "pt", - - isMe : function(url) - { - return (url.indexOf("read.himawarimangas.com.br/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://read.himawarimangas.com.br/", - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $(".selector2 .options a", div).each(function(index) - { - res.push([$(this).attr("title").trim(), "http://read.himawarimangas.com.br/" + $(this).attr("href")]); - }); - callback("Himawari Mangás", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $(".theList .chapter", div).each(function(index) - { - res.push([$("b", $(this)).text().trim(), "http://read.himawarimangas.com.br/" + $("a", $(this)).attr("href")]); - }); - - callback(res, obj); - } - }); - }, - - retrieveInfo: function(sel) - { - var _obj = {}; - var curval = $(sel.contents()[0]).text(); - var pos = curval.indexOf(": "); - curval = curval.substring(pos + 2, curval.length).trim(); - $("a", sel).each(function(index) - { - if ($(".option", $(this)).text().trim() == curval) - { - _obj = {name: curval, url: "http://read.himawarimangas.com.br/" + $(this).attr("href")}; - } - }); - return _obj; - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - var manga = HimawariMangas.retrieveInfo($($(".selector2", doc)[0])); - var chapter = HimawariMangas.retrieveInfo($($(".selector2", doc)[1])); - name = manga.name; - currentChapter = chapter.name; - currentChapterURL = chapter.url; - currentMangaURL = manga.url; - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - //This function runs in the DOM of the current consulted page. - getListImages: function(doc, curUrl) - { - var res = []; - $("script", doc).each(function(index) - { - if ($(this).text().indexOf("imageArray = new Array();") != -1) - { - var txt = $(this).text(); - var pos = txt.indexOf("imageArray["); - while (pos != -1) - { - var debur = txt.indexOf("'", pos); - var finur = txt.indexOf("'", debur + 1); - res.push("http://read.himawarimangas.com.br/" + txt.substring(debur + 1, finur)); - pos = txt.indexOf("imageArray[", finur + 1); - } - } - }); - res.pop() - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - $(".ads", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteScans: function(doc, curUrl) - { - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return ($("#theManga #thePic", doc).size() > 0); - }, - - //This method is called before displaying full chapters in the page - //This function runs in the DOM of the current consulted page. - doSomethingBeforeWritingScans: function(doc, curUrl) - { - if (typeof doc.createElement == 'function') - { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keyup');"; - doc.body.appendChild(script); - } - $("#theManga", doc).empty(); - var cloned = $("#theManga", doc).clone(); - $("#theManga", doc).after(cloned); - cloned.attr("id", "amrManga"); - $("#theManga", doc).remove(); - $("#amrManga", doc).css("width", "auto"); - $("#amrManga", doc).css("margin", "0"); - $("#theHead", doc).remove(); - $("").appendTo($("#amrManga", doc)); - $("
").appendTo($("#amrManga", doc)); - $("").appendTo($("#amrManga", doc)); - $(".navAMR", doc).css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) - { - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol: function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - var sel = $($(".selector2", doc)[1]); - var ret = $(""); - var curval = $(sel.contents()[0]).text(); - var pos = curval.indexOf(": "); - curval = curval.substring(pos + 2, curval.length).trim(); - $("a", sel).each(function(index) - { - var iscur = false; - if ($(".option", $(this)).text().trim() == curval) - { - iscur = true; - } - $("").appendTo(ret); - }); - return ret; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded : function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - $('#infoSpread').hide(); - } +var HimawariMangas = +{ + mirrorName: "Himawari Mangás", + canListFullMangas: true, + mirrorIcon: "img/himawarimangas.png", + languages: "pt", + isMe : function(url) + { + return (url.indexOf("read.himawarimangas.com.br/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://read.himawarimangas.com.br/", + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $(".selector2 .options a", div).each(function(index) + { + res.push([$(this).attr("title").trim(), "http://read.himawarimangas.com.br/" + $(this).attr("href")]); + }); + callback("Himawari Mangás", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $(".theList .chapter", div).each(function(index) + { + res.push([$("b", $(this)).text().trim(), "http://read.himawarimangas.com.br/" + $("a", $(this)).attr("href")]); + }); + callback(res, obj); + } + }); + }, + retrieveInfo: function(sel) + { + var _obj = {}; + var curval = $(sel.contents()[0]).text(); + var pos = curval.indexOf(": "); + curval = curval.substring(pos + 2, curval.length).trim(); + $("a", sel).each(function(index) + { + if ($(".option", $(this)).text().trim() == curval) + { + _obj = {name: curval, url: "http://read.himawarimangas.com.br/" + $(this).attr("href")}; + } + }); + return _obj; + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + var manga = HimawariMangas.retrieveInfo($($(".selector2", doc)[0])); + var chapter = HimawariMangas.retrieveInfo($($(".selector2", doc)[1])); + name = manga.name; + currentChapter = chapter.name; + currentChapterURL = chapter.url; + currentMangaURL = manga.url; + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + //This function runs in the DOM of the current consulted page. + getListImages: function(doc, curUrl) + { + var res = []; + $("script", doc).each(function(index) + { + if ($(this).text().indexOf("imageArray = new Array();") != -1) + { + var txt = $(this).text(); + var pos = txt.indexOf("imageArray["); + while (pos != -1) + { + var debur = txt.indexOf("'", pos); + var finur = txt.indexOf("'", debur + 1); + res.push("http://read.himawarimangas.com.br/" + txt.substring(debur + 1, finur)); + pos = txt.indexOf("imageArray[", finur + 1); + } + } + }); + res.pop() + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + $(".ads", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteScans: function(doc, curUrl) + { + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return ($("#theManga #thePic", doc).size() > 0); + }, + //This method is called before displaying full chapters in the page + //This function runs in the DOM of the current consulted page. + doSomethingBeforeWritingScans: function(doc, curUrl) + { + if (typeof doc.createElement == 'function') + { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keyup');"; + doc.body.appendChild(script); + } + $("#theManga", doc).empty(); + var cloned = $("#theManga", doc).clone(); + $("#theManga", doc).after(cloned); + cloned.attr("id", "amrManga"); + $("#theManga", doc).remove(); + $("#amrManga", doc).css("width", "auto"); + $("#amrManga", doc).css("margin", "0"); + $("#theHead", doc).remove(); + $("").appendTo($("#amrManga", doc)); + $("
").appendTo($("#amrManga", doc)); + $("").appendTo($("#amrManga", doc)); + $(".navAMR", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) + { + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol: function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + var sel = $($(".selector2", doc)[1]); + var ret = $(""); + var curval = $(sel.contents()[0]).text(); + var pos = curval.indexOf(": "); + curval = curval.substring(pos + 2, curval.length).trim(); + $("a", sel).each(function(index) + { + var iscur = false; + if ($(".option", $(this)).text().trim() == curval) + { + iscur = true; + } + $("").appendTo(ret); + }); + return ret; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded : function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + $('#infoSpread').hide(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Himawari Mangás", HimawariMangas); diff --git a/Imangascans.js b/Imangascans.js index db44979..12c0073 100644 --- a/Imangascans.js +++ b/Imangascans.js @@ -1,146 +1,145 @@ -var Imangascans = { - mirrorName: "Imangascans", - canListFullMangas: true, - mirrorIcon: "img/imangascans.png", - languages: "en", - isMe: function (url) { - "use strict"; - return (url.indexOf("reader.imangascans.org") !== -1); - }, - getMangaList: function (search, callback) { - "use strict"; - $.ajax({ - url: "https://reader.imangascans.org/", - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ 0); - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - "use strict"; - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $('td.mid', doc).empty(); - $('td.mid', doc).append($("")); - $('td.mid', doc).append($("
")); - $('td.mid', doc).append($("")); - $(".navAMR").css("text-align", "center"); - }, - nextChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - "use strict"; - $(image).attr("src", urlImg); - }, - isImageInOneCol: function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - "use strict"; - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - $("body", doc).css('background-color', '#f5f5f5'); - } +var Imangascans = { + mirrorName: "Imangascans", + canListFullMangas: true, + mirrorIcon: "img/imangascans.png", + languages: "en", + isMe: function (url) { + "use strict"; + return (url.indexOf("reader.imangascans.org") !== -1); + }, + getMangaList: function (search, callback) { + "use strict"; + $.ajax({ + url: "https://reader.imangascans.org/", + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ 0); + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + "use strict"; + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $('td.mid', doc).empty(); + $('td.mid', doc).append($("")); + $('td.mid', doc).append($("
")); + $('td.mid', doc).append($("")); + $(".navAMR").css("text-align", "center"); + }, + nextChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + "use strict"; + $(image).attr("src", urlImg); + }, + isImageInOneCol: function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + "use strict"; + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + $("body", doc).css('background-color', '#f5f5f5'); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Imangascans", Imangascans); diff --git a/ImperialScans.js b/ImperialScans.js index 1be69bd..bba0510 100644 --- a/ImperialScans.js +++ b/ImperialScans.js @@ -1,245 +1,221 @@ -var ImperialScans = -{ - // Name of the mirror - mirrorName: "Imperial Scans", - // True if the mirror can list all of its mangas. - canListFullMangas: true, - // Extension internal link to the icon of the mirror. (if not filled, will be blank...) - mirrorIcon: "img/imperial.png", - languages: "en", - - //Return true if the url corresponds to the mirror - isMe: function(url) - { - return (url.indexOf("imperialscans.com") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://imperialscans.com/archive", - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('#chapters-list .manga-entry', div).each(function() - { - res.push([$('h2', $(this)).text(), 'http://imperialscans.com' + $('li:first a', $(this)).attr('href').match(/^\/read\/[^/]*/g)[0]]); - }); - - callback("Imperial Scans", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $('#chapter-select option', div).each(function() - { - if ($(this).attr('value') == '') return true; - res.push([$(this).text(), 'http://imperialscans.com' + $(this).attr('value')]); - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var hlogospan = $('#hlogo span', doc).text(); - var name = hlogospan.substr(1, hlogospan.lastIndexOf(' ') - 1); - var currentChapter = hlogospan.substr(hlogospan.lastIndexOf(' ') + 1); - var currentMangaURL = 'http://imperialscans.com' + $('#series-select option:contains('+name+')', doc).attr('value'); - var currentChapterURL = 'http://imperialscans.com' + $('#chapter-select option:contains('+currentChapter+')', doc).attr('value'); - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL} - ); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages: function(doc, curUrl) - { - var res = []; - $('#page-select option', doc).each(function() - { - if ($(this).attr('value') == '') return true; - res.push($(this).attr('value')); - }); - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - $('#leaderboard', doc).remove(); - $('#side-ad', doc).remove(); - $('#p180-root', doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans: function(doc, curUrl) - { - return $('#container .pageAMR', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return (curUrl.search('imperialscans.com/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans: function(doc, curUrl) - { - if (typeof doc.createElement == 'function') - { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#container .page", doc).before($("")); - $("#container .page", doc).after($("")); - $("#container .page", doc).empty(); - $("#container .page", doc).css("width", "100%"); - $("#container .page", doc).css("text-align", "center"); - $("#container .page", doc).attr('class', 'pageAMR'); - $('#chapter-select', doc).hide(); - $('#page-select', doc).hide(); - $('#prevPage', doc).remove(); - $('#nextPage', doc).remove(); - $(".navAMR", doc).css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - var hlogospan = $('#hlogo span', doc).text(); - var currentChapter = hlogospan.substr(hlogospan.lastIndexOf(' ') + 1); - if ($('#chapter-select option:contains('+currentChapter+')', doc).prev().attr('value')) - { - return 'http://imperialscans.com' + $('#chapter-select option:contains('+currentChapter+')', doc).prev().attr('value'); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - var hlogospan = $('#hlogo span', doc).text(); - var currentChapter = hlogospan.substr(hlogospan.lastIndexOf(' ') + 1); - if ($('#chapter-select option:contains('+currentChapter+')', doc).next().attr('value')) - { - return 'http://imperialscans.com' + $('#chapter-select option:contains('+currentChapter+')', doc).next().attr('value'); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $.ajax( - { - url: 'http://imperialscans.com' + urlImg, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var src = 'http://imperialscans.com' + $('#page-img', div).attr('src'); - - $(image).attr("src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol: function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - } +var ImperialScans = +{ + // Name of the mirror + mirrorName: "Imperial Scans", + // True if the mirror can list all of its mangas. + canListFullMangas: true, + // Extension internal link to the icon of the mirror. (if not filled, will be blank...) + mirrorIcon: "img/imperial.png", + languages: "en", + //Return true if the url corresponds to the mirror + isMe: function(url) + { + return (url.indexOf("imperialscans.com") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://imperialscans.com/archive", + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('#chapters-list .manga-entry', div).each(function() + { + res.push([$('h2', $(this)).text(), 'http://imperialscans.com' + $('li:first a', $(this)).attr('href').match(/^\/read\/[^/]*/g)[0]]); + }); + callback("Imperial Scans", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('#chapter-select option', div).each(function() + { + if ($(this).attr('value') == '') return true; + res.push([$(this).text(), 'http://imperialscans.com' + $(this).attr('value')]); + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var hlogospan = $('#hlogo span', doc).text(); + var name = hlogospan.substr(1, hlogospan.lastIndexOf(' ') - 1); + var currentChapter = hlogospan.substr(hlogospan.lastIndexOf(' ') + 1); + var currentMangaURL = 'http://imperialscans.com' + $('#series-select option:contains('+name+')', doc).attr('value'); + var currentChapterURL = 'http://imperialscans.com' + $('#chapter-select option:contains('+currentChapter+')', doc).attr('value'); + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL} + ); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages: function(doc, curUrl) + { + var res = []; + $('#page-select option', doc).each(function() + { + if ($(this).attr('value') == '') return true; + res.push($(this).attr('value')); + }); + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + $('#leaderboard', doc).remove(); + $('#side-ad', doc).remove(); + $('#p180-root', doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans: function(doc, curUrl) + { + return $('#container .pageAMR', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return (curUrl.search('imperialscans.com/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans: function(doc, curUrl) + { + if (typeof doc.createElement == 'function') + { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#container .page", doc).before($("")); + $("#container .page", doc).after($("")); + $("#container .page", doc).empty(); + $("#container .page", doc).css("width", "100%"); + $("#container .page", doc).css("text-align", "center"); + $("#container .page", doc).attr('class', 'pageAMR'); + $('#chapter-select', doc).hide(); + $('#page-select', doc).hide(); + $('#prevPage', doc).remove(); + $('#nextPage', doc).remove(); + $(".navAMR", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + var hlogospan = $('#hlogo span', doc).text(); + var currentChapter = hlogospan.substr(hlogospan.lastIndexOf(' ') + 1); + if ($('#chapter-select option:contains('+currentChapter+')', doc).prev().attr('value')) + { + return 'http://imperialscans.com' + $('#chapter-select option:contains('+currentChapter+')', doc).prev().attr('value'); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + var hlogospan = $('#hlogo span', doc).text(); + var currentChapter = hlogospan.substr(hlogospan.lastIndexOf(' ') + 1); + if ($('#chapter-select option:contains('+currentChapter+')', doc).next().attr('value')) + { + return 'http://imperialscans.com' + $('#chapter-select option:contains('+currentChapter+')', doc).next().attr('value'); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $.ajax( + { + url: 'http://imperialscans.com' + urlImg, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = 'http://imperialscans.com' + $('#page-img', div).attr('src'); + $(image).attr("src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol: function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Imperial Scans", ImperialScans); diff --git a/ItaScan.js b/ItaScan.js index b780615..826d741 100644 --- a/ItaScan.js +++ b/ItaScan.js @@ -1,235 +1,202 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var ItaScan = { - //Name of the mirror - mirrorName : "ItaScan", - //True if the mirror can list all of its mangas. - canListFullMangas : false, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/itascan.png", - //Languages of scans for the mirror - languages : "it", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("itascan.info/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.itascan.info/search/", - type: 'POST', - data: "nomemanga=" + search, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("a", $("#newsgroup > div", div)).each(function(index) { - res[res.length] = [$(this).text().trim(), "http://www.itascan.info" + $(this).attr("href")]; - }); - callback("ItaScan", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - //console.log($($("#left-menuall .news > div", div)[1]).html()); - //console.log($("div > a", $($("#left-menuall .news > div", div)[1])).size()); - $("div > a", $($("#left-menuall .news > div", div)[1])).each(function(index) { - var team = $("a", $(this).parent().next()).text(); - res[res.length] = [$(this).text().trim() + " (" + team + ")", "http://www.itascan.info" + $(this).attr("href")]; - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("#contenitore span.nomemanga a", doc).text().trim(); - currentChapter = $("#contenitore .menu select option:selected", doc).text(); - currentChapterURL = "http://www.itascan.info/" + $("#contenitore .menu select option:selected", doc).val(); - currentMangaURL = "http://www.itascan.info" + $("#contenitore span.nomemanga a", doc).attr("href"); - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - $("option", $($("select[name='task']", doc)[0])).each(function(index) { - res[res.length] = "http://www.itascan.info/" + $(this).val(); - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".pubblicita", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#image", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $($(".width", doc)[2]).add($($(".width", doc)[4])); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#wievcap", doc).size() > 0); - }, - - //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. - $("#image", doc).empty(); - $("#image", doc).css("width", "auto"); - $("#image", doc).css("background-color", "black"); - $("#image", doc).css("padding-top", "10px"); - $($(".width", doc)[2]).empty(); - $($(".width", doc)[4]).empty(); - - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = "http://www.itascan.info" + $("#wievcap", div).attr("src"); - - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#contenitore .menu select option", doc).each(function(index) { - $(this).val("http://www.itascan.info/" + $(this).val()); - }); - - return $("#contenitore .menu select", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var ItaScan = { + //Name of the mirror + mirrorName : "ItaScan", + //True if the mirror can list all of its mangas. + canListFullMangas : false, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/itascan.png", + //Languages of scans for the mirror + languages : "it", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("itascan.info/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.itascan.info/search/", + type: 'POST', + data: "nomemanga=" + search, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("a", $("#newsgroup > div", div)).each(function(index) { + res[res.length] = [$(this).text().trim(), "http://www.itascan.info" + $(this).attr("href")]; + }); + callback("ItaScan", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + //console.log($($("#left-menuall .news > div", div)[1]).html()); + //console.log($("div > a", $($("#left-menuall .news > div", div)[1])).size()); + $("div > a", $($("#left-menuall .news > div", div)[1])).each(function(index) { + var team = $("a", $(this).parent().next()).text(); + res[res.length] = [$(this).text().trim() + " (" + team + ")", "http://www.itascan.info" + $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("#contenitore span.nomemanga a", doc).text().trim(); + currentChapter = $("#contenitore .menu select option:selected", doc).text(); + currentChapterURL = "http://www.itascan.info/" + $("#contenitore .menu select option:selected", doc).val(); + currentMangaURL = "http://www.itascan.info" + $("#contenitore span.nomemanga a", doc).attr("href"); + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + $("option", $($("select[name='task']", doc)[0])).each(function(index) { + res[res.length] = "http://www.itascan.info/" + $(this).val(); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".pubblicita", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#image", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $($(".width", doc)[2]).add($($(".width", doc)[4])); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#wievcap", doc).size() > 0); + }, + //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. + $("#image", doc).empty(); + $("#image", doc).css("width", "auto"); + $("#image", doc).css("background-color", "black"); + $("#image", doc).css("padding-top", "10px"); + $($(".width", doc)[2]).empty(); + $($(".width", doc)[4]).empty(); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = "http://www.itascan.info" + $("#wievcap", div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#contenitore .menu select option", doc).each(function(index) { + $(this).val("http://www.itascan.info/" + $(this).val()); + }); + return $("#contenitore .menu select", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("ItaScan", ItaScan); diff --git a/Japanzai.js b/Japanzai.js index 5b133ff..07f4176 100644 --- a/Japanzai.js +++ b/Japanzai.js @@ -1,166 +1,165 @@ -var Japanzai = { - mirrorName: "Japanzai & XscansX", - canListFullMangas: false, - mirrorIcon: "img/japanzai.png", - languages: "en", - isMe: function (url) { - "use strict"; - return (url.indexOf("reader.japanzai.com/") !== -1); - }, - getMangaList: function (search, callback) { - "use strict"; - $.ajax({ - url: "https://reader.japanzai.com/search/", - type: 'POST', - data: { - 'search': search - }, - success: function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ -1); - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - "use strict"; - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; - script.type = 'text/javascript'; - doc.body.appendChild(script); - } - $('#page', doc).css("max-width", "none"); - $('#page', doc).css("width", "100%"); - $("#page", doc).before(""); - $("#page", doc).after(""); - $("#page", doc).empty(); - }, - nextChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - "use strict"; - $(image).attr("src", urlImg); - }, - isImageInOneCol: function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - "use strict"; - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - } +var Japanzai = { + mirrorName: "Japanzai & XscansX", + canListFullMangas: false, + mirrorIcon: "img/japanzai.png", + languages: "en", + isMe: function (url) { + "use strict"; + return (url.indexOf("reader.japanzai.com/") !== -1); + }, + getMangaList: function (search, callback) { + "use strict"; + $.ajax({ + url: "https://reader.japanzai.com/search/", + type: 'POST', + data: { + 'search': search + }, + success: function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ -1); + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + "use strict"; + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; + script.type = 'text/javascript'; + doc.body.appendChild(script); + } + $('#page', doc).css("max-width", "none"); + $('#page', doc).css("width", "100%"); + $("#page", doc).before(""); + $("#page", doc).after(""); + $("#page", doc).empty(); + }, + nextChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + "use strict"; + $(image).attr("src", urlImg); + }, + isImageInOneCol: function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + "use strict"; + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Japanzai & XscansX", Japanzai); diff --git a/KawaiiScans.js b/KawaiiScans.js index c332976..d2e6b41 100644 --- a/KawaiiScans.js +++ b/KawaiiScans.js @@ -1,136 +1,135 @@ -var KawaiiScans = { - mirrorName : "Kawaii Scans", - canListFullMangas : true, - mirrorIcon : "img/kawaiiscans.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("kawaii.ca/") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://kawaii.ca/reader/", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $("select[name='manga'] option", div).each(function (index) { - if ($(this).attr('value') !== 0) { - res.push([$(this).text(), 'http://kawaii.ca/reader/' + $(this).attr('value')]); - } - }); - callback("Kawaii Scans", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var currentMangaURL = 'http://kawaii.ca/reader/' + $("select[name='manga']:first option[selected]", div).attr('value'); - var res = []; - $("select[name='chapter']:first option", div).each(function (index) { - res.push([$(this).text(), currentMangaURL + (res.length > 0 ? '/' + $(this).attr('value') : '')]); - }); - res.reverse(); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $("select[name='manga']:first option[selected]", doc).text(); - var currentChapter = $("select[name='chapter']:first option[selected]", doc).text(); - var currentMangaURL = 'http://kawaii.ca/reader/' + $("select[name='manga']:first option[selected]", doc).attr('value'); - var currentChapterURL; - if ($("select[name='chapter']:first option[selected]", doc).attr('value') === $("select[name='chapter']:first option:first", doc).attr('value')) { - currentChapterURL = currentMangaURL; - } else { - currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); - } - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var currentMangaURL = 'http://kawaii.ca/reader/' + $("select[name='manga']:first option[selected]", doc).attr('value'); - var currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); - var res = []; - $("select[name='page']:first option", doc).each(function () { - if ($(this).attr('value') === '') { - return true; - } - res.push(currentChapterURL + '/' + $(this).attr('value')); - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $('.ads').remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('.imgAMR', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return ($("select[name='chapter']", doc).length > 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - doc.onkeydown = null; - $('td.mid table', doc).remove(); - $('td.mid', doc).css('background-color', '#f4f4f4'); - $('td.mid', doc).append($("")); - $('td.mid', doc).append($("
")); - $('td.mid', doc).append($("")); - $(".navAMR").css("text-align", "center"); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = 'http://kawaii.ca/reader/' + $('img.picture', div).attr('src'); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - $("body", doc).css('background-color', '#f5f5f5'); - } +var KawaiiScans = { + mirrorName : "Kawaii Scans", + canListFullMangas : true, + mirrorIcon : "img/kawaiiscans.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("kawaii.ca/") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://kawaii.ca/reader/", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("select[name='manga'] option", div).each(function (index) { + if ($(this).attr('value') !== 0) { + res.push([$(this).text(), 'http://kawaii.ca/reader/' + $(this).attr('value')]); + } + }); + callback("Kawaii Scans", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var currentMangaURL = 'http://kawaii.ca/reader/' + $("select[name='manga']:first option[selected]", div).attr('value'); + var res = []; + $("select[name='chapter']:first option", div).each(function (index) { + res.push([$(this).text(), currentMangaURL + (res.length > 0 ? '/' + $(this).attr('value') : '')]); + }); + res.reverse(); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $("select[name='manga']:first option[selected]", doc).text(); + var currentChapter = $("select[name='chapter']:first option[selected]", doc).text(); + var currentMangaURL = 'http://kawaii.ca/reader/' + $("select[name='manga']:first option[selected]", doc).attr('value'); + var currentChapterURL; + if ($("select[name='chapter']:first option[selected]", doc).attr('value') === $("select[name='chapter']:first option:first", doc).attr('value')) { + currentChapterURL = currentMangaURL; + } else { + currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); + } + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var currentMangaURL = 'http://kawaii.ca/reader/' + $("select[name='manga']:first option[selected]", doc).attr('value'); + var currentChapterURL = currentMangaURL + '/' + $("select[name='chapter']:first option[selected]", doc).attr('value'); + var res = []; + $("select[name='page']:first option", doc).each(function () { + if ($(this).attr('value') === '') { + return true; + } + res.push(currentChapterURL + '/' + $(this).attr('value')); + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $('.ads').remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('.imgAMR', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return ($("select[name='chapter']", doc).length > 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + doc.onkeydown = null; + $('td.mid table', doc).remove(); + $('td.mid', doc).css('background-color', '#f4f4f4'); + $('td.mid', doc).append($("")); + $('td.mid', doc).append($("
")); + $('td.mid', doc).append($("")); + $(".navAMR").css("text-align", "center"); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = 'http://kawaii.ca/reader/' + $('img.picture', div).attr('src'); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + $("body", doc).css('background-color', '#f5f5f5'); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Kawaii Scans", KawaiiScans); diff --git a/LICENSE b/LICENSE index ddbc2a0..c29cb6b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,15 +1,11 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/} Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble - The GNU General Public License is a free, copyleft license for software and other kinds of works. - The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to @@ -18,35 +14,29 @@ software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. - When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. - For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. - For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. - Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of @@ -57,49 +47,37 @@ have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. - Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. - The precise terms and conditions for copying, distribution and modification follow. - TERMS AND CONDITIONS - 0. Definitions. - "This License" refers to version 3 of the GNU General Public License. - "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. - "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. - To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. - A "covered work" means either the unmodified Program or a work based on the Program. - To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. - To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. - An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) @@ -108,18 +86,14 @@ extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. - 1. Source Code. - The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. - A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. - The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major @@ -130,7 +104,6 @@ implementation is available to the public in source code form. A (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. - The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to @@ -143,16 +116,12 @@ the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. - The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. - The Corresponding Source for a work in source code form is that same work. - 2. Basic Permissions. - All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited @@ -160,7 +129,6 @@ permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. - You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose @@ -171,19 +139,15 @@ not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. - Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. - When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to @@ -191,9 +155,7 @@ the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. - 4. Conveying Verbatim Copies. - You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; @@ -201,24 +163,18 @@ keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. - You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. - 5. Conveying Modified Source Versions. - You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: - a) The work must carry prominent notices stating that you modified it, and giving a relevant date. - b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". - c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 @@ -226,12 +182,10 @@ terms of section 4, provided that you also meet all of these conditions: regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. - d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. - A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, @@ -241,19 +195,15 @@ used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. - 6. Conveying Non-Source Forms. - You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: - a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. - b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as @@ -265,13 +215,11 @@ in one of these ways: more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. - c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. - d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no @@ -284,16 +232,13 @@ in one of these ways: Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. - e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. - A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. - A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation @@ -306,7 +251,6 @@ actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. - "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from @@ -314,7 +258,6 @@ a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. - If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the @@ -325,7 +268,6 @@ by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). - The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for @@ -333,15 +275,12 @@ the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. - Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. - 7. Additional Terms. - "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall @@ -350,41 +289,32 @@ that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. - When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. - Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: - a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or - b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or - c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or - d) Limiting the use for publicity purposes of names of licensors or authors of the material; or - e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or - f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. - All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is @@ -394,46 +324,37 @@ a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. - If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. - Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. - 8. Termination. - You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). - However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. - Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. - Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. - 9. Acceptance Not Required for Having Copies. - You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission @@ -442,14 +363,11 @@ nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. - 10. Automatic Licensing of Downstream Recipients. - Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. - An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered @@ -459,7 +377,6 @@ licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. - You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of @@ -467,13 +384,10 @@ rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. - 11. Patents. - A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". - A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted @@ -483,19 +397,16 @@ consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. - Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. - In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. - If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a @@ -509,7 +420,6 @@ actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. - If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties @@ -517,7 +427,6 @@ receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. - A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are @@ -532,13 +441,10 @@ conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. - Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. - 12. No Surrender of Others' Freedom. - If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a @@ -548,9 +454,7 @@ not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Use with the GNU Affero General Public License. - Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single @@ -559,14 +463,11 @@ License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. - 14. Revised Versions of this License. - The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the @@ -575,19 +476,15 @@ version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. - If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. - Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. - 15. Disclaimer of Warranty. - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY @@ -596,9 +493,7 @@ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - 16. Limitation of Liability. - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY @@ -608,67 +503,51 @@ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - 17. Interpretation of Sections 15 and 16. - If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. - END OF TERMS AND CONDITIONS - How to Apply These Terms to Your New Programs - If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - {one line to give the program's name and a brief idea of what it does.} Copyright (C) {year} {name of author} - This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program. If not, see {http://www.gnu.org/licenses/}. - Also add information on how to contact you by electronic and paper mail. - If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - mirrors Copyright (C) 2013 AllMangasReader-dev This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. - The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". - You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see {http://www.gnu.org/licenses/}. - The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -{http://www.gnu.org/philosophy/why-not-lgpl.html}. +{http://www.gnu.org/philosophy/why-not-lgpl.html}. \ No newline at end of file diff --git a/MCReborn.js b/MCReborn.js index e79e3b7..f526b12 100644 --- a/MCReborn.js +++ b/MCReborn.js @@ -1,229 +1,199 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) Enter here your copyright mention... // -// // -///////////////////////////////////////////////////////////////////////////// -*/ - -//This class is an example of manga site following implementation for All Manga Reader. -//To test this class, just modify the json variable in mgEntry.js. -//If your implementation works and has been fully tested, send it to me with an -//icon (png with transparency file, 16x16) for your mirror -//at pl dot duhoux (at) gmail dot com. I will add it in the extension. -//If you have problems implementing your mirror, send me a mail... i will be glad to help you... - -//CHANGE here the classname -var MCReborn = { - //CHANGE : Name of the mirror - mirrorName : "MC Reborn", - //CHANGE : True if the mirror can list all of its mangas. - canListFullMangas : false, - //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) - mirrorIcon : "img/mcreborn.png", - languages: "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("mcreborn.com/reader/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - //CHANGE URL HERE - url: "http://mcreborn.com/reader/reader/search/", - type: 'POST', - data: - { - 'search': search - }, - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback("MC Reborn", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - //CHANGE URL HERE - url: urlManga, - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $('.list > .element > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback(res, obj); - } - }); - }, - - /******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). - ********************************************************************************************************/ - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - var res = []; - eval($('body', doc).html().match(/var pages = .*\n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - return $('#page', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) - //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return (curUrl.search('mcreborn.com/reader/reader/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans : function(doc, curUrl) { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - $('#page').css("max-width", (screen.width - 150) + 'px'); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR").css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES - $("body > div:empty", doc).remove(); - - //DO ANYTHING ELSE YOU NEED - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) Enter here your copyright mention... // +// // +///////////////////////////////////////////////////////////////////////////// +*/ +//This class is an example of manga site following implementation for All Manga Reader. +//To test this class, just modify the json variable in mgEntry.js. +//If your implementation works and has been fully tested, send it to me with an +//icon (png with transparency file, 16x16) for your mirror +//at pl dot duhoux (at) gmail dot com. I will add it in the extension. +//If you have problems implementing your mirror, send me a mail... i will be glad to help you... +//CHANGE here the classname +var MCReborn = { + //CHANGE : Name of the mirror + mirrorName : "MC Reborn", + //CHANGE : True if the mirror can list all of its mangas. + canListFullMangas : false, + //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) + mirrorIcon : "img/mcreborn.png", + languages: "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("mcreborn.com/reader/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + //CHANGE URL HERE + url: "http://mcreborn.com/reader/reader/search/", + type: 'POST', + data: + { + 'search': search + }, + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("MC Reborn", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + //CHANGE URL HERE + url: urlManga, + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + /******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). + ********************************************************************************************************/ + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + var res = []; + eval($('body', doc).html().match(/var pages = .*\n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + return $('#page', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) + //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return (curUrl.search('mcreborn.com/reader/reader/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans : function(doc, curUrl) { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + $('#page').css("max-width", (screen.width - 150) + 'px'); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR").css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES + $("body > div:empty", doc).remove(); + //DO ANYTHING ELSE YOU NEED + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MC Reborn", MCReborn); diff --git a/Manga24.js b/Manga24.js index b66fb7e..79d6528 100644 --- a/Manga24.js +++ b/Manga24.js @@ -1,278 +1,248 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var Manga24 = { - //Name of the mirror - mirrorName : "Manga24", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/Manga24.png", - //Languages of scans for the mirror - languages : "ru", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("manga24.ru/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://manga24.ru/all/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("select#manga_list > option", div).each(function(index) { - if (index > 0) { - res[res.length] = [$(this).text(), "http://manga24.ru" + $(this).val()]; - } - }); - callback("Manga24", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - if ($("#main .chapters li", div).size() > 0) { - $("#main .chapters li", div).each( - function(index){ - res[res.length] = [$($("em", $(this)).contents()[0]).text(), "http://manga24.ru" + $("a", $(this)).attr("href")]; - } - ); - } else { - res[res.length] = [$("#up h1", div).text(), urlManga +"read/"]; - } - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var mangaURL = ""; - $("script", doc).each(function(index) { - if ($(this).text().indexOf("Reader.init(") != -1) { - var pos = $(this).text().indexOf("mangaUrl: \"\\") + 12; - var fin = $(this).text().indexOf("\\/\"", pos); - mangaURL = "http://manga24.ru" + $(this).text().substring(pos, fin) + "/"; - } - }); - - var name = $("title", doc).text();//$( $("option:selected", $("select[name='series']", doc)[0] ) ).text(); - var pos = name.indexOf("-"); - if (pos != -1) { - name = name.substring(0, pos).trim(); - } - var nameurl = mangaURL; - - var curChapName = ""; - var chapurl = ""; - if ($("#chapters select", doc).size() > 0) { - curChapName = $("#chapters select option:selected", doc).text(); - chapurl = mangaURL + $("#chapters select option:selected", doc).val() + "/"; - } else { - curChapName = name; - chapurl = mangaURL + "read/"; - } - - callback({"name": name, - "currentChapter": curChapName, - "currentMangaURL": nameurl, - "currentChapterURL": chapurl}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl2) { - //This function runs in the DOM of the current consulted page. - var res = []; - var dir = ""; - var scansstr = ""; - $("script", doc).each(function(index) { - if ($(this).text().indexOf("Reader.init(") != -1) { - var posdir = $(this).text().indexOf("dir: \"") + 6; - var findir = $(this).text().indexOf("\"", posdir); - dir = $(this).text().substring(posdir, findir).replace(/\\\//g, "/"); - var possc = $(this).text().indexOf("images: [[") + 8; - var finsc = $(this).text().indexOf("]]", possc) + 2; - scansstr = $(this).text().substring(possc, finsc).replace(/\\\//g, "/"); - var pos = scansstr.indexOf("\""); - while (pos != -1) { - var end = scansstr.indexOf("\"", pos + 1); - res[res.length] = dir + scansstr.substring(pos + 1, end); - pos = scansstr.indexOf("\"", end + 1); - } - } - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //$("iframe", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - //return $("select[name='series']").parent().parent(); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - var isChap = false; - - $("script", doc).each(function(index) { - if ($(this).text().indexOf("Reader.init(") != -1) { - isChap = true; - } - }); - - return isChap; - }, - - //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. - $("#sidebar", doc).remove(); - $("#content", doc).empty(); - $("#content", doc).css("width", "100%"); - $("").appendTo($("#content", doc)); - $("
").appendTo($("#content", doc)); - $("").appendTo($("#content", doc)); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $( image ).attr( "src", urlImg ) - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var mangaURL = ""; - $("script", doc).each(function(index) { - if ($(this).text().indexOf("Reader.init(") != -1) { - var pos = $(this).text().indexOf("mangaUrl: \"\\") + 12; - var fin = $(this).text().indexOf("\\/\"", pos); - mangaURL = "http://manga24.ru" + $(this).text().substring(pos, fin) + "/"; - } - }); - var name = $("title", doc).text();//$( $("option:selected", $("select[name='series']", doc)[0] ) ).text(); - var pos = name.indexOf("-"); - if (pos != -1) { - name = name.substring(0, pos).trim(); - } - var select = null; - if ($("#chapters select", doc).size() > 0) { - $("#chapters select option", doc).each(function(index) { - $(this).val(mangaURL + $(this).val() + "/"); - }); - select = $("#chapters select", doc); - } else { - select = $(""); - } - - return select; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //$("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var Manga24 = { + //Name of the mirror + mirrorName : "Manga24", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/Manga24.png", + //Languages of scans for the mirror + languages : "ru", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("manga24.ru/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://manga24.ru/all/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("select#manga_list > option", div).each(function(index) { + if (index > 0) { + res[res.length] = [$(this).text(), "http://manga24.ru" + $(this).val()]; + } + }); + callback("Manga24", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + if ($("#main .chapters li", div).size() > 0) { + $("#main .chapters li", div).each( + function(index){ + res[res.length] = [$($("em", $(this)).contents()[0]).text(), "http://manga24.ru" + $("a", $(this)).attr("href")]; + } + ); + } else { + res[res.length] = [$("#up h1", div).text(), urlManga +"read/"]; + } + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var mangaURL = ""; + $("script", doc).each(function(index) { + if ($(this).text().indexOf("Reader.init(") != -1) { + var pos = $(this).text().indexOf("mangaUrl: \"\\") + 12; + var fin = $(this).text().indexOf("\\/\"", pos); + mangaURL = "http://manga24.ru" + $(this).text().substring(pos, fin) + "/"; + } + }); + var name = $("title", doc).text();//$( $("option:selected", $("select[name='series']", doc)[0] ) ).text(); + var pos = name.indexOf("-"); + if (pos != -1) { + name = name.substring(0, pos).trim(); + } + var nameurl = mangaURL; + var curChapName = ""; + var chapurl = ""; + if ($("#chapters select", doc).size() > 0) { + curChapName = $("#chapters select option:selected", doc).text(); + chapurl = mangaURL + $("#chapters select option:selected", doc).val() + "/"; + } else { + curChapName = name; + chapurl = mangaURL + "read/"; + } + callback({"name": name, + "currentChapter": curChapName, + "currentMangaURL": nameurl, + "currentChapterURL": chapurl}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl2) { + //This function runs in the DOM of the current consulted page. + var res = []; + var dir = ""; + var scansstr = ""; + $("script", doc).each(function(index) { + if ($(this).text().indexOf("Reader.init(") != -1) { + var posdir = $(this).text().indexOf("dir: \"") + 6; + var findir = $(this).text().indexOf("\"", posdir); + dir = $(this).text().substring(posdir, findir).replace(/\\\//g, "/"); + var possc = $(this).text().indexOf("images: [[") + 8; + var finsc = $(this).text().indexOf("]]", possc) + 2; + scansstr = $(this).text().substring(possc, finsc).replace(/\\\//g, "/"); + var pos = scansstr.indexOf("\""); + while (pos != -1) { + var end = scansstr.indexOf("\"", pos + 1); + res[res.length] = dir + scansstr.substring(pos + 1, end); + pos = scansstr.indexOf("\"", end + 1); + } + } + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //$("iframe", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + //return $("select[name='series']").parent().parent(); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + var isChap = false; + $("script", doc).each(function(index) { + if ($(this).text().indexOf("Reader.init(") != -1) { + isChap = true; + } + }); + return isChap; + }, + //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. + $("#sidebar", doc).remove(); + $("#content", doc).empty(); + $("#content", doc).css("width", "100%"); + $("").appendTo($("#content", doc)); + $("
").appendTo($("#content", doc)); + $("").appendTo($("#content", doc)); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $( image ).attr( "src", urlImg ) + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var mangaURL = ""; + $("script", doc).each(function(index) { + if ($(this).text().indexOf("Reader.init(") != -1) { + var pos = $(this).text().indexOf("mangaUrl: \"\\") + 12; + var fin = $(this).text().indexOf("\\/\"", pos); + mangaURL = "http://manga24.ru" + $(this).text().substring(pos, fin) + "/"; + } + }); + var name = $("title", doc).text();//$( $("option:selected", $("select[name='series']", doc)[0] ) ).text(); + var pos = name.indexOf("-"); + if (pos != -1) { + name = name.substring(0, pos).trim(); + } + var select = null; + if ($("#chapters select", doc).size() > 0) { + $("#chapters select option", doc).each(function(index) { + $(this).val(mangaURL + $(this).val() + "/"); + }); + select = $("#chapters select", doc); + } else { + select = $(""); + } + return select; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //$("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga24", Manga24); diff --git a/Manga2u.js b/Manga2u.js index d0cafdf..a86ed66 100644 --- a/Manga2u.js +++ b/Manga2u.js @@ -1,163 +1,162 @@ -var Manga2u = { - mirrorName : "Manga2u", - canListFullMangas : false, - mirrorIcon : "img/manga2u.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("manga2u.me/") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://www.manga2u.me/list/search/", - type : 'POST', - data : { - "cmd_wpm_search" : "Search", - "txt_wpm_wgt_mng_sch_nme" : search, - "cmd_wpm_wgt_mng_sch_sbm" : 1, - "cmd_wpm_wgt_mng_sch_sbm_img.x" : 0, - "cmd_wpm_wgt_mng_sch_sbm_img.y" : 0 - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $(".wpm_pag.mng_lst .det a:first-child", div).each(function (index) { - if ($(this).text().trim() != "") { - res[res.length] = [$(this).text(), $(this).attr("href")]; - } - }); - res.sort(function (a, b) { - return ((a[0].toLowerCase() < b[0].toLowerCase()) ? -1 : ((a[0] == b[0]) ? 0 : 1)); - }); - callback("Manga2u", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $("ul.lst a.lst", div).each(function (index) { - if ($(this).text().trim() != "") { - res[res.length] = [$("b.val", $(this)).text(), $(this).attr("href")]; - } - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - name = $("h1.ttl a:first", doc).text().trim(); - if (name.substring(name.length - 5, name.length) == "Manga") { - name = name.substr(0, name.length - 5).trim(); - } - var url = curUrl; - var pos = 0; - for (var i = 0; i < 4; i++) { - pos = url.indexOf("/", pos + 1); - } - currentMangaURL = url.substr(0, pos + 1); - currentChapter = $("h1.ttl", doc).contents().last().text().trim(); - if (currentChapter.substr(0, 1) == "-") { - currentChapter = currentChapter.substr(1).trim(); - } - currentChapterURL = $("link[rel='canonical']", doc).attr("href"); - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - var nba = $("h2.wpm_tip.lnk_cnr a", doc).size(); - $("h2.wpm_tip.lnk_cnr a", doc).each(function (index) { - if (index != nba - 1) { - res[res.length] = $(this).attr("href"); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) {}, - whereDoIWriteScans : function (doc, curUrl) { - return $(".wpm_nav:first", doc).next(); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".wpm_nav", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return ($("img.manga-page", doc).size() > 0 || $("#chapter-link a").text().toLowerCase().indexOf("begin reading") != -1 || $("h1:first").text().indexOf("Index of") != -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $(".wpm_nav:first", doc).next().empty(); - $(".wpm_nav:first", doc).next().next().remove(); - $(".wpm_nav", doc).empty(); - $(".wpm_nav", doc).css("text-align", "center"); - $(".wpm_nav", doc).css("padding", "5px"); - $(".wpm_nav", doc).css("height", "auto"); - $("#sct_col_l").css("width", "auto"); - $("#sct_col_l").css("float", "none"); - $(".wrap").css("width", "auto"); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("img.manga-page", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - var url = curUrl; - var pos = 0; - for (var i = 0; i < 4; i++) { - pos = url.indexOf("/", pos + 1); - } - var currentMangaURL = url.substr(0, pos + 1); - $(".cbo_wpm_chp:first option", doc).each(function (index) { - $(this).val(currentMangaURL + $(this).val() + "/01/"); - }); - return $(".cbo_wpm_chp:first", doc); - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - }, +var Manga2u = { + mirrorName : "Manga2u", + canListFullMangas : false, + mirrorIcon : "img/manga2u.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("manga2u.me/") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://www.manga2u.me/list/search/", + type : 'POST', + data : { + "cmd_wpm_search" : "Search", + "txt_wpm_wgt_mng_sch_nme" : search, + "cmd_wpm_wgt_mng_sch_sbm" : 1, + "cmd_wpm_wgt_mng_sch_sbm_img.x" : 0, + "cmd_wpm_wgt_mng_sch_sbm_img.y" : 0 + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $(".wpm_pag.mng_lst .det a:first-child", div).each(function (index) { + if ($(this).text().trim() != "") { + res[res.length] = [$(this).text(), $(this).attr("href")]; + } + }); + res.sort(function (a, b) { + return ((a[0].toLowerCase() < b[0].toLowerCase()) ? -1 : ((a[0] == b[0]) ? 0 : 1)); + }); + callback("Manga2u", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("ul.lst a.lst", div).each(function (index) { + if ($(this).text().trim() != "") { + res[res.length] = [$("b.val", $(this)).text(), $(this).attr("href")]; + } + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("h1.ttl a:first", doc).text().trim(); + if (name.substring(name.length - 5, name.length) == "Manga") { + name = name.substr(0, name.length - 5).trim(); + } + var url = curUrl; + var pos = 0; + for (var i = 0; i < 4; i++) { + pos = url.indexOf("/", pos + 1); + } + currentMangaURL = url.substr(0, pos + 1); + currentChapter = $("h1.ttl", doc).contents().last().text().trim(); + if (currentChapter.substr(0, 1) == "-") { + currentChapter = currentChapter.substr(1).trim(); + } + currentChapterURL = $("link[rel='canonical']", doc).attr("href"); + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + var nba = $("h2.wpm_tip.lnk_cnr a", doc).size(); + $("h2.wpm_tip.lnk_cnr a", doc).each(function (index) { + if (index != nba - 1) { + res[res.length] = $(this).attr("href"); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) {}, + whereDoIWriteScans : function (doc, curUrl) { + return $(".wpm_nav:first", doc).next(); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".wpm_nav", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return ($("img.manga-page", doc).size() > 0 || $("#chapter-link a").text().toLowerCase().indexOf("begin reading") != -1 || $("h1:first").text().indexOf("Index of") != -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $(".wpm_nav:first", doc).next().empty(); + $(".wpm_nav:first", doc).next().next().remove(); + $(".wpm_nav", doc).empty(); + $(".wpm_nav", doc).css("text-align", "center"); + $(".wpm_nav", doc).css("padding", "5px"); + $(".wpm_nav", doc).css("height", "auto"); + $("#sct_col_l").css("width", "auto"); + $("#sct_col_l").css("float", "none"); + $(".wrap").css("width", "auto"); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("img.manga-page", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + var url = curUrl; + var pos = 0; + for (var i = 0; i < 4; i++) { + pos = url.indexOf("/", pos + 1); + } + var currentMangaURL = url.substr(0, pos + 1); + $(".cbo_wpm_chp:first option", doc).each(function (index) { + $(this).val(currentMangaURL + $(this).val() + "/01/"); + }); + return $(".cbo_wpm_chp:first", doc); + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga2u", Manga2u); diff --git a/MangaAccess.js b/MangaAccess.js index 7aa4464..00aceb9 100644 --- a/MangaAccess.js +++ b/MangaAccess.js @@ -1,226 +1,197 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaAccess = { - //Name of the mirror - mirrorName : "MangaAccess", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangaaccess.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("manga-access.com") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://manga-access.com/manga/list", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#inner_page div > a", div).each(function(index) { - res[res.length] = [$(this).text(), "http://manga-access.com" + $(this).attr("href")]; - }); - callback("MangaAccess", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga + "?mature_confirm=1", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("#inner_page a.download-link", div).each( - function(index){ - res[res.length] = [$("strong", $(this)).text(), "http://manga-access.com" + $(this).attr("href")]; - } - ); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $( "#bc a:nth-child(4)", doc ).text(); - var curChapName = $( "#bc a:nth-child(5)", doc ).text(); - var nameurl = "http://manga-access.com" + $( "#bc a:nth-child(4)", doc ).attr("href"); - var chapurl = "http://manga-access.com" + $( "#bc a:nth-child(5)", doc ).attr("href"); - callback({"name": name, - "currentChapter": curChapName, - "currentMangaURL": nameurl, - "currentChapterURL": chapurl}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl2) { - //This function runs in the DOM of the current consulted page. - var res = []; - - $("#page_switch option", doc).each( - function(index){ - res[index] = "http://manga-access.com" + $(this).val(); - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#pic", doc).prev().remove(); - $("#pic", doc).next().next().remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#pic", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#bc", doc).add($(".navAMR", doc)); - //return $("select[name='series']").parent().parent(); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#pic img", doc).size() > 0); - }, - - //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. - $("#reader-container", doc).css("width", "100%"); - $("#inner_page", doc).css("background-color", "black"); - $("#inner_page > table", doc).remove(); - $("#bc", doc).empty(); - $("#pic", doc).empty(); - $("#pic", doc).next().after($("")); - $(".navAMR", doc).css("text-align", "center"); - $("#bc", doc).css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = $("#pic img", div).attr("src"); - - $( image ).attr( "src", src ); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#chapter_switch option", doc).each(function(index) { - $(this).val("http://manga-access.com" + $(this).val()); - }); - return $("#chapter_switch", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaAccess = { + //Name of the mirror + mirrorName : "MangaAccess", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangaaccess.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("manga-access.com") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://manga-access.com/manga/list", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#inner_page div > a", div).each(function(index) { + res[res.length] = [$(this).text(), "http://manga-access.com" + $(this).attr("href")]; + }); + callback("MangaAccess", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga + "?mature_confirm=1", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#inner_page a.download-link", div).each( + function(index){ + res[res.length] = [$("strong", $(this)).text(), "http://manga-access.com" + $(this).attr("href")]; + } + ); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $( "#bc a:nth-child(4)", doc ).text(); + var curChapName = $( "#bc a:nth-child(5)", doc ).text(); + var nameurl = "http://manga-access.com" + $( "#bc a:nth-child(4)", doc ).attr("href"); + var chapurl = "http://manga-access.com" + $( "#bc a:nth-child(5)", doc ).attr("href"); + callback({"name": name, + "currentChapter": curChapName, + "currentMangaURL": nameurl, + "currentChapterURL": chapurl}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl2) { + //This function runs in the DOM of the current consulted page. + var res = []; + $("#page_switch option", doc).each( + function(index){ + res[index] = "http://manga-access.com" + $(this).val(); + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#pic", doc).prev().remove(); + $("#pic", doc).next().next().remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#pic", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#bc", doc).add($(".navAMR", doc)); + //return $("select[name='series']").parent().parent(); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#pic img", doc).size() > 0); + }, + //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. + $("#reader-container", doc).css("width", "100%"); + $("#inner_page", doc).css("background-color", "black"); + $("#inner_page > table", doc).remove(); + $("#bc", doc).empty(); + $("#pic", doc).empty(); + $("#pic", doc).next().after($("")); + $(".navAMR", doc).css("text-align", "center"); + $("#bc", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = $("#pic img", div).attr("src"); + $( image ).attr( "src", src ); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#chapter_switch option", doc).each(function(index) { + $(this).val("http://manga-access.com" + $(this).val()); + }); + return $("#chapter_switch", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaAccess", MangaAccess); diff --git a/MangaAr.js b/MangaAr.js index 8ad2a1d..94b20f7 100644 --- a/MangaAr.js +++ b/MangaAr.js @@ -1,140 +1,139 @@ -var MangaAr = { - mirrorName : "Manga Ar", - canListFullMangas : false, - mirrorIcon : "img/mangaar.png", - languages : "ar", - isMe : function (url) { - return (url.indexOf("manga-ar.com/") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://manga-ar.com/directory.php?action=search&SeriesName=" + search, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $("td.list > a", div).each(function (index) { - res[res.length] = [$(this).text(), $(this).attr("href")]; - }); - $("td.color > a", div).each(function (index) { - res[res.length] = [$(this).text(), $(this).attr("href")]; - }); - callback("Manga Ar", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $("#newspaper-b3 tbody tr td:nth-child(6) > a", div).each(function (index) { - res[res.length] = [$(this).text(), $(this).attr("href")]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - name = $(".indexer a:nth-child(2)", doc).text(); - var SeriesID = $("#SeriesID", doc).val(); - var ChapterID = $("#ChapterID", doc).val(); - currentMangaURL = "http://manga-ar.com/" + SeriesID + "/"; - currentChapter = $("#ChapterID:first option:selected", doc).text(); - currentChapterURL = "http://manga-ar.com/" + SeriesID + "/" + ChapterID + "/1"; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - var SeriesID = $("#SeriesID", doc).val(); - var ChapterID = $("#ChapterID", doc).val(); - $("#PageID:first option", doc).each(function (index) { - res[res.length] = "http://manga-ar.com/" + SeriesID + "/" + ChapterID + "/" + $(this).val(); - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $("#aswift_0_anchor", doc).remove(); - $("#aswift_1_anchor", doc).remove(); - $("#aswift_2_anchor", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $("#PagePhoto", doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $("#newspaper-b4", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return ($("img.manga-pic2", doc).size() > 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $("#newspaper-b4", doc).empty(); - $("#newspaper-b4:last", doc).remove(); - $("#newspaper-b4:last", doc).remove(); - $("#newspaper-b4", doc).css("text-align", "center"); - $("#PagePhoto", doc).empty(); - $("#content2", doc).css("width", "auto"); - $(".gallery", doc).css("background", "black"); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("img.manga-pic2", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - var res = []; - var currentMangaURL = "http://manga-ar.com/" + $("select[name='manga']:first option:selected", doc).val(); - var SeriesID = $("#SeriesID", doc).val(); - $("#ChapterID option", doc).each(function (index) { - $(this).val("http://manga-ar.com/" + SeriesID + "/" + $(this).val() + "/1"); - }); - return $("#ChapterID:first", doc); - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var MangaAr = { + mirrorName : "Manga Ar", + canListFullMangas : false, + mirrorIcon : "img/mangaar.png", + languages : "ar", + isMe : function (url) { + return (url.indexOf("manga-ar.com/") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://manga-ar.com/directory.php?action=search&SeriesName=" + search, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("td.list > a", div).each(function (index) { + res[res.length] = [$(this).text(), $(this).attr("href")]; + }); + $("td.color > a", div).each(function (index) { + res[res.length] = [$(this).text(), $(this).attr("href")]; + }); + callback("Manga Ar", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("#newspaper-b3 tbody tr td:nth-child(6) > a", div).each(function (index) { + res[res.length] = [$(this).text(), $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $(".indexer a:nth-child(2)", doc).text(); + var SeriesID = $("#SeriesID", doc).val(); + var ChapterID = $("#ChapterID", doc).val(); + currentMangaURL = "http://manga-ar.com/" + SeriesID + "/"; + currentChapter = $("#ChapterID:first option:selected", doc).text(); + currentChapterURL = "http://manga-ar.com/" + SeriesID + "/" + ChapterID + "/1"; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + var SeriesID = $("#SeriesID", doc).val(); + var ChapterID = $("#ChapterID", doc).val(); + $("#PageID:first option", doc).each(function (index) { + res[res.length] = "http://manga-ar.com/" + SeriesID + "/" + ChapterID + "/" + $(this).val(); + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $("#aswift_0_anchor", doc).remove(); + $("#aswift_1_anchor", doc).remove(); + $("#aswift_2_anchor", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $("#PagePhoto", doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $("#newspaper-b4", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return ($("img.manga-pic2", doc).size() > 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $("#newspaper-b4", doc).empty(); + $("#newspaper-b4:last", doc).remove(); + $("#newspaper-b4:last", doc).remove(); + $("#newspaper-b4", doc).css("text-align", "center"); + $("#PagePhoto", doc).empty(); + $("#content2", doc).css("width", "auto"); + $(".gallery", doc).css("background", "black"); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("img.manga-pic2", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + var res = []; + var currentMangaURL = "http://manga-ar.com/" + $("select[name='manga']:first option:selected", doc).val(); + var SeriesID = $("#SeriesID", doc).val(); + $("#ChapterID option", doc).each(function (index) { + $(this).val("http://manga-ar.com/" + SeriesID + "/" + $(this).val() + "/1"); + }); + return $("#ChapterID:first", doc); + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Ar", MangaAr); diff --git a/MangaChapter.js b/MangaChapter.js index 419b005..2230827 100644 --- a/MangaChapter.js +++ b/MangaChapter.js @@ -1,208 +1,207 @@ -var MangaChapter = -{ - mirrorName: "MangaChapter", - canListFullMangas: false, - mirrorIcon: "img/mangachapter.png", - languages: "en", - isMe: function(url) - { - return (url.indexOf("mangachapter.net") != -1); - }, - getMangaList: function(search, callback) - { - var urlSearch = "http://www.mangachapter.net/search.html?w=" + search; - var res = []; - var getMangaListRecursive = function(url, callback) - { - $.ajax( - { - url: url, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(response) - { - var div = document.createElement('div'); - div.innerHTML = response.replace('
").appendTo(viewer); - $("
").appendTo(viewer); - $("").appendTo(viewer); - $(".navAMR", doc).css({ 'text-align':'center', 'background-color':'#fff', 'margin-bottom':'15px' }); - }, - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $.ajax( - { - url: urlImg, - success: function(objResponse) - { - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var src = $("#mangaImg, #Img1", div).attr("src") || ""; - $( image ).attr( "src", src); - } - }); - }, - isImageInOneCol: function(img, doc, curUrl) - { - return false; - }, - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - $(".imageAMR", doc).css('margin-top', '10px'); - $("body, table", doc).css( - { - 'background-color':'#000', - 'border-bottom-color':'#000', - 'border-left-color':'#000', - 'border-right-color':'#000', - 'border-top-color':'#000' - }); - if (doc.createElement) - { - var script = doc.createElement('script'); - script.innerText = "document.onkeydown = undefined;"; - doc.body.appendChild(script); - } - } +var MangaChapter = +{ + mirrorName: "MangaChapter", + canListFullMangas: false, + mirrorIcon: "img/mangachapter.png", + languages: "en", + isMe: function(url) + { + return (url.indexOf("mangachapter.net") != -1); + }, + getMangaList: function(search, callback) + { + var urlSearch = "http://www.mangachapter.net/search.html?w=" + search; + var res = []; + var getMangaListRecursive = function(url, callback) + { + $.ajax( + { + url: url, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(response) + { + var div = document.createElement('div'); + div.innerHTML = response.replace('
").appendTo(viewer); + $("
").appendTo(viewer); + $("").appendTo(viewer); + $(".navAMR", doc).css({ 'text-align':'center', 'background-color':'#fff', 'margin-bottom':'15px' }); + }, + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $.ajax( + { + url: urlImg, + success: function(objResponse) + { + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = $("#mangaImg, #Img1", div).attr("src") || ""; + $( image ).attr( "src", src); + } + }); + }, + isImageInOneCol: function(img, doc, curUrl) + { + return false; + }, + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + $(".imageAMR", doc).css('margin-top', '10px'); + $("body, table", doc).css( + { + 'background-color':'#000', + 'border-bottom-color':'#000', + 'border-left-color':'#000', + 'border-right-color':'#000', + 'border-top-color':'#000' + }); + if (doc.createElement) + { + var script = doc.createElement('script'); + script.innerText = "document.onkeydown = undefined;"; + doc.body.appendChild(script); + } + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaChapter", MangaChapter); diff --git a/MangaEden_en.js b/MangaEden_en.js index f1203fe..69fc0c9 100644 --- a/MangaEden_en.js +++ b/MangaEden_en.js @@ -1,254 +1,223 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaEden_en = { - //Name of the mirror - mirrorName : "Manga Eden (EN)", - //True if the mirror can list all of its mangas. - canListFullMangas : false, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangaeden.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("www.mangaeden.com/en-manga/") != -1); - }, - - getMangaListPage: function(response, res) - { - var div = document.createElement("div"); - div.innerHTML = response; - $('#mangaList tr td:first-child a', div).each(function(index) { - res.push([$(this).text(), "http://www.mangaeden.com" + $(this).attr("href")]); - }); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.mangaeden.com/en-directory/?title=" + search, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - res = []; - MangaEden_en.getMangaListPage(objResponse, res); - var div = document.createElement("div"); - div.innerHTML = objResponse; - if (!isNaN(n = parseInt($('.pagination_bottom a:not(:has(span)):last', div).text()))) - { - for (i = 2; i <= n; i++) - { - $.ajax( - { - url: "http://www.mangaeden.com/en-directory/?title=" + search + "&page=" + i, - async: false, - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - MangaEden_en.getMangaListPage(objResponse, res); - } - }); - } - } - callback("Manga Eden (EN)", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $('.chapterLink', div).each(function(index) { - res[res.length] = [parseFloat($("b", $(this)).text()), "http://www.mangaeden.com" + $(this).attr("href")]; - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $('#top a:last', doc).text(); - var currentChapter = $('#combobox option:selected', doc).text(); - var currentMangaURL = "http://www.mangaeden.com" + $('#top a:last', doc).attr('href'); - var currentChapterURL = currentMangaURL + currentChapter + "/1/"; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - res.push(curUrl); - $('.pagination a:not(:contains("Prev")):not(:contains("Next")):not(.selected)', doc).each(function(index) - { - res.push($(this).attr('href')); - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#adsTop", doc).remove(); - $("#adsRight", doc).remove(); - $("#bottomAds", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - if (curUrl.indexOf("www.mangaeden.com/en-manga/") != -1) - { - return (curUrl.substring(curUrl.indexOf("www.mangaeden.com/en-manga/") + 27).split(/\//g).length - 1) > 1 - } - }, - - //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. - - $('.pagination').remove(); - $("#content", doc).empty(); - $("").appendTo($("#content", doc)); - $("
").appendTo($("#content", doc)); - $("").appendTo($("#content", doc)); - $(".navAMR", doc).css("text-align", "center"); - script = doc.createElement('script'); - script.innerText = "document.onkeydown = null;\n"; - doc.body.appendChild(script); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - if (urlImg.indexOf("http://") == -1) - { - urlImg = "http://www.mangaeden.com" + urlImg; - } - $.ajax( - { - url: urlImg, - success: function(objResponse) - { - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - $(image).attr('src', $('#mainImgC img', div).attr('src')); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaEden_en = { + //Name of the mirror + mirrorName : "Manga Eden (EN)", + //True if the mirror can list all of its mangas. + canListFullMangas : false, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangaeden.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("www.mangaeden.com/en-manga/") != -1); + }, + getMangaListPage: function(response, res) + { + var div = document.createElement("div"); + div.innerHTML = response; + $('#mangaList tr td:first-child a', div).each(function(index) { + res.push([$(this).text(), "http://www.mangaeden.com" + $(this).attr("href")]); + }); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.mangaeden.com/en-directory/?title=" + search, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + res = []; + MangaEden_en.getMangaListPage(objResponse, res); + var div = document.createElement("div"); + div.innerHTML = objResponse; + if (!isNaN(n = parseInt($('.pagination_bottom a:not(:has(span)):last', div).text()))) + { + for (i = 2; i <= n; i++) + { + $.ajax( + { + url: "http://www.mangaeden.com/en-directory/?title=" + search + "&page=" + i, + async: false, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + MangaEden_en.getMangaListPage(objResponse, res); + } + }); + } + } + callback("Manga Eden (EN)", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.chapterLink', div).each(function(index) { + res[res.length] = [parseFloat($("b", $(this)).text()), "http://www.mangaeden.com" + $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $('#top a:last', doc).text(); + var currentChapter = $('#combobox option:selected', doc).text(); + var currentMangaURL = "http://www.mangaeden.com" + $('#top a:last', doc).attr('href'); + var currentChapterURL = currentMangaURL + currentChapter + "/1/"; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + res.push(curUrl); + $('.pagination a:not(:contains("Prev")):not(:contains("Next")):not(.selected)', doc).each(function(index) + { + res.push($(this).attr('href')); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#adsTop", doc).remove(); + $("#adsRight", doc).remove(); + $("#bottomAds", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + if (curUrl.indexOf("www.mangaeden.com/en-manga/") != -1) + { + return (curUrl.substring(curUrl.indexOf("www.mangaeden.com/en-manga/") + 27).split(/\//g).length - 1) > 1 + } + }, + //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. + $('.pagination').remove(); + $("#content", doc).empty(); + $("").appendTo($("#content", doc)); + $("
").appendTo($("#content", doc)); + $("").appendTo($("#content", doc)); + $(".navAMR", doc).css("text-align", "center"); + script = doc.createElement('script'); + script.innerText = "document.onkeydown = null;\n"; + doc.body.appendChild(script); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + if (urlImg.indexOf("http://") == -1) + { + urlImg = "http://www.mangaeden.com" + urlImg; + } + $.ajax( + { + url: urlImg, + success: function(objResponse) + { + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + $(image).attr('src', $('#mainImgC img', div).attr('src')); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Eden (EN)", MangaEden_en); diff --git a/MangaEden_it.js b/MangaEden_it.js index dec4548..7193b43 100644 --- a/MangaEden_it.js +++ b/MangaEden_it.js @@ -1,254 +1,223 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaEden_it = { - //Name of the mirror - mirrorName : "Manga Eden (IT)", - //True if the mirror can list all of its mangas. - canListFullMangas : false, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangaeden.png", - //Languages of scans for the mirror - languages : "it", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("www.mangaeden.com/it-manga/") != -1); - }, - - getMangaListPage: function(response, res) - { - var div = document.createElement("div"); - div.innerHTML = response; - $('#mangaList tr td:first-child a', div).each(function(index) { - res.push([$(this).text(), "http://www.mangaeden.com" + $(this).attr("href")]); - }); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.mangaeden.com/it-directory/?title=" + search, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - res = []; - MangaEden_it.getMangaListPage(objResponse, res); - var div = document.createElement("div"); - div.innerHTML = objResponse; - if (!isNaN(n = parseInt($('.pagination_bottom a:not(:has(span)):last', div).text()))) - { - for (i = 2; i <= n; i++) - { - $.ajax( - { - url: "http://www.mangaeden.com/it-directory/?title=" + search + "&page=" + i, - async: false, - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - MangaEden_it.getMangaListPage(objResponse, res); - } - }); - } - } - callback("Manga Eden (IT)", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $('.chapterLink', div).each(function(index) { - res[res.length] = [parseFloat($("b", $(this)).text()), "http://www.mangaeden.com" + $(this).attr("href")]; - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $('#top a:last', doc).text(); - var currentChapter = $('#combobox option:selected', doc).text(); - var currentMangaURL = "http://www.mangaeden.com" + $('#top a:last', doc).attr('href'); - var currentChapterURL = currentMangaURL + currentChapter + "/1/"; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - res.push(curUrl); - $('.pagination a:not(:contains("Prev")):not(:contains("Next")):not(.selected)', doc).each(function(index) - { - res.push($(this).attr('href')); - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("#adsTop", doc).remove(); - $("#adsRight", doc).remove(); - $("#bottomAds", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - if (curUrl.indexOf("www.mangaeden.com/it-manga/") != -1) - { - return (curUrl.substring(curUrl.indexOf("www.mangaeden.com/it-manga/") + 27).split(/\//g).length - 1) > 1 - } - }, - - //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. - - $('.pagination').remove(); - $("#content", doc).empty(); - $("").appendTo($("#content", doc)); - $("
").appendTo($("#content", doc)); - $("").appendTo($("#content", doc)); - $(".navAMR", doc).css("text-align", "center"); - script = doc.createElement('script'); - script.innerText = "document.onkeydown = null;\n"; - doc.body.appendChild(script); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - if (urlImg.indexOf("http://") == -1) - { - urlImg = "http://www.mangaeden.com" + urlImg; - } - $.ajax( - { - url: urlImg, - success: function(objResponse) - { - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - $(image).attr('src', $('#mainImgC img', div).attr('src')); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaEden_it = { + //Name of the mirror + mirrorName : "Manga Eden (IT)", + //True if the mirror can list all of its mangas. + canListFullMangas : false, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangaeden.png", + //Languages of scans for the mirror + languages : "it", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("www.mangaeden.com/it-manga/") != -1); + }, + getMangaListPage: function(response, res) + { + var div = document.createElement("div"); + div.innerHTML = response; + $('#mangaList tr td:first-child a', div).each(function(index) { + res.push([$(this).text(), "http://www.mangaeden.com" + $(this).attr("href")]); + }); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.mangaeden.com/it-directory/?title=" + search, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + res = []; + MangaEden_it.getMangaListPage(objResponse, res); + var div = document.createElement("div"); + div.innerHTML = objResponse; + if (!isNaN(n = parseInt($('.pagination_bottom a:not(:has(span)):last', div).text()))) + { + for (i = 2; i <= n; i++) + { + $.ajax( + { + url: "http://www.mangaeden.com/it-directory/?title=" + search + "&page=" + i, + async: false, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + MangaEden_it.getMangaListPage(objResponse, res); + } + }); + } + } + callback("Manga Eden (IT)", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.chapterLink', div).each(function(index) { + res[res.length] = [parseFloat($("b", $(this)).text()), "http://www.mangaeden.com" + $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $('#top a:last', doc).text(); + var currentChapter = $('#combobox option:selected', doc).text(); + var currentMangaURL = "http://www.mangaeden.com" + $('#top a:last', doc).attr('href'); + var currentChapterURL = currentMangaURL + currentChapter + "/1/"; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + res.push(curUrl); + $('.pagination a:not(:contains("Prev")):not(:contains("Next")):not(.selected)', doc).each(function(index) + { + res.push($(this).attr('href')); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("#adsTop", doc).remove(); + $("#adsRight", doc).remove(); + $("#bottomAds", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + if (curUrl.indexOf("www.mangaeden.com/it-manga/") != -1) + { + return (curUrl.substring(curUrl.indexOf("www.mangaeden.com/it-manga/") + 27).split(/\//g).length - 1) > 1 + } + }, + //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. + $('.pagination').remove(); + $("#content", doc).empty(); + $("").appendTo($("#content", doc)); + $("
").appendTo($("#content", doc)); + $("").appendTo($("#content", doc)); + $(".navAMR", doc).css("text-align", "center"); + script = doc.createElement('script'); + script.innerText = "document.onkeydown = null;\n"; + doc.body.appendChild(script); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + if (urlImg.indexOf("http://") == -1) + { + urlImg = "http://www.mangaeden.com" + urlImg; + } + $.ajax( + { + url: urlImg, + success: function(objResponse) + { + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + $(image).attr('src', $('#mainImgC img', div).attr('src')); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Eden (IT)", MangaEden_it); diff --git a/MangaExceed.js b/MangaExceed.js index 510620f..facff21 100644 --- a/MangaExceed.js +++ b/MangaExceed.js @@ -1,9 +1,8 @@ -var MangaExceed={mirrorName:"Manga Exceed",canListFullMangas:false,mirrorIcon:"img/mangaexceed.png",languages:"en",isMe:function(url){return(url.indexOf("example.net")!=-1);},getMangaList:function(search,callback){$.ajax({url:"http://example.net/",beforeSend:function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache");},success:function(objResponse){res=[];var div=document.createElement("div");div.innerHTML=objResponse;$("a.lst",div).each(function(index){res.push([$('b:first-child',$(this)).text().trim(),$(this).attr("href")]);});callback("Manga Exceed",res);}});},getListChaps:function(urlManga,mangaName,obj,callback){$.ajax({url:urlManga,beforeSend:function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache");},success:function(objResponse){var div=document.createElement("div");div.innerHTML=objResponse;var res=[];$("a.list",div).each(function(index){res.push([$(this).text(),$(this).attr("href")]);});callback(res,obj);}});},getInformationsFromCurrentPage:function(doc,curUrl,callback){var name=$('h1.ttl a',doc).text();var currentChapter=$($('select.cbo_wpm_chp option:selected',doc)[0]).text();var currentMangaURL=$('h1.ttl a',doc).attr('href');var currentChapterURL=currentMangaURL+$($('select.cbo_wpm_chp option:selected',doc)[0]).attr('value')+'/';callback({"name":name,"currentChapter":currentChapter,"currentMangaURL":currentMangaURL,"currentChapterURL":currentChapterURL});},getListImages:function(doc,curUrl){var res=[];var baseUrl=$('h1.ttl a',doc).attr('href')+$($('select.cbo_wpm_chp option:selected',doc)[0]).attr('value')+'/';$('.cbo_wpm_pag:first option',doc).each(function(index) -{res.push(baseUrl+$(this).attr('value')+'/');});return res;},removeBanners:function(doc,curUrl){$('#sct_img_mng_enl ~ *',doc).remove()},whereDoIWriteScans:function(doc,curUrl){return $(".scanAMR",doc);},whereDoIWriteNavigation:function(doc,curUrl){return $(".navAMR",doc);},isCurrentPageAChapterPage:function(doc,curUrl){return($('#contentInner3 img',doc).length>0);},doSomethingBeforeWritingScans:function(doc,curUrl){$('#main_content',doc).css('width','auto');$('#contentInner3',doc).empty();$("").appendTo($("#contentInner3",doc));$("
").appendTo($("#contentInner3",doc));$("").appendTo($("#contentInner3",doc));$('.wpm_nav',doc).remove();$('.wpm_tip',doc).remove();$('#sct_img_mng_enl',doc).remove();$("#middle",doc).css("width","auto");},nextChapterUrl:function(select,doc,curUrl){if($(select).children("option:selected").prev().size()!=0){return $(select).children("option:selected").prev().val();} -return null;},previousChapterUrl:function(select,doc,curUrl){if($(select).children("option:selected").next().size()!=0){return $(select).children("option:selected").next().val();} -return null;},getImageFromPageAndWrite:function(urlImg,image,doc,curUrl){$.ajax({url:urlImg,success:function(objResponse) +var MangaExceed={mirrorName:"Manga Exceed",canListFullMangas:false,mirrorIcon:"img/mangaexceed.png",languages:"en",isMe:function(url){return(url.indexOf("example.net")!=-1);},getMangaList:function(search,callback){$.ajax({url:"http://example.net/",beforeSend:function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache");},success:function(objResponse){res=[];var div=document.createElement("div");div.innerHTML=objResponse;$("a.lst",div).each(function(index){res.push([$('b:first-child',$(this)).text().trim(),$(this).attr("href")]);});callback("Manga Exceed",res);}});},getListChaps:function(urlManga,mangaName,obj,callback){$.ajax({url:urlManga,beforeSend:function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache");},success:function(objResponse){var div=document.createElement("div");div.innerHTML=objResponse;var res=[];$("a.list",div).each(function(index){res.push([$(this).text(),$(this).attr("href")]);});callback(res,obj);}});},getInformationsFromCurrentPage:function(doc,curUrl,callback){var name=$('h1.ttl a',doc).text();var currentChapter=$($('select.cbo_wpm_chp option:selected',doc)[0]).text();var currentMangaURL=$('h1.ttl a',doc).attr('href');var currentChapterURL=currentMangaURL+$($('select.cbo_wpm_chp option:selected',doc)[0]).attr('value')+'/';callback({"name":name,"currentChapter":currentChapter,"currentMangaURL":currentMangaURL,"currentChapterURL":currentChapterURL});},getListImages:function(doc,curUrl){var res=[];var baseUrl=$('h1.ttl a',doc).attr('href')+$($('select.cbo_wpm_chp option:selected',doc)[0]).attr('value')+'/';$('.cbo_wpm_pag:first option',doc).each(function(index) +{res.push(baseUrl+$(this).attr('value')+'/');});return res;},removeBanners:function(doc,curUrl){$('#sct_img_mng_enl ~ *',doc).remove()},whereDoIWriteScans:function(doc,curUrl){return $(".scanAMR",doc);},whereDoIWriteNavigation:function(doc,curUrl){return $(".navAMR",doc);},isCurrentPageAChapterPage:function(doc,curUrl){return($('#contentInner3 img',doc).length>0);},doSomethingBeforeWritingScans:function(doc,curUrl){$('#main_content',doc).css('width','auto');$('#contentInner3',doc).empty();$("").appendTo($("#contentInner3",doc));$("
").appendTo($("#contentInner3",doc));$("").appendTo($("#contentInner3",doc));$('.wpm_nav',doc).remove();$('.wpm_tip',doc).remove();$('#sct_img_mng_enl',doc).remove();$("#middle",doc).css("width","auto");},nextChapterUrl:function(select,doc,curUrl){if($(select).children("option:selected").prev().size()!=0){return $(select).children("option:selected").prev().val();} +return null;},previousChapterUrl:function(select,doc,curUrl){if($(select).children("option:selected").next().size()!=0){return $(select).children("option:selected").next().val();} +return null;},getImageFromPageAndWrite:function(urlImg,image,doc,curUrl){$.ajax({url:urlImg,success:function(objResponse) {var div=document.createElement("div");div.innerHTML=objResponse;$(image).attr('src',$('#contentInner3 img',div).attr('src'));}});},isImageInOneCol:function(img,doc,curUrl){return false;},getMangaSelectFromPage:function(doc,curUrl){return null;},doAfterMangaLoaded:function(doc,curUrl){$("body > div:empty",doc).remove();}} - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Exceed", MangaExceed); diff --git a/MangaFox.js b/MangaFox.js index 0997153..1c03d53 100644 --- a/MangaFox.js +++ b/MangaFox.js @@ -1,215 +1,214 @@ -var MangaFox = { - mirrorName: "Manga-Fox", - canListFullMangas: false, - mirrorIcon: "img/mangafox.png", - languages: "en", - isMe: function(url) { - "use strict"; - return (url.indexOf("mangafox") !== -1); - }, - getMangaList: function(search, callback) { - "use strict"; - var urlManga = "http://mangafox.me/search.php?name=" + search + - "&advopts=1"; - $.ajax({ - url: urlManga, - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", - "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - if (objResponse.indexOf("No Manga Series") !== - -1) { - callback("Manga-Fox", []); - } else { - var res = []; - $("#listing tr td:first-child a", div).each( - function(index) { - res[index] = [$(this).html(), - $(this).attr("href") - ]; - }); - callback("Manga-Fox", res); - } - } - }); - }, - getListChaps: function(urlManga, mangaName, obj, callback) { - "use strict"; - $.ajax({ - url: urlManga + "?no_warning=1", - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", - "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) { +var MangaFox = { + mirrorName: "Manga-Fox", + canListFullMangas: false, + mirrorIcon: "img/mangafox.png", + languages: "en", + isMe: function(url) { + "use strict"; + return (url.indexOf("mangafox") !== -1); + }, + getMangaList: function(search, callback) { + "use strict"; + var urlManga = "http://mangafox.me/search.php?name=" + search + + "&advopts=1"; + $.ajax({ + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", + "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + if (objResponse.indexOf("No Manga Series") !== + -1) { + callback("Manga-Fox", []); + } else { + var res = []; + $("#listing tr td:first-child a", div).each( + function(index) { + res[index] = [$(this).html(), + $(this).attr("href") + ]; + }); + callback("Manga-Fox", res); + } + } + }); + }, + getListChaps: function(urlManga, mangaName, obj, callback) { + "use strict"; + $.ajax({ + url: urlManga + "?no_warning=1", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", + "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) { var div = document.createElement("div"); objResponse = objResponse.replace(/]*>/ig, ''); //avoid loading cover image - div.innerHTML = objResponse; - var res = []; - var mangaName = $('#title h2', div).text().substr( - 5, $('#title h2', div).text().length - - 18); - $("ul.chlist h3, ul.chlist h4", div).each( - function(index) { - if ($('a', $(this)).attr("href") - .indexOf("/manga/") !== -1) { - var vol = $(this).parents( - 'ul.chlist').prev( - 'div.slide').children( - 'h3').contents( - ':not(span)').text() - .trim().substr(7); - var tit = 'Vol ' + vol + - ' Ch ' + $('a', $(this)) - .text().substr( - mangaName.length + - 1) + ': ' + $( - 'span.title', $( - this)).text(); - var url = $('a', $(this)).attr( - "href"); - var curChapURL = url.substr( - 0, url.lastIndexOf( - "/") + 1); - if (curChapURL.substr( - curChapURL.length - - 2, 2) === "//") { - curChapURL = curChapURL - .substr(0, - curChapURL.length - - 1); - } - res[res.length] = [tit.trim(), - curChapURL - ]; - } - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage: function(doc, curUrl, callback) { - "use strict"; - var str = $('#series > strong a', doc).text(); // dom lookups are expensive! - var name = $('#related > h3 a', doc).text() || str.substring(0, - str.length - 6); //falls through #related, into #series - var currentChapter = $("#series h1", doc).text(); - var url = curUrl; - var posSl5 = 0; - var i; - for (i = 0; i < 5; i += 1) { - posSl5 = url.indexOf("/", posSl5 + 1); - } - var curChapURL = url.substr(0, url.lastIndexOf("/") + 1); - if (curChapURL.substr(curChapURL.length - 2, 2) === "//") { - curChapURL = curChapURL.substr(0, curChapURL.length - 1); - } - callback({ - "name": name, - "currentChapter": currentChapter.trim(), - "currentMangaURL": url.substr(0, posSl5 + 1), - "currentChapterURL": curChapURL - }); - }, - getListImages: function(doc, curUrl) { - "use strict"; - var res = []; - $('#top_bar select.m option', doc).each(function() { - if (this.value > 0) { - res.push(curUrl.substr(0, curUrl.lastIndexOf( - "/") + 1) + this.value + '.html'); - } - }); - return res; - }, - removeBanners: function(doc, curUrl) { - "use strict"; - $("#bottom_ads", doc).remove(); - $('#MarketGid9463', doc).remove(); - $('.ad', doc).remove(); - $('#banner', doc).remove(); - }, - whereDoIWriteScans: function(doc, curUrl) { - "use strict"; - return $("#viewer", doc); - }, - whereDoIWriteNavigation: function(doc, curUrl) { - "use strict"; - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage: function(doc, curUrl) { - "use strict"; - if ($("#viewer", doc) !== null) { - return ($("#viewer", doc).size() !== 0); - } - return false; - }, - doSomethingBeforeWritingScans: function(doc, curUrl) { - "use strict"; - $('#viewer', doc).css({ - 'width': 'auto', - 'margin': 'auto', - 'background-color': 'black' - }); - $("#image", doc).remove(); - $("#tool", doc).next().remove(); - $("#viewer", doc).after("").before( - ""); - $(".widepage.page", doc).remove(); - $('.fb_iframe_widget', doc).remove(); - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - }, - nextChapterUrl: function(select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function(select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) { - "use strict"; - $.ajax({ - url: urlImg, - success: function(objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("meta[property='og:image']", - div).attr("content").replace( - "thumbnails/mini.", "compressed/"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol: function(img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function(doc, curUrl) { - "use strict"; - return null; - }, - doAfterMangaLoaded: function(doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - } + div.innerHTML = objResponse; + var res = []; + var mangaName = $('#title h2', div).text().substr( + 5, $('#title h2', div).text().length - + 18); + $("ul.chlist h3, ul.chlist h4", div).each( + function(index) { + if ($('a', $(this)).attr("href") + .indexOf("/manga/") !== -1) { + var vol = $(this).parents( + 'ul.chlist').prev( + 'div.slide').children( + 'h3').contents( + ':not(span)').text() + .trim().substr(7); + var tit = 'Vol ' + vol + + ' Ch ' + $('a', $(this)) + .text().substr( + mangaName.length + + 1) + ': ' + $( + 'span.title', $( + this)).text(); + var url = $('a', $(this)).attr( + "href"); + var curChapURL = url.substr( + 0, url.lastIndexOf( + "/") + 1); + if (curChapURL.substr( + curChapURL.length - + 2, 2) === "//") { + curChapURL = curChapURL + .substr(0, + curChapURL.length - + 1); + } + res[res.length] = [tit.trim(), + curChapURL + ]; + } + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage: function(doc, curUrl, callback) { + "use strict"; + var str = $('#series > strong a', doc).text(); // dom lookups are expensive! + var name = $('#related > h3 a', doc).text() || str.substring(0, + str.length - 6); //falls through #related, into #series + var currentChapter = $("#series h1", doc).text(); + var url = curUrl; + var posSl5 = 0; + var i; + for (i = 0; i < 5; i += 1) { + posSl5 = url.indexOf("/", posSl5 + 1); + } + var curChapURL = url.substr(0, url.lastIndexOf("/") + 1); + if (curChapURL.substr(curChapURL.length - 2, 2) === "//") { + curChapURL = curChapURL.substr(0, curChapURL.length - 1); + } + callback({ + "name": name, + "currentChapter": currentChapter.trim(), + "currentMangaURL": url.substr(0, posSl5 + 1), + "currentChapterURL": curChapURL + }); + }, + getListImages: function(doc, curUrl) { + "use strict"; + var res = []; + $('#top_bar select.m option', doc).each(function() { + if (this.value > 0) { + res.push(curUrl.substr(0, curUrl.lastIndexOf( + "/") + 1) + this.value + '.html'); + } + }); + return res; + }, + removeBanners: function(doc, curUrl) { + "use strict"; + $("#bottom_ads", doc).remove(); + $('#MarketGid9463', doc).remove(); + $('.ad', doc).remove(); + $('#banner', doc).remove(); + }, + whereDoIWriteScans: function(doc, curUrl) { + "use strict"; + return $("#viewer", doc); + }, + whereDoIWriteNavigation: function(doc, curUrl) { + "use strict"; + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage: function(doc, curUrl) { + "use strict"; + if ($("#viewer", doc) !== null) { + return ($("#viewer", doc).size() !== 0); + } + return false; + }, + doSomethingBeforeWritingScans: function(doc, curUrl) { + "use strict"; + $('#viewer', doc).css({ + 'width': 'auto', + 'margin': 'auto', + 'background-color': 'black' + }); + $("#image", doc).remove(); + $("#tool", doc).next().remove(); + $("#viewer", doc).after("").before( + ""); + $(".widepage.page", doc).remove(); + $('.fb_iframe_widget', doc).remove(); + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + }, + nextChapterUrl: function(select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function(select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) { + "use strict"; + $.ajax({ + url: urlImg, + success: function(objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("meta[property='og:image']", + div).attr("content").replace( + "thumbnails/mini.", "compressed/"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol: function(img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function(doc, curUrl) { + "use strict"; + return null; + }, + doAfterMangaLoaded: function(doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga-Fox", MangaFox); diff --git a/MangaHead_en.js b/MangaHead_en.js index 18ab47c..d387eca 100644 --- a/MangaHead_en.js +++ b/MangaHead_en.js @@ -1,261 +1,230 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaHead_en = { - //Name of the mirror - mirrorName : "MangaHead (EN)", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangahead.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - if ((url.indexOf("http://mangahead.com/Manga-English-Scan/") != -1) || (url.indexOf("http://mangahead.com/index.php/Manga-English-Scan/") != -1)) - { - return true; - } - return false; - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://mangahead.com/Manga-English-Scan/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#updates strong a", div).each(function(index) { - res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; - }); - callback("MangaHead (EN)", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("#main_content strong+a", div).each(function(index) { - res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; - }); - - res.reverse(); - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $($(".mangaviewer_toppest_navig a", doc)[2]).text(); - var currentChapter = $($(".mangaviewer_toppest_navig", doc)[0].lastChild).text().trim().substring(3) - var currentMangaURL = "http://mangahead.com" + $($(".mangaviewer_toppest_navig a", doc)[2]).attr('href'); - var currentChapterURL = currentMangaURL + "/" + currentChapter.replace(/ /g, "-"); - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - $(".mangahead_thumbnail_cell a", doc).each(function(index) - { - res.push("http://mangahead.com" + $(this).attr('href')); - }); - if ($(".mangahead_pages_navigator", doc).length > 0) - { - var numPages = $("a", $(".mangahead_pages_navigator", doc)[0]).length - 1; - $("a", $(".mangahead_pages_navigator", doc)[0]).each(function(index) - { - if (index == numPages) return; - $.ajax( - { - url: "http://mangahead.com" + $(this).attr('href'), - async: false, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - $(".mangahead_thumbnail_cell a", div).each(function(index) - { - res.push("http://mangahead.com" + $(this).attr('href')); - }); - } - }); - }); - } - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("iframe", doc).remove(); - $("#bottom_ads", doc).remove(); - $("#main_skybanner", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($(".mangahead_thumbnail_cell", doc).size() > 0); - }, - - //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. - - $("#main_content", doc).empty() - var cloned = $("#main_content", doc).clone(); - $("#main_content", doc).after(cloned); - cloned.attr("id", "amrManga"); - $("#main_content", doc).remove(); - $("#amrManga", doc).css("width", "auto"); - $("#amrManga", doc).css("margin", "0"); - $("#amrManga", doc).css("background-color", "black"); - $("").appendTo($("#amrManga", doc)); - $("
").appendTo($("#amrManga", doc)); - $("").appendTo($("#amrManga", doc)); - $(".navAMR", doc).css("text-align", "center"); - $("body", doc).css("padding-right", "0"); - $("#main_inner", doc).css("padding", "0"); - $("#main_inner", doc).css("width", "100%"); - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "document.onkeydown = null;"; - doc.body.appendChild(script); - } - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var src = $("#mangahead_image", div).attr("src"); - - $(image).attr("src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaHead_en = { + //Name of the mirror + mirrorName : "MangaHead (EN)", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangahead.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + if ((url.indexOf("http://mangahead.com/Manga-English-Scan/") != -1) || (url.indexOf("http://mangahead.com/index.php/Manga-English-Scan/") != -1)) + { + return true; + } + return false; + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://mangahead.com/Manga-English-Scan/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#updates strong a", div).each(function(index) { + res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; + }); + callback("MangaHead (EN)", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#main_content strong+a", div).each(function(index) { + res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; + }); + res.reverse(); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $($(".mangaviewer_toppest_navig a", doc)[2]).text(); + var currentChapter = $($(".mangaviewer_toppest_navig", doc)[0].lastChild).text().trim().substring(3) + var currentMangaURL = "http://mangahead.com" + $($(".mangaviewer_toppest_navig a", doc)[2]).attr('href'); + var currentChapterURL = currentMangaURL + "/" + currentChapter.replace(/ /g, "-"); + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + $(".mangahead_thumbnail_cell a", doc).each(function(index) + { + res.push("http://mangahead.com" + $(this).attr('href')); + }); + if ($(".mangahead_pages_navigator", doc).length > 0) + { + var numPages = $("a", $(".mangahead_pages_navigator", doc)[0]).length - 1; + $("a", $(".mangahead_pages_navigator", doc)[0]).each(function(index) + { + if (index == numPages) return; + $.ajax( + { + url: "http://mangahead.com" + $(this).attr('href'), + async: false, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + $(".mangahead_thumbnail_cell a", div).each(function(index) + { + res.push("http://mangahead.com" + $(this).attr('href')); + }); + } + }); + }); + } + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("iframe", doc).remove(); + $("#bottom_ads", doc).remove(); + $("#main_skybanner", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($(".mangahead_thumbnail_cell", doc).size() > 0); + }, + //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. + $("#main_content", doc).empty() + var cloned = $("#main_content", doc).clone(); + $("#main_content", doc).after(cloned); + cloned.attr("id", "amrManga"); + $("#main_content", doc).remove(); + $("#amrManga", doc).css("width", "auto"); + $("#amrManga", doc).css("margin", "0"); + $("#amrManga", doc).css("background-color", "black"); + $("").appendTo($("#amrManga", doc)); + $("
").appendTo($("#amrManga", doc)); + $("").appendTo($("#amrManga", doc)); + $(".navAMR", doc).css("text-align", "center"); + $("body", doc).css("padding-right", "0"); + $("#main_inner", doc).css("padding", "0"); + $("#main_inner", doc).css("width", "100%"); + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "document.onkeydown = null;"; + doc.body.appendChild(script); + } + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("#mangahead_image", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaHead (EN)", MangaHead_en); diff --git a/MangaHead_raw.js b/MangaHead_raw.js index 185e867..3d2d4fd 100644 --- a/MangaHead_raw.js +++ b/MangaHead_raw.js @@ -1,261 +1,230 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaHead_raw = { - //Name of the mirror - mirrorName : "MangaHead (RAW)", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangahead.png", - //Languages of scans for the mirror - languages : "ja", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - if ((url.indexOf("http://mangahead.com/Manga-Raw-Scan/") != -1) || (url.indexOf("http://mangahead.com/index.php/Manga-Raw-Scan/") != -1)) - { - return true; - } - return false; - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://mangahead.com/Manga-Raw-Scan/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#updates strong a", div).each(function(index) { - res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; - }); - callback("MangaHead (RAW)", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("#main_content strong+a", div).each(function(index) { - res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; - }); - - res.reverse(); - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $($(".mangaviewer_toppest_navig a", doc)[2]).text(); - var currentChapter = $($(".mangaviewer_toppest_navig", doc)[0].lastChild).text().trim().substring(3) - var currentMangaURL = "http://mangahead.com" + $($(".mangaviewer_toppest_navig a", doc)[2]).attr('href'); - var currentChapterURL = currentMangaURL + "/" + currentChapter.replace(/ /g, "-"); - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - $(".mangahead_thumbnail_cell a", doc).each(function(index) - { - res.push("http://mangahead.com" + $(this).attr('href')); - }); - if ($(".mangahead_pages_navigator", doc).length > 0) - { - var numPages = $("a", $(".mangahead_pages_navigator", doc)[0]).length - 1; - $("a", $(".mangahead_pages_navigator", doc)[0]).each(function(index) - { - if (index == numPages) return; - $.ajax( - { - url: "http://mangahead.com" + $(this).attr('href'), - async: false, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - $(".mangahead_thumbnail_cell a", div).each(function(index) - { - res.push("http://mangahead.com" + $(this).attr('href')); - }); - } - }); - }); - } - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("iframe", doc).remove(); - $("#bottom_ads", doc).remove(); - $("#main_skybanner", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($(".mangahead_thumbnail_cell", doc).size() > 0); - }, - - //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. - - $("#main_content", doc).empty() - var cloned = $("#main_content", doc).clone(); - $("#main_content", doc).after(cloned); - cloned.attr("id", "amrManga"); - $("#main_content", doc).remove(); - $("#amrManga", doc).css("width", "auto"); - $("#amrManga", doc).css("margin", "0"); - $("#amrManga", doc).css("background-color", "black"); - $("").appendTo($("#amrManga", doc)); - $("
").appendTo($("#amrManga", doc)); - $("").appendTo($("#amrManga", doc)); - $(".navAMR", doc).css("text-align", "center"); - $("body", doc).css("padding-right", "0"); - $("#main_inner", doc).css("padding", "0"); - $("#main_inner", doc).css("width", "100%"); - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "document.onkeydown = null;"; - doc.body.appendChild(script); - } - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var src = $("#mangahead_image", div).attr("src"); - - $(image).attr("src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaHead_raw = { + //Name of the mirror + mirrorName : "MangaHead (RAW)", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangahead.png", + //Languages of scans for the mirror + languages : "ja", + //Return true if the url corresponds to the mirror + isMe : function(url) { + if ((url.indexOf("http://mangahead.com/Manga-Raw-Scan/") != -1) || (url.indexOf("http://mangahead.com/index.php/Manga-Raw-Scan/") != -1)) + { + return true; + } + return false; + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://mangahead.com/Manga-Raw-Scan/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#updates strong a", div).each(function(index) { + res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; + }); + callback("MangaHead (RAW)", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#main_content strong+a", div).each(function(index) { + res[res.length] = [$(this).text(), "http://mangahead.com" + $(this).attr("href")]; + }); + res.reverse(); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $($(".mangaviewer_toppest_navig a", doc)[2]).text(); + var currentChapter = $($(".mangaviewer_toppest_navig", doc)[0].lastChild).text().trim().substring(3) + var currentMangaURL = "http://mangahead.com" + $($(".mangaviewer_toppest_navig a", doc)[2]).attr('href'); + var currentChapterURL = currentMangaURL + "/" + currentChapter.replace(/ /g, "-"); + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + $(".mangahead_thumbnail_cell a", doc).each(function(index) + { + res.push("http://mangahead.com" + $(this).attr('href')); + }); + if ($(".mangahead_pages_navigator", doc).length > 0) + { + var numPages = $("a", $(".mangahead_pages_navigator", doc)[0]).length - 1; + $("a", $(".mangahead_pages_navigator", doc)[0]).each(function(index) + { + if (index == numPages) return; + $.ajax( + { + url: "http://mangahead.com" + $(this).attr('href'), + async: false, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + $(".mangahead_thumbnail_cell a", div).each(function(index) + { + res.push("http://mangahead.com" + $(this).attr('href')); + }); + } + }); + }); + } + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("iframe", doc).remove(); + $("#bottom_ads", doc).remove(); + $("#main_skybanner", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($(".mangahead_thumbnail_cell", doc).size() > 0); + }, + //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. + $("#main_content", doc).empty() + var cloned = $("#main_content", doc).clone(); + $("#main_content", doc).after(cloned); + cloned.attr("id", "amrManga"); + $("#main_content", doc).remove(); + $("#amrManga", doc).css("width", "auto"); + $("#amrManga", doc).css("margin", "0"); + $("#amrManga", doc).css("background-color", "black"); + $("").appendTo($("#amrManga", doc)); + $("
").appendTo($("#amrManga", doc)); + $("").appendTo($("#amrManga", doc)); + $(".navAMR", doc).css("text-align", "center"); + $("body", doc).css("padding-right", "0"); + $("#main_inner", doc).css("padding", "0"); + $("#main_inner", doc).css("width", "100%"); + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "document.onkeydown = null;"; + doc.body.appendChild(script); + } + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("#mangahead_image", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaHead (RAW)", MangaHead_raw); diff --git a/MangaHere.js b/MangaHere.js index 01195c1..6089101 100644 --- a/MangaHere.js +++ b/MangaHere.js @@ -1,214 +1,186 @@ -var MangaHere = { - //Name of the mirror - mirrorName: "Manga Here", - //True if the mirror can list all of its mangas. - canListFullMangas: false, - //Extension internal link to the icon of the mirror. - mirrorIcon: "img/mangahere.png", - //Languages of scans for the mirror - languages: "en", - - //Return true if the url corresponds to the mirror - isMe: function (url) { - return (url.indexOf("mangahere.co/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function (search, callback) { - $.ajax({ - url: "http://www.mangahere.co/search.php?name=" + search, - - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function (objResponse) { - var div = document.createElement("div"); - 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")]; - }); - callback("Manga Here", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function (urlManga, mangaName, obj, callback) { - $.ajax({ - url: urlManga, - - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function (objResponse) { - var div = document.createElement("div"); - 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")]; - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage: function (doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $($(".readpage_top .title a", doc)[1]).text().trim(); - if (name.length >= 5 && name.substr(name.length - 5, 5) == "Manga") { - 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"); - - - callback({ - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages: function (doc, curUrl) { - //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(); - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners: function (doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".inner_banner", doc).remove(); - $("#link_heading_banner", doc).remove(); - $(".readpage_top .title", doc).next().remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans: function (doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation: function (doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function (doc, curUrl) { - return ($("#image", doc).size() > 0); - }, - - //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)); - $("
").appendTo($(".amrcontainer", doc)); - $("").appendTo($(".amrcontainer", doc)); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl: function (select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl: function (select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax({ - url: urlImg, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("#image", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol: function (img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage: function (doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - 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'); - script.innerText = "Hotkeys.hotkeys.clear();"; - doc.body.appendChild(script); - $(".spanForImg").css("text-align", "left"); - } +var MangaHere = { + //Name of the mirror + mirrorName: "Manga Here", + //True if the mirror can list all of its mangas. + canListFullMangas: false, + //Extension internal link to the icon of the mirror. + mirrorIcon: "img/mangahere.png", + //Languages of scans for the mirror + languages: "en", + //Return true if the url corresponds to the mirror + isMe: function (url) { + return (url.indexOf("mangahere.co/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function (search, callback) { + $.ajax({ + url: "http://www.mangahere.co/search.php?name=" + search, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"); + 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")]; + }); + callback("Manga Here", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function (urlManga, mangaName, obj, callback) { + $.ajax({ + url: urlManga, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"); + 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")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage: function (doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $($(".readpage_top .title a", doc)[1]).text().trim(); + if (name.length >= 5 && name.substr(name.length - 5, 5) == "Manga") { + 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"); + callback({ + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages: function (doc, curUrl) { + //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(); + }); + return res; + }, + //Remove the banners from the current page + removeBanners: function (doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".inner_banner", doc).remove(); + $("#link_heading_banner", doc).remove(); + $(".readpage_top .title", doc).next().remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans: function (doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation: function (doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function (doc, curUrl) { + return ($("#image", doc).size() > 0); + }, + //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)); + $("
").appendTo($(".amrcontainer", doc)); + $("").appendTo($(".amrcontainer", doc)); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl: function (select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl: function (select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax({ + url: urlImg, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("#image", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol: function (img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage: function (doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + 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'); + script.innerText = "Hotkeys.hotkeys.clear();"; + doc.body.appendChild(script); + $(".spanForImg").css("text-align", "left"); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Here", MangaHere); diff --git a/MangaIR.js b/MangaIR.js index b3a93a0..b8a0822 100644 --- a/MangaIR.js +++ b/MangaIR.js @@ -1,240 +1,205 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// Sepehr Raftari // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaIR = { - //Name of the mirror - mirrorName : "MangaIR", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangafarsi.PNG", - //Languages of scans for the mirror - languages : "fa", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("www.manga.ir/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.manga.ir/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("select[name='manga'] option", div).each(function(index) { - if (index > 0) { - res[res.length] = [$(this).text(), "http://www.manga.ir/" + $(this).val()]; - } - }); - callback("MangaIR", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - var currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", div).val(); - $("select[name='chapter']:first option", div).each(function(index) { - res[res.length] = [$(this).text(), currentMangaURL + "/" + $(this).val()]; - }); - res.reverse(); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("select[name='manga']:first option:selected", doc).text(); - currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", doc).val(); - - currentChapter = $("select[name='chapter']:first option:selected", doc).text(); - currentChapterURL = currentMangaURL + "/" + $("select[name='chapter']:first option:selected", doc).val(); - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - var currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", doc).val(); - var currentChapterURL = currentMangaURL + "/" + $("select[name='chapter']:first option:selected", doc).val(); - - $("select[name='page']:first option", doc).each(function(index) { - res[res.length] = currentChapterURL + "/" + $(this).val(); - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".ads", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scansAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("img.picture", doc).size() > 0); - }, - - //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. - $("td.mid", doc).empty(); - $("").appendTo($("td.mid", doc)); - $("
").appendTo($("td.mid", doc)); - $("").appendTo($("td.mid", doc)); - - $(".scansAMR", doc).css("background-color", "black"); - $(".scansAMR", doc).css("padding-top", "10px"); - $(".navAMR", doc).css("text-align", "center"); - - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax({ - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = "http://www.manga.ir/" + $("img.picture", div).attr("src"); - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - var currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", doc).val(); - $("select[name='chapter']:first option", doc).each(function(index) { - $(this).val(currentMangaURL + "/" + $(this).val()); - }); - - return $("select[name='chapter']:first", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// Sepehr Raftari // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaIR = { + //Name of the mirror + mirrorName : "MangaIR", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangafarsi.PNG", + //Languages of scans for the mirror + languages : "fa", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("www.manga.ir/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.manga.ir/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("select[name='manga'] option", div).each(function(index) { + if (index > 0) { + res[res.length] = [$(this).text(), "http://www.manga.ir/" + $(this).val()]; + } + }); + callback("MangaIR", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + var currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", div).val(); + $("select[name='chapter']:first option", div).each(function(index) { + res[res.length] = [$(this).text(), currentMangaURL + "/" + $(this).val()]; + }); + res.reverse(); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("select[name='manga']:first option:selected", doc).text(); + currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", doc).val(); + currentChapter = $("select[name='chapter']:first option:selected", doc).text(); + currentChapterURL = currentMangaURL + "/" + $("select[name='chapter']:first option:selected", doc).val(); + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + var currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", doc).val(); + var currentChapterURL = currentMangaURL + "/" + $("select[name='chapter']:first option:selected", doc).val(); + $("select[name='page']:first option", doc).each(function(index) { + res[res.length] = currentChapterURL + "/" + $(this).val(); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".ads", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scansAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("img.picture", doc).size() > 0); + }, + //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. + $("td.mid", doc).empty(); + $("").appendTo($("td.mid", doc)); + $("
").appendTo($("td.mid", doc)); + $("").appendTo($("td.mid", doc)); + $(".scansAMR", doc).css("background-color", "black"); + $(".scansAMR", doc).css("padding-top", "10px"); + $(".navAMR", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax({ + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = "http://www.manga.ir/" + $("img.picture", div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + var currentMangaURL = "http://www.manga.ir/" + $("select[name='manga']:first option:selected", doc).val(); + $("select[name='chapter']:first option", doc).each(function(index) { + $(this).val(currentMangaURL + "/" + $(this).val()); + }); + return $("select[name='chapter']:first", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaIR", MangaIR); diff --git a/MangaInn.js b/MangaInn.js index e61ab02..a12ef5b 100644 --- a/MangaInn.js +++ b/MangaInn.js @@ -1,139 +1,138 @@ -var MangaInn = { - mirrorName : "MangaInn", - canListFullMangas : false, - languages : "en", - isMe : function (url) { - return (url.indexOf("mangainn.me/") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://www.mangainn.me/advresults", - type : 'POST', - data : { - "seriestype" : "c", - "series" : search, - "authortype" : "c", - "artisttype" : "c", - "yeartype" : "o" - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ -1); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('#gotoMangaInfo', doc).text(); - var currentChapter = $('#chapters option:selected', doc).text().replace(name, '').trim(); - var currentMangaURL = $('#gotoMangaInfo', doc).attr('href'); - var currentChapterURL = "http://www.mangainn.me/manga/chapter/" + $("#chapters option:selected", doc).val(); - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $('#cmbpages > option', doc).each(function () { - if (this.value > 0) { - res.push(curUrl.substr(0, curUrl.length) + '/page_' + this.value); - } - }); - return res; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("img#imgPage", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - removeBanners : function (doc, curUrl) { - $("#divmangareadtopad", doc).remove(); - $("#divmangareadtopad2", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $(".scanAMR", doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $(".boscontent", doc).after("
"); - $(".boscontent", doc).empty(); - $(".footer", doc).hide(); - $(".amrcontainer", doc).append(""); - $(".amrcontainer", doc).append("
"); - $(".amrcontainer", doc).append(""); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return "http://www.mangainn.me/manga/chapter/" + $(select).children("option:selected").next().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return "http://www.mangainn.me/manga/chapter/" + $(select).children("option:selected").prev().val(); - } - return null; - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return $("#chapters", doc); - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var MangaInn = { + mirrorName : "MangaInn", + canListFullMangas : false, + languages : "en", + isMe : function (url) { + return (url.indexOf("mangainn.me/") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://www.mangainn.me/advresults", + type : 'POST', + data : { + "seriestype" : "c", + "series" : search, + "authortype" : "c", + "artisttype" : "c", + "yeartype" : "o" + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ -1); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('#gotoMangaInfo', doc).text(); + var currentChapter = $('#chapters option:selected', doc).text().replace(name, '').trim(); + var currentMangaURL = $('#gotoMangaInfo', doc).attr('href'); + var currentChapterURL = "http://www.mangainn.me/manga/chapter/" + $("#chapters option:selected", doc).val(); + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $('#cmbpages > option', doc).each(function () { + if (this.value > 0) { + res.push(curUrl.substr(0, curUrl.length) + '/page_' + this.value); + } + }); + return res; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("img#imgPage", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + removeBanners : function (doc, curUrl) { + $("#divmangareadtopad", doc).remove(); + $("#divmangareadtopad2", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $(".scanAMR", doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $(".boscontent", doc).after("
"); + $(".boscontent", doc).empty(); + $(".footer", doc).hide(); + $(".amrcontainer", doc).append(""); + $(".amrcontainer", doc).append("
"); + $(".amrcontainer", doc).append(""); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return "http://www.mangainn.me/manga/chapter/" + $(select).children("option:selected").next().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return "http://www.mangainn.me/manga/chapter/" + $(select).children("option:selected").prev().val(); + } + return null; + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return $("#chapters", doc); + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaInn", MangaInn); diff --git a/MangaKong.js b/MangaKong.js index 57ba39c..1e6077d 100644 --- a/MangaKong.js +++ b/MangaKong.js @@ -1,226 +1,197 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaKong = { - //Name of the mirror - mirrorName : "MangaKong", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangakong.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("mangakong.com") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.mangakong.com/manga/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("select[name='manga'] > option", div).each(function(index) { - if (index > 0) { - res[res.length] = [$(this).text(), "http://www.mangakong.com/manga/" + $(this).val()]; - } - }); - callback("MangaKong", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - var nameurl = $( $("option:selected", $("select[name='manga']", div)[0] )).val(); - - $( $("option", $("select[name='chapter']", div)[0] ) ).each( - function(index){ - res[res.length] = [$(this).text(), "http://www.mangakong.com/manga/" + nameurl + "/" + $(this).val()]; - } - ); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $( $("option:selected", $("select[name='manga']", doc)[0] ) ).text(); - var curChapName = $( $("option:selected", $("select[name='chapter']", doc)[0] ) ).text(); - var nameurl = "http://www.mangakong.com/manga/" + $( $("option:selected", $("select[name='manga']", doc)[0] ) ).val(); - var chapurl = nameurl + "/" + $( $("option:selected", $("select[name='chapter']", doc)[0] ) ).val(); - callback({"name": name, - "currentChapter": curChapName, - "currentMangaURL": nameurl, - "currentChapterURL": chapurl}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl2) { - //This function runs in the DOM of the current consulted page. - var res = []; - - var nameurl = "http://www.mangakong.com/manga/" + $( $("option:selected", $("select[name='manga']", doc)[0] ) ).val(); - var chapurl = nameurl + "/" + $( $("option:selected", $("select[name='chapter']", doc)[0] ) ).val(); - - $( $("option", $("select[name='page']", doc)[0] ) ).each( - function(index){ - res[index] = chapurl + "/" + $(this).val(); - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("object", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#omv", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#omv .mid img.picture", doc).size() != 0); - }, - - //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. - $("#omv", doc).before($("")); - $("#omv", doc).after($("")); - $("#omv", doc).empty(); - $(".navAMR").css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = "http://www.mangakong.com/manga/" + $("#omv .mid img.picture", div).attr("src"); - $( image ).attr( "src", src ); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var nameurl = "http://www.mangakong.com/manga/" + $( $("option:selected", $("select[name='manga']", doc)[0] ) ).val(); - $("option", $($("select[name='chapter']", doc)[0])).each(function(index) { - $(this).val(nameurl + "/" + $(this).val()); - }); - return $("select[name='chapter']", doc)[0]; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaKong = { + //Name of the mirror + mirrorName : "MangaKong", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangakong.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("mangakong.com") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.mangakong.com/manga/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("select[name='manga'] > option", div).each(function(index) { + if (index > 0) { + res[res.length] = [$(this).text(), "http://www.mangakong.com/manga/" + $(this).val()]; + } + }); + callback("MangaKong", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + var nameurl = $( $("option:selected", $("select[name='manga']", div)[0] )).val(); + $( $("option", $("select[name='chapter']", div)[0] ) ).each( + function(index){ + res[res.length] = [$(this).text(), "http://www.mangakong.com/manga/" + nameurl + "/" + $(this).val()]; + } + ); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $( $("option:selected", $("select[name='manga']", doc)[0] ) ).text(); + var curChapName = $( $("option:selected", $("select[name='chapter']", doc)[0] ) ).text(); + var nameurl = "http://www.mangakong.com/manga/" + $( $("option:selected", $("select[name='manga']", doc)[0] ) ).val(); + var chapurl = nameurl + "/" + $( $("option:selected", $("select[name='chapter']", doc)[0] ) ).val(); + callback({"name": name, + "currentChapter": curChapName, + "currentMangaURL": nameurl, + "currentChapterURL": chapurl}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl2) { + //This function runs in the DOM of the current consulted page. + var res = []; + var nameurl = "http://www.mangakong.com/manga/" + $( $("option:selected", $("select[name='manga']", doc)[0] ) ).val(); + var chapurl = nameurl + "/" + $( $("option:selected", $("select[name='chapter']", doc)[0] ) ).val(); + $( $("option", $("select[name='page']", doc)[0] ) ).each( + function(index){ + res[index] = chapurl + "/" + $(this).val(); + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("object", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#omv", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#omv .mid img.picture", doc).size() != 0); + }, + //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. + $("#omv", doc).before($("")); + $("#omv", doc).after($("")); + $("#omv", doc).empty(); + $(".navAMR").css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = "http://www.mangakong.com/manga/" + $("#omv .mid img.picture", div).attr("src"); + $( image ).attr( "src", src ); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var nameurl = "http://www.mangakong.com/manga/" + $( $("option:selected", $("select[name='manga']", doc)[0] ) ).val(); + $("option", $($("select[name='chapter']", doc)[0])).each(function(index) { + $(this).val(nameurl + "/" + $(this).val()); + }); + return $("select[name='chapter']", doc)[0]; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaKong", MangaKong); diff --git a/MangaLib.js b/MangaLib.js index 167ae73..1958997 100644 --- a/MangaLib.js +++ b/MangaLib.js @@ -1,142 +1,141 @@ -var MangaLib = { - mirrorName : "Manga Library", - canListFullMangas : true, - mirrorIcon : "img/mangalib.png", - languages : "pl", - isMe : function (url) { - "use strict"; - return (url.indexOf("manga-lib.pl/") !== -1); - }, - getMangaList : function (search, callback) { - "use strict"; - $.ajax({ - url : "http://www.manga-lib.pl/index.php/manga/search?title=" + search, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - "use strict"; - $(".reader", doc).empty(); - $(".reader", doc).css("height", "auto"); - $(".reader", doc).css("width", "auto"); - $(".reader", doc).before(""); - $(".reader", doc).after(""); - $(".navAMR", doc).css("text-align", "center"); - }, - nextChapterUrl : function (select, doc, curUrl) { - "use strict"; - if ($("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).prev().size() !== 0) { - return $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).prev().attr("value"); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - "use strict"; - if ($("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).next().size() !== 0) { - return $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).next().attr("value"); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - "use strict"; - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("#img_curr", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - "use strict"; - return $($(".reader_menu .left select", doc)[0]); - }, - doAfterMangaLoaded : function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - $(".reader_page_holder .AMRtable", doc).css("background-color", "black"); - $(".reader_page_holder .AMRtable tr", doc).css("background-color", "black"); - $(".reader_page_holder .AMRtable tr td", doc).css("background-color", "black"); - } +var MangaLib = { + mirrorName : "Manga Library", + canListFullMangas : true, + mirrorIcon : "img/mangalib.png", + languages : "pl", + isMe : function (url) { + "use strict"; + return (url.indexOf("manga-lib.pl/") !== -1); + }, + getMangaList : function (search, callback) { + "use strict"; + $.ajax({ + url : "http://www.manga-lib.pl/index.php/manga/search?title=" + search, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + "use strict"; + $(".reader", doc).empty(); + $(".reader", doc).css("height", "auto"); + $(".reader", doc).css("width", "auto"); + $(".reader", doc).before(""); + $(".reader", doc).after(""); + $(".navAMR", doc).css("text-align", "center"); + }, + nextChapterUrl : function (select, doc, curUrl) { + "use strict"; + if ($("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).prev().size() !== 0) { + return $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).prev().attr("value"); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + "use strict"; + if ($("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).next().size() !== 0) { + return $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).next().attr("value"); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + "use strict"; + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("#img_curr", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + "use strict"; + return $($(".reader_menu .left select", doc)[0]); + }, + doAfterMangaLoaded : function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + $(".reader_page_holder .AMRtable", doc).css("background-color", "black"); + $(".reader_page_holder .AMRtable tr", doc).css("background-color", "black"); + $(".reader_page_holder .AMRtable tr td", doc).css("background-color", "black"); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Library", MangaLib); diff --git a/MangaPirate.js b/MangaPirate.js index 2fa602d..cad84f6 100644 --- a/MangaPirate.js +++ b/MangaPirate.js @@ -1,131 +1,130 @@ -var MangaPirate = { - mirrorName : "Manga Pirate", - canListFullMangas : false, - mirrorIcon : "img/mangapirate.png", - languages : "en", - isMe : function (url) { - return (url.match(/mangapirate.(me|net)/gi) !== null); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://mangapirate.me/manga-list/advanced-search/", - type : 'POST', - data : { - "txt_wpm_pag_mng_sch_nme" : search, - "cmd_wpm_pag_mng_sch_sbm" : "Search" - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ 0); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $("h1.ttl a", doc).text(), - currentMangaURL = $("h1.ttl a", doc).attr('href').replace("mangapirate.net", "mangapirate.me"), - currentChapter = $("select.cbo_wpm_chp:first option:selected", doc).text().trim(), - currentChapterURL = currentMangaURL + $("select.cbo_wpm_chp:first option:selected", doc).attr('value') + "/"; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var currentMangaURL = $("h1.ttl a", doc).attr('href'), - currentChapterURL = currentMangaURL + $("select.cbo_wpm_chp:first option:selected", doc).attr('value'), - res = []; - $('.cbo_wpm_pag:first option', doc).each(function () { - res.push(currentChapterURL + '/' + $(this).attr('value')); - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $("#top-left-ad", doc).remove(); - $("#top-right-ad", doc).remove(); - $("#bottom-right-ad", doc).remove(); - $("#bottom-left-ad", doc).remove(); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $(".mng_rlt", doc).hide(); - $(".wpm_nav", doc).hide(); - $(".prw", doc).empty(); - $(".prw", doc).prepend(""); - $(".prw", doc).append(""); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $(".prw", doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"), - src; - div.innerHTML = objResponse; - src = $(".prw img", div).attr('src'); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var MangaPirate = { + mirrorName : "Manga Pirate", + canListFullMangas : false, + mirrorIcon : "img/mangapirate.png", + languages : "en", + isMe : function (url) { + return (url.match(/mangapirate.(me|net)/gi) !== null); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://mangapirate.me/manga-list/advanced-search/", + type : 'POST', + data : { + "txt_wpm_pag_mng_sch_nme" : search, + "cmd_wpm_pag_mng_sch_sbm" : "Search" + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ 0); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $("h1.ttl a", doc).text(), + currentMangaURL = $("h1.ttl a", doc).attr('href').replace("mangapirate.net", "mangapirate.me"), + currentChapter = $("select.cbo_wpm_chp:first option:selected", doc).text().trim(), + currentChapterURL = currentMangaURL + $("select.cbo_wpm_chp:first option:selected", doc).attr('value') + "/"; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var currentMangaURL = $("h1.ttl a", doc).attr('href'), + currentChapterURL = currentMangaURL + $("select.cbo_wpm_chp:first option:selected", doc).attr('value'), + res = []; + $('.cbo_wpm_pag:first option', doc).each(function () { + res.push(currentChapterURL + '/' + $(this).attr('value')); + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $("#top-left-ad", doc).remove(); + $("#top-right-ad", doc).remove(); + $("#bottom-right-ad", doc).remove(); + $("#bottom-left-ad", doc).remove(); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $(".mng_rlt", doc).hide(); + $(".wpm_nav", doc).hide(); + $(".prw", doc).empty(); + $(".prw", doc).prepend(""); + $(".prw", doc).append(""); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $(".prw", doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"), + src; + div.innerHTML = objResponse; + src = $(".prw img", div).attr('src'); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Pirate", MangaPirate); diff --git a/MangaReader.js b/MangaReader.js index 1fb2a74..d3ca5da 100644 --- a/MangaReader.js +++ b/MangaReader.js @@ -1,129 +1,128 @@ -var MangaReader = { - mirrorName : "Manga Reader", - canListFullMangas : false, - mirrorIcon : "img/mangareader.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("www.mangareader.net") !== -1); - }, - getMangaList : function (search, callback) { - var urlManga = "http://www.mangareader.net/search/?w=" + search + "&rd=0&status=0&order=0&genre=0000000000000000000000000000000000000&p=0"; - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/
"); - $("#imgholder", doc).after(""); - $("#selection", doc).next().remove(); - $("#selection", doc).remove(); - $("#navi", doc).empty(); - $("#selectmanga", doc).empty(); - $("#wrapper_body", doc).css("width", "auto"); - $("#topchapter", doc).css("width", "950px"); - $("#topchapter", doc).css("text-align", "center"); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $.ajax({ - url : urlImg, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("#imgholder img", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var MangaReader = { + mirrorName : "Manga Reader", + canListFullMangas : false, + mirrorIcon : "img/mangareader.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("www.mangareader.net") !== -1); + }, + getMangaList : function (search, callback) { + var urlManga = "http://www.mangareader.net/search/?w=" + search + "&rd=0&status=0&order=0&genre=0000000000000000000000000000000000000&p=0"; + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/
"); + $("#imgholder", doc).after(""); + $("#selection", doc).next().remove(); + $("#selection", doc).remove(); + $("#navi", doc).empty(); + $("#selectmanga", doc).empty(); + $("#wrapper_body", doc).css("width", "auto"); + $("#topchapter", doc).css("width", "950px"); + $("#topchapter", doc).css("text-align", "center"); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $.ajax({ + url : urlImg, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("#imgholder img", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Reader", MangaReader); diff --git a/MangaStream.js b/MangaStream.js index 13a7b26..e428229 100644 --- a/MangaStream.js +++ b/MangaStream.js @@ -1,149 +1,148 @@ -var MangaStream = { - mirrorName: "MangaStream", - canListFullMangas: true, - mirrorIcon: "img/mangastream.png", - languages: "en", - isMe: function (url) { - "use strict"; - return (url.match(/(mangastream|readms).com/g) !== null); - }, - getMangaList: function (search, callback) { - "use strict"; - $.ajax({ - url: "http://mangastream.com/manga", - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ 0) - { - res[npages - 1] = baseUrl + npages; - npages--; - } - return res; - }, - removeBanners: function (doc, curUrl) { - "use strict"; - $('.banner-ad', doc).remove(); - $('#reader-sky', doc).appendTo('.row-fluid.page-wrap', doc); - $('#reader-sky', doc).css('margin-left', 'auto'); - $('#reader-sky', doc).css('margin-right', 'auto'); - $('#reader-sky', doc).css('left', 'auto'); - $('#reader-sky', doc).css('right', 'auto'); - $('#reader-sky', doc).css('position', 'relative'); - }, - whereDoIWriteScans: function (doc, curUrl) { - "use strict"; - return $(".scanAMR", doc); - }, - whereDoIWriteNavigation: function (doc, curUrl) { - "use strict"; - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage: function (doc, curUrl) { - "use strict"; - return ($("#manga-page", doc).size() > 0); - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - "use strict"; - $(".page", doc).empty(); - $(".page", doc).css("width", "auto"); - $(".sub-nav", doc).hide(); - $(".page", doc).append(""); - $(".page", doc).append("
"); - $(".page", doc).append(""); - $(".navAMR", doc).css("text-align", "center"); - }, - nextChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - "use strict"; - $.ajax({ - url: urlImg, - success: function (objResponse) { - var div = document.createElement("div"), - src; - div.innerHTML = objResponse; - src = $("img#manga-page", div).attr("src"); - $(image).attr("src", src); - } - }); - }, - isImageInOneCol: function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - "use strict"; - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - } +var MangaStream = { + mirrorName: "MangaStream", + canListFullMangas: true, + mirrorIcon: "img/mangastream.png", + languages: "en", + isMe: function (url) { + "use strict"; + return (url.match(/(mangastream|readms).com/g) !== null); + }, + getMangaList: function (search, callback) { + "use strict"; + $.ajax({ + url: "http://mangastream.com/manga", + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ 0) + { + res[npages - 1] = baseUrl + npages; + npages--; + } + return res; + }, + removeBanners: function (doc, curUrl) { + "use strict"; + $('.banner-ad', doc).remove(); + $('#reader-sky', doc).appendTo('.row-fluid.page-wrap', doc); + $('#reader-sky', doc).css('margin-left', 'auto'); + $('#reader-sky', doc).css('margin-right', 'auto'); + $('#reader-sky', doc).css('left', 'auto'); + $('#reader-sky', doc).css('right', 'auto'); + $('#reader-sky', doc).css('position', 'relative'); + }, + whereDoIWriteScans: function (doc, curUrl) { + "use strict"; + return $(".scanAMR", doc); + }, + whereDoIWriteNavigation: function (doc, curUrl) { + "use strict"; + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage: function (doc, curUrl) { + "use strict"; + return ($("#manga-page", doc).size() > 0); + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + "use strict"; + $(".page", doc).empty(); + $(".page", doc).css("width", "auto"); + $(".sub-nav", doc).hide(); + $(".page", doc).append(""); + $(".page", doc).append("
"); + $(".page", doc).append(""); + $(".navAMR", doc).css("text-align", "center"); + }, + nextChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + "use strict"; + $.ajax({ + url: urlImg, + success: function (objResponse) { + var div = document.createElement("div"), + src; + div.innerHTML = objResponse; + src = $("img#manga-page", div).attr("src"); + $(image).attr("src", src); + } + }); + }, + isImageInOneCol: function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + "use strict"; + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaStream", MangaStream); diff --git a/MangaTraders.js b/MangaTraders.js index e1c1044..49f3447 100644 --- a/MangaTraders.js +++ b/MangaTraders.js @@ -1,260 +1,239 @@ -var MangaTraders = -{ - mirrorName: "Manga Traders", - canListFullMangas: false, - mirrorIcon: "img/mangatraders.png", - languages: "en", - - //Return true if the url corresponds to the mirror - isMe: function(url) - { - return (url.indexOf("www.mangatraders.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://www.mangatraders.com/search/?searchSeries=1&showOnlySeries=1&term=" + search, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - //var div = document.createElement("div"); - //div.innerHTML = objResponse; - var res = []; - $(".list1 li:not(:has(img[alt='NO_DL!'])) a", objResponse).each(function(index) - { - res.push([$(this).text(), "http://www.mangatraders.com" + $(this).attr("href")]); - }); - callback("Manga Traders", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga + '/files', - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(xml) - { - var res = []; - $('file', xml).each(function(index) - { - res.push([$('file_disp', this).text(), "http://www.mangatraders.com/view/list/" + $(this).attr('id')]); - }); - res.reverse(); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - if (curUrl.indexOf('/list/') != -1) - { - var name = $('h2.viewListHeader a', doc).text(); - var currentChapter = $('#dropdown_top select[name=file_selector] option:selected', doc).text() - var currentMangaURL = "http://www.mangatraders.com" + $('h2.viewListHeader a', doc).attr('href'); - var currentChapterURL = "http://www.mangatraders.com/view/list/" + $('#dropdown_top select[name=file_selector] option:selected', doc).attr('value'); - } - else - { - var name = $($('#viewerHeader a')[0]).text(); - var currentChapter = doc.title.substring(24, doc.title.lastIndexOf('-') - 1); - var currentMangaURL = "http://www.mangatraders.com" + $($('#viewerHeader a')[0]).attr('href'); - var currentChapterURL = curUrl.substring(0, curUrl.lastIndexOf('/page')==-1?curUrl.lenght:curUrl.lastIndexOf('/page')).replace('file', 'list'); - } - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - //This function runs in the DOM of the current consulted page. - getListImages: function(doc, curUrl) - { - var res = []; - if (curUrl.indexOf('/list/') != -1) - { - $('#content_table a', doc).each(function(index) - { - res.push("http://www.mangatraders.com" + $(this).attr('href')); - }); - } - else - { - var baseUrl = curUrl.substring(0, curUrl.lastIndexOf('/page')==-1?curUrl.lenght:curUrl.lastIndexOf('/page')) + '/page/'; - $('select[name=page_top2] option', doc).each(function(index) - { - res.push(baseUrl + $(this).attr('value')); - }); - } - - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - $('#topmenu ~ *', doc).remove(); - $('#header', doc).append('
'); - $('#header', doc).css('height', 'auto'); - $('#google_ad_top', doc).remove(); - $('object', doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteScans: function(doc, curUrl) - { - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return (curUrl.match(/www.mangatraders.com\/view\/(list|file)/gi) != null) - }, - - //This method is called before displaying full chapters in the page - //This function runs in the DOM of the current consulted page. - doSomethingBeforeWritingScans: function(doc, curUrl) - { - if (typeof doc.createElement == 'function') - { - script = doc.createElement('script'); - script.innerText = "function setAreaHeight() {return true;}"; - script.innerText += "var docCss = document.styleSheets; var cssOk = false;"; - script.innerText += "for (i = 0; i < docCss.length; i++) if (docCss[i].cssRules){"; - script.innerText += "for (j = 0; j < docCss[i].cssRules.length; j++) if (docCss[i].cssRules[j].selectorText == 'body, th, td, input, textarea, select, caption'){"; - script.innerText += "docCss[i].cssRules[j].style.color = '#565051'; cssOk = true; break;}"; - script.innerText += "if (cssOk) break;}"; - doc.body.appendChild(script); - } - $('body', doc).css('height', 'auto'); - $('#col1, #col3', doc).remove(); - $('#col2', doc).css('margin', '0 22px'); - $('#content', doc).empty(); - $('#content', doc).css('background', 'black'); - $('#content', doc).css('margin', '0'); - $('#content', doc).css('width', '100%'); - $('#content', doc).attr('class', ''); - $('#footer', doc).after($('#content', doc)); - $("").appendTo($("#content", doc)); - $("
").appendTo($("#content", doc)); - $("").appendTo($("#content", doc)); - $(".navAMR", doc).css("text-align", "center"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $.ajax( - { - url: urlImg, - success: function(objResponse) - { - //var div = document.createElement("div"); - //div.innerHTML = objResponse; - - $(image).attr('src', $('#image', objResponse).attr('src')); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol: function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded : function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - } +var MangaTraders = +{ + mirrorName: "Manga Traders", + canListFullMangas: false, + mirrorIcon: "img/mangatraders.png", + languages: "en", + //Return true if the url corresponds to the mirror + isMe: function(url) + { + return (url.indexOf("www.mangatraders.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://www.mangatraders.com/search/?searchSeries=1&showOnlySeries=1&term=" + search, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + //var div = document.createElement("div"); + //div.innerHTML = objResponse; + var res = []; + $(".list1 li:not(:has(img[alt='NO_DL!'])) a", objResponse).each(function(index) + { + res.push([$(this).text(), "http://www.mangatraders.com" + $(this).attr("href")]); + }); + callback("Manga Traders", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga + '/files', + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(xml) + { + var res = []; + $('file', xml).each(function(index) + { + res.push([$('file_disp', this).text(), "http://www.mangatraders.com/view/list/" + $(this).attr('id')]); + }); + res.reverse(); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + if (curUrl.indexOf('/list/') != -1) + { + var name = $('h2.viewListHeader a', doc).text(); + var currentChapter = $('#dropdown_top select[name=file_selector] option:selected', doc).text() + var currentMangaURL = "http://www.mangatraders.com" + $('h2.viewListHeader a', doc).attr('href'); + var currentChapterURL = "http://www.mangatraders.com/view/list/" + $('#dropdown_top select[name=file_selector] option:selected', doc).attr('value'); + } + else + { + var name = $($('#viewerHeader a')[0]).text(); + var currentChapter = doc.title.substring(24, doc.title.lastIndexOf('-') - 1); + var currentMangaURL = "http://www.mangatraders.com" + $($('#viewerHeader a')[0]).attr('href'); + var currentChapterURL = curUrl.substring(0, curUrl.lastIndexOf('/page')==-1?curUrl.lenght:curUrl.lastIndexOf('/page')).replace('file', 'list'); + } + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + //This function runs in the DOM of the current consulted page. + getListImages: function(doc, curUrl) + { + var res = []; + if (curUrl.indexOf('/list/') != -1) + { + $('#content_table a', doc).each(function(index) + { + res.push("http://www.mangatraders.com" + $(this).attr('href')); + }); + } + else + { + var baseUrl = curUrl.substring(0, curUrl.lastIndexOf('/page')==-1?curUrl.lenght:curUrl.lastIndexOf('/page')) + '/page/'; + $('select[name=page_top2] option', doc).each(function(index) + { + res.push(baseUrl + $(this).attr('value')); + }); + } + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + $('#topmenu ~ *', doc).remove(); + $('#header', doc).append('
'); + $('#header', doc).css('height', 'auto'); + $('#google_ad_top', doc).remove(); + $('object', doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteScans: function(doc, curUrl) + { + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return (curUrl.match(/www.mangatraders.com\/view\/(list|file)/gi) != null) + }, + //This method is called before displaying full chapters in the page + //This function runs in the DOM of the current consulted page. + doSomethingBeforeWritingScans: function(doc, curUrl) + { + if (typeof doc.createElement == 'function') + { + script = doc.createElement('script'); + script.innerText = "function setAreaHeight() {return true;}"; + script.innerText += "var docCss = document.styleSheets; var cssOk = false;"; + script.innerText += "for (i = 0; i < docCss.length; i++) if (docCss[i].cssRules){"; + script.innerText += "for (j = 0; j < docCss[i].cssRules.length; j++) if (docCss[i].cssRules[j].selectorText == 'body, th, td, input, textarea, select, caption'){"; + script.innerText += "docCss[i].cssRules[j].style.color = '#565051'; cssOk = true; break;}"; + script.innerText += "if (cssOk) break;}"; + doc.body.appendChild(script); + } + $('body', doc).css('height', 'auto'); + $('#col1, #col3', doc).remove(); + $('#col2', doc).css('margin', '0 22px'); + $('#content', doc).empty(); + $('#content', doc).css('background', 'black'); + $('#content', doc).css('margin', '0'); + $('#content', doc).css('width', '100%'); + $('#content', doc).attr('class', ''); + $('#footer', doc).after($('#content', doc)); + $("").appendTo($("#content", doc)); + $("
").appendTo($("#content", doc)); + $("").appendTo($("#content", doc)); + $(".navAMR", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $.ajax( + { + url: urlImg, + success: function(objResponse) + { + //var div = document.createElement("div"); + //div.innerHTML = objResponse; + $(image).attr('src', $('#image', objResponse).attr('src')); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol: function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded : function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Traders", MangaTraders); diff --git a/MangaTurk.js b/MangaTurk.js index a27d516..021baea 100644 --- a/MangaTurk.js +++ b/MangaTurk.js @@ -1,232 +1,198 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var MangaTurk = { - //Name of the mirror - mirrorName : "MangaTurk", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangaturk.png", - //Languages of scans for the mirror - languages : "tr", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("turkcraft.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.turkcraft.com/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("select[name='manga'] option", div).each(function(index) { - if (index > 0) { - res[res.length] = [$(this).text(), "http://www.turkcraft.com/" + $(this).val()]; - } - }); - callback("MangaTurk", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("select[name='chapter']:first option", div).each(function(index) { - res[res.length] = [$(this).text(), urlManga + "/" + $(this).val()]; - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("select[name='manga']:first option:selected", doc).text(); - currentMangaURL = "http://www.turkcraft.com/" + $("select[name='manga']:first option:selected", doc).val(); - - currentChapter = $("select[name='chapter']:first option:selected", doc).text(); - currentChapterURL = currentMangaURL + "/" + $("select[name='chapter']:first option:selected", doc).val(); - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - var mg = "http://www.turkcraft.com/" + $("select[name='manga']:first option:selected", doc).val(); - var chap = mg + "/" + $("select[name='chapter']:first option:selected", doc).val(); - - $("select[name='page']:first option", doc).each(function(index) { - res[res.length] = chap + "/" + $(this).val(); - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("iframe", doc).parents("ins").remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scansAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".pager", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("img.picture", doc).size() > 0); - }, - - //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. - $(".pager", doc).empty(); - $("img.picture", doc).closest("td").html("
"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax({ - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var src = "http://www.turkcraft.com/" + $("img.picture", div).attr("src"); - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - var mg = "http://www.turkcraft.com/" + $("select[name='manga']:first option:selected", doc).val(); - - $("select[name='chapter']:first option", doc).each(function(index) { - $(this).val(mg + "/" + $(this).val()); - }); - - return $("select[name='chapter']:first", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var MangaTurk = { + //Name of the mirror + mirrorName : "MangaTurk", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangaturk.png", + //Languages of scans for the mirror + languages : "tr", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("turkcraft.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.turkcraft.com/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("select[name='manga'] option", div).each(function(index) { + if (index > 0) { + res[res.length] = [$(this).text(), "http://www.turkcraft.com/" + $(this).val()]; + } + }); + callback("MangaTurk", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("select[name='chapter']:first option", div).each(function(index) { + res[res.length] = [$(this).text(), urlManga + "/" + $(this).val()]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("select[name='manga']:first option:selected", doc).text(); + currentMangaURL = "http://www.turkcraft.com/" + $("select[name='manga']:first option:selected", doc).val(); + currentChapter = $("select[name='chapter']:first option:selected", doc).text(); + currentChapterURL = currentMangaURL + "/" + $("select[name='chapter']:first option:selected", doc).val(); + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + var mg = "http://www.turkcraft.com/" + $("select[name='manga']:first option:selected", doc).val(); + var chap = mg + "/" + $("select[name='chapter']:first option:selected", doc).val(); + $("select[name='page']:first option", doc).each(function(index) { + res[res.length] = chap + "/" + $(this).val(); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("iframe", doc).parents("ins").remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scansAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".pager", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("img.picture", doc).size() > 0); + }, + //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. + $(".pager", doc).empty(); + $("img.picture", doc).closest("td").html("
"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax({ + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = "http://www.turkcraft.com/" + $("img.picture", div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + var mg = "http://www.turkcraft.com/" + $("select[name='manga']:first option:selected", doc).val(); + $("select[name='chapter']:first option", doc).each(function(index) { + $(this).val(mg + "/" + $(this).val()); + }); + return $("select[name='chapter']:first", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaTurk", MangaTurk); diff --git a/MangaYobai.js b/MangaYobai.js index ba78ff7..b050df4 100644 --- a/MangaYobai.js +++ b/MangaYobai.js @@ -1,154 +1,129 @@ -var MangaYobai = { - mirrorName : "MangaYobai", - canListFullMangas : false, - mirrorIcon : "img/generic.png", - languages: "en", - - isMe : function(url) { - return (url.indexOf("mangayobai.net/foolslide") != -1); - }, - - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://mangayobai.net/foolslide/reader/search/", - type: 'POST', - data: - { - 'search': search - }, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $('.list.series > .group > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback("MangaYobai", res); - } - }); - }, - - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $('.list > .element > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback(res, obj); - } - }); - }, - - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - getListImages : function(doc, curUrl) { - var res = []; - eval($('body', doc).html().match(/var pages = .*n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - removeBanners : function(doc, curUrl) { - $(".ads", doc).remove(); - }, - - whereDoIWriteScans : function(doc, curUrl) { - return $('#page', doc); - }, - - whereDoIWriteNavigation : function(doc, curUrl) { - return $(".navAMR", doc); - }, - - isCurrentPageAChapterPage : function(doc, curUrl) { - return (curUrl.search('mangayobai.net/foolslide/reader/read/') > -1); - }, - - doSomethingBeforeWritingScans : function(doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function() { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - - nextChapterUrl : function(select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - previousChapterUrl : function(select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - - isImageInOneCol : function(img, doc, curUrl) { - return false; - }, - - getMangaSelectFromPage : function(doc, curUrl) { - return null; - }, - - doAfterMangaLoaded : function(doc, curUrl) { - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - } +var MangaYobai = { + mirrorName : "MangaYobai", + canListFullMangas : false, + mirrorIcon : "img/generic.png", + languages: "en", + isMe : function(url) { + return (url.indexOf("mangayobai.net/foolslide") != -1); + }, + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://mangayobai.net/foolslide/reader/search/", + type: 'POST', + data: + { + 'search': search + }, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list.series > .group > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("MangaYobai", res); + } + }); + }, + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + getListImages : function(doc, curUrl) { + var res = []; + eval($('body', doc).html().match(/var pages = .*n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + removeBanners : function(doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function(doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function(doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function(doc, curUrl) { + return (curUrl.search('mangayobai.net/foolslide/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function(doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function() { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function(select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function(select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function(img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function(doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function(doc, curUrl) { + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MangaYobai", MangaYobai); diff --git a/Mangable.js b/Mangable.js index acdf973..2ef7f5e 100644 --- a/Mangable.js +++ b/Mangable.js @@ -1,247 +1,213 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var Mangable = { - //Name of the mirror - mirrorName : "Mangable", - //True if the mirror can list all of its mangas. - canListFullMangas : false, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/mangable.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("mangable.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://mangable.com/search/?series_name=" + search + "&submit=Search", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#comprehensive_list li .col1 > a:first-child", div).each(function(index) { - var tit = $(this).text(); - res[res.length] = [tit, "http://mangable.com" + $(this).attr("href")]; - }); - callback("Mangable", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $("#newlist li a:first-child", div).each(function(index) { - var tit = $(".audi b", $(this)).text(); - tit = tit.replace(mangaName, "").trim(); - - res[res.length] = [tit, $(this).attr("href")]; - }); - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("#breadcrumbs li:nth-child(2) a", doc).text(); - currentMangaURL = "http://mangable.com" + $("#breadcrumbs li:nth-child(2) a", doc).attr("href"); - - currentChapter = $("#select_chapter option:selected", doc).text(); - currentChapterURL = currentMangaURL + "chapter-" + $("#select_chapter option:selected", doc).val() + "/"; - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL); */ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var currentMangaURL = "http://mangable.com" + $("#breadcrumbs li:nth-child(2) a", doc).attr("href"), - currentChapterURL = currentMangaURL + "chapter-" + $("#select_chapter option:selected", doc).val() + "/"; - - var res = []; - $("#select_page select option", doc).each( - function(index){ - res[index] = currentChapterURL + $(this).val() + "/"; - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //$("div > iframe", doc).each(function(index){$(this).parent().remove()}); - $("iframe", doc).remove(); - $("#set1", doc).remove(); - $("#image_box td div").remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scansAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#image_box #image", doc).size() > 0); - }, - - //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. - $("#image_box td a", doc).remove(); - $("#image_box td > img", doc).remove(); - $("#chapter_choose_container", doc).remove(); - console.log("Sizeeee : " + $("#image_box td", doc).size()); - $("
").appendTo($("#image_box td", doc)); - $(".scansAMR", doc).after($("")); - $(".scansAMR", doc).before($("")); - $(".navAMR", doc).css("text-align", "center"); - $(".scansAMR", doc).css("background-color", "black"); - $(".scansAMR", doc).css("padding-top", "10px"); - $(".scansAMR", doc).css("padding-bottom", "10px"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = $("#image_box #image", div).attr("src"); - - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var currentMangaURL = "http://mangable.com" + $("#breadcrumbs li:nth-child(2) a", doc).attr("href"); - - $("#select_chapter option", doc).each(function(index) { - $(this).val(currentMangaURL + "chapter-" + $(this).val() + "/"); - }); - - return $("#select_chapter", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var Mangable = { + //Name of the mirror + mirrorName : "Mangable", + //True if the mirror can list all of its mangas. + canListFullMangas : false, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/mangable.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("mangable.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://mangable.com/search/?series_name=" + search + "&submit=Search", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#comprehensive_list li .col1 > a:first-child", div).each(function(index) { + var tit = $(this).text(); + res[res.length] = [tit, "http://mangable.com" + $(this).attr("href")]; + }); + callback("Mangable", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#newlist li a:first-child", div).each(function(index) { + var tit = $(".audi b", $(this)).text(); + tit = tit.replace(mangaName, "").trim(); + res[res.length] = [tit, $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("#breadcrumbs li:nth-child(2) a", doc).text(); + currentMangaURL = "http://mangable.com" + $("#breadcrumbs li:nth-child(2) a", doc).attr("href"); + currentChapter = $("#select_chapter option:selected", doc).text(); + currentChapterURL = currentMangaURL + "chapter-" + $("#select_chapter option:selected", doc).val() + "/"; + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL); */ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var currentMangaURL = "http://mangable.com" + $("#breadcrumbs li:nth-child(2) a", doc).attr("href"), + currentChapterURL = currentMangaURL + "chapter-" + $("#select_chapter option:selected", doc).val() + "/"; + var res = []; + $("#select_page select option", doc).each( + function(index){ + res[index] = currentChapterURL + $(this).val() + "/"; + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //$("div > iframe", doc).each(function(index){$(this).parent().remove()}); + $("iframe", doc).remove(); + $("#set1", doc).remove(); + $("#image_box td div").remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scansAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#image_box #image", doc).size() > 0); + }, + //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. + $("#image_box td a", doc).remove(); + $("#image_box td > img", doc).remove(); + $("#chapter_choose_container", doc).remove(); + console.log("Sizeeee : " + $("#image_box td", doc).size()); + $("
").appendTo($("#image_box td", doc)); + $(".scansAMR", doc).after($("")); + $(".scansAMR", doc).before($("")); + $(".navAMR", doc).css("text-align", "center"); + $(".scansAMR", doc).css("background-color", "black"); + $(".scansAMR", doc).css("padding-top", "10px"); + $(".scansAMR", doc).css("padding-bottom", "10px"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = $("#image_box #image", div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var currentMangaURL = "http://mangable.com" + $("#breadcrumbs li:nth-child(2) a", doc).attr("href"); + $("#select_chapter option", doc).each(function(index) { + $(this).val(currentMangaURL + "chapter-" + $(this).val() + "/"); + }); + return $("#select_chapter", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Mangable", Mangable); diff --git a/Mangacurse.js b/Mangacurse.js index 5faaf8c..e0ef67f 100644 --- a/Mangacurse.js +++ b/Mangacurse.js @@ -1,230 +1,201 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) Enter here your copyright mention... // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -//This class is an example of manga site following implementation for All Manga Reader. -//To test this class, just modify the json variable in mgEntry.js. -//If your implementation works and has been fully tested, send it to me with an -//icon (png with transparency file, 16x16) for your mirror -//at pl dot duhoux (at) gmail dot com. I will add it in the extension. -//If you have problems implementing your mirror, send me a mail... i will be glad to help you... - -//CHANGE here the classname -var Mangacurse = { - //CHANGE : Name of the mirror - mirrorName : "Mangacurse", - //CHANGE : True if the mirror can list all of its mangas. - canListFullMangas : true, - //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) - mirrorIcon : "img/mangacurse.png", - languages: "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("mangacurse.info") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - //CHANGE URL HERE - url: "http://mangacurse.info/reader/reader/list/", - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $('.list.series > .group > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback("Mangacurse", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - //CHANGE URL HERE - url: urlManga, - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $('.list > .element > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback(res, obj); - } - }); - }, - - /******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). - ********************************************************************************************************/ - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - var res = []; - eval($('body', doc).html().match(/var pages = .*\n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".ads", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - return $('#page', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) - //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return (curUrl.search('mangacurse.info/reader/reader/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans : function(doc, curUrl) { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function() { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - //DO ANYTHING ELSE YOU NEED - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) Enter here your copyright mention... // +// // +/////////////////////////////////////////////////////////////////////////////*/ +//This class is an example of manga site following implementation for All Manga Reader. +//To test this class, just modify the json variable in mgEntry.js. +//If your implementation works and has been fully tested, send it to me with an +//icon (png with transparency file, 16x16) for your mirror +//at pl dot duhoux (at) gmail dot com. I will add it in the extension. +//If you have problems implementing your mirror, send me a mail... i will be glad to help you... +//CHANGE here the classname +var Mangacurse = { + //CHANGE : Name of the mirror + mirrorName : "Mangacurse", + //CHANGE : True if the mirror can list all of its mangas. + canListFullMangas : true, + //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) + mirrorIcon : "img/mangacurse.png", + languages: "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("mangacurse.info") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + //CHANGE URL HERE + url: "http://mangacurse.info/reader/reader/list/", + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list.series > .group > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Mangacurse", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + //CHANGE URL HERE + url: urlManga, + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + /******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). + ********************************************************************************************************/ + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + var res = []; + eval($('body', doc).html().match(/var pages = .*\n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".ads", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + return $('#page', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) + //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return (curUrl.search('mangacurse.info/reader/reader/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans : function(doc, curUrl) { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function() { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + //DO ANYTHING ELSE YOU NEED + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Mangacurse", Mangacurse); diff --git a/Mangaholic.js b/Mangaholic.js index f9accdc..43bdc09 100644 --- a/Mangaholic.js +++ b/Mangaholic.js @@ -1,136 +1,135 @@ -var Mangaholic = { - mirrorName : "Mangaholic", - canListFullMangas : false, - mirrorIcon : "img/Mangaholic.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("mangaholic.tk/slide") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://mangaholic.tk/slide/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Mangaholic", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('mangaholic.tk/slide/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - }, +var Mangaholic = { + mirrorName : "Mangaholic", + canListFullMangas : false, + mirrorIcon : "img/Mangaholic.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("mangaholic.tk/slide") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://mangaholic.tk/slide/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Mangaholic", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('mangaholic.tk/slide/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Mangaholic", Mangaholic); diff --git a/Mangajoy.js b/Mangajoy.js index 41e9deb..8defd21 100644 --- a/Mangajoy.js +++ b/Mangajoy.js @@ -1,183 +1,182 @@ -var Mangajoy = { - mirrorName: "Mangajoy", - canListFullMangas: false, - mirrorIcon: "img/mangajoy.png", - languages: "en", - isMe: function(url) - { - "use strict"; - return (url.match(/^http:\/\/(www\.)?mangajoy\.com/gi) !== null); - }, - getMangaList: function(search, callback) - { - "use strict"; - $.ajax( - { - url: "http://mangajoy.com/manga-list/advanced-search/", - type: "POST", - data: - { - cbo_wpm_pag_mng_sch_nme: 0, - txt_wpm_pag_mng_sch_nme: search, - cmd_wpm_pag_mng_sch_sbm: "Search" - }, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - // Limited to the first page of results, else a wide crazy search like 'a' would - // return more than a thousand pages of results. - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse.replace(/ 0; i -= 1) - { - res.push(href + i + "/"); - } - res.reverse(); - return res; - }, - removeBanners: function(doc, curUrl) - { - return null; - }, - whereDoIWriteScans: function(doc, curUrl) - { - "use strict"; - return $('.imgAMR', doc); - }, - whereDoIWriteNavigation: function(doc, curUrl) - { - "use strict"; - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage: function(doc, curUrl) - { - "use strict"; - return ($(".wpm_nav_rdr select", doc).length > 0); - }, - doSomethingBeforeWritingScans: function(doc, curUrl) - { - "use strict"; - $(".wpm_pag", doc).empty(); - $(".wpm_pag", doc).append($("")); - $(".wpm_pag", doc).append($("
")); - $(".wpm_pag", doc).append($("")); - $(".navAMR", doc).css("text-align", "center"); - }, - nextChapterUrl: function(select, doc, curUrl) - { - "use strict"; - if ($(select, doc).children("option:selected").prev().size() != 0) { - return $(select, doc).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl: function(select, doc, curUrl) - { - "use strict"; - if ($(select, doc).children("option:selected").next().size() !== 0) { - return $(select, doc).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - "use strict"; - $.ajax( - { - url: urlImg, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - $(image).attr("src", $(".prw img", div).attr("src")); - } - }); - }, - isImageInOneCol: function(img, doc, curUrl) - { - "use strict"; - return false; - }, - getMangaSelectFromPage: function(doc, curUrl) - { - "use strict"; - var chapterSelect = $($(".wpm_nav_rdr select", doc)[0]), - mangaUrl = chapterSelect.attr('onchange').toString().match(/location\.href='([^']+)'/)[1]; - $("option", chapterSelect).each(function(index) - { - $(this).val(mangaUrl + $(this).val() + "/") - }); - return chapterSelect; - }, - doAfterMangaLoaded: function(doc, curUrl) - { - "use strict"; - return null; - } +var Mangajoy = { + mirrorName: "Mangajoy", + canListFullMangas: false, + mirrorIcon: "img/mangajoy.png", + languages: "en", + isMe: function(url) + { + "use strict"; + return (url.match(/^http:\/\/(www\.)?mangajoy\.com/gi) !== null); + }, + getMangaList: function(search, callback) + { + "use strict"; + $.ajax( + { + url: "http://mangajoy.com/manga-list/advanced-search/", + type: "POST", + data: + { + cbo_wpm_pag_mng_sch_nme: 0, + txt_wpm_pag_mng_sch_nme: search, + cmd_wpm_pag_mng_sch_sbm: "Search" + }, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + // Limited to the first page of results, else a wide crazy search like 'a' would + // return more than a thousand pages of results. + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse.replace(/ 0; i -= 1) + { + res.push(href + i + "/"); + } + res.reverse(); + return res; + }, + removeBanners: function(doc, curUrl) + { + return null; + }, + whereDoIWriteScans: function(doc, curUrl) + { + "use strict"; + return $('.imgAMR', doc); + }, + whereDoIWriteNavigation: function(doc, curUrl) + { + "use strict"; + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage: function(doc, curUrl) + { + "use strict"; + return ($(".wpm_nav_rdr select", doc).length > 0); + }, + doSomethingBeforeWritingScans: function(doc, curUrl) + { + "use strict"; + $(".wpm_pag", doc).empty(); + $(".wpm_pag", doc).append($("")); + $(".wpm_pag", doc).append($("
")); + $(".wpm_pag", doc).append($("")); + $(".navAMR", doc).css("text-align", "center"); + }, + nextChapterUrl: function(select, doc, curUrl) + { + "use strict"; + if ($(select, doc).children("option:selected").prev().size() != 0) { + return $(select, doc).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl: function(select, doc, curUrl) + { + "use strict"; + if ($(select, doc).children("option:selected").next().size() !== 0) { + return $(select, doc).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + "use strict"; + $.ajax( + { + url: urlImg, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + $(image).attr("src", $(".prw img", div).attr("src")); + } + }); + }, + isImageInOneCol: function(img, doc, curUrl) + { + "use strict"; + return false; + }, + getMangaSelectFromPage: function(doc, curUrl) + { + "use strict"; + var chapterSelect = $($(".wpm_nav_rdr select", doc)[0]), + mangaUrl = chapterSelect.attr('onchange').toString().match(/location\.href='([^']+)'/)[1]; + $("option", chapterSelect).each(function(index) + { + $(this).val(mangaUrl + $(this).val() + "/") + }); + return chapterSelect; + }, + doAfterMangaLoaded: function(doc, curUrl) + { + "use strict"; + return null; + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Mangajoy", Mangajoy); diff --git a/MangasProject.js b/MangasProject.js index 17b4605..d8b18ec 100644 --- a/MangasProject.js +++ b/MangasProject.js @@ -1,286 +1,260 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -function parseToLink(str) -{ - str = str.replace(/[ .]/g,"-").replace(/\//g,""); - return str; -} - -var MangasProject = -{ - mirrorName: "Mangas Project", - canListFullMangas: true, - mirrorIcon: "img/mangasproject.png", - languages: "pt", - - //Return true if the url corresponds to the mirror - isMe: function(url) - { - return (url.indexOf("mangas.xpg.com.br/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://mangas.xpg.com.br/includes/getSeriesList.php", - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var obj = JSON.parse(objResponse).All; - var res = []; - for (var j = 0; j < obj.length; j++) - { - var url = "http://mangas.xpg.com.br/Manga/"+obj[j].seriesId+"-"+parseToLink(obj[j].seriesName); - res[res.length] = [obj[j].seriesName, url]; - } - callback("Mangas Project", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - var pos = urlManga.lastIndexOf("/"); - var poss = urlManga.indexOf("-", pos); - var id = urlManga.substring(pos + 1, poss); - $.ajax( - { - url: "http://mangas.xpg.com.br/includes/getChaptersList.php?series=" + id, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var objR = JSON.parse(objResponse)["1"]; - - var res = []; - if (objR != undefined) - { - for (var j = 0; j < objR.length; j++) - { - var name = objR[j].chapValue + " " + objR[j].chapName; - for (var i = 0; i < objR[j].releases.length; i++) - { - res[res.length] = [name + " (" + objR[j].releases[i].groupName + ")", "http://mangas.xpg.com.br/reader/?rel=" + objR[j].releases[i].releaseId]; - } - } - } - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - currentChapterURL = $("meta[property='og:url']", doc).attr("content").replace("www.mangasproject", "mangas"); - - var pos = currentChapterURL.indexOf("?rel="); - var id = currentChapterURL.substring(pos + 5, currentChapterURL.length); - - $.ajax( - { - url: "http://mangas.xpg.com.br/reader/listPages.php", - type: 'POST', - data: - { - "rel": id, - "updating": 0 - }, - success: function(objResponse) - { - var obj = JSON.parse(objResponse); - - name = obj.series; - currentMangaURL = "http://mangas.xpg.com.br/Manga/"+obj.seriesId+"-"+parseToLink(obj.series); - currentChapter = obj.number + " " + obj.name + " (" + obj.group + ")"; - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - } - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - //This function runs in the DOM of the current consulted page. - getListImages: function(doc, curUrl) - { - var url = $("meta[property='og:url']", doc).attr("content"); - var pos = url.indexOf("?rel="); - var id = url.substring(pos + 5, url.length); - - var res = []; - $.ajax( - { - url: "http://mangas.xpg.com.br/reader/listPages.php", - type: 'POST', - data: - { - "rel": id - }, - async: false, - success: function(objResponse) - { - var obj = JSON.parse(objResponse); - if (obj != undefined) - { - var path = obj.path; - var i = 0; - while (obj.pages[i+'']) - { - var iurl = obj.pages[i+''].path; - if (iurl.indexOf("http") == 0) - { - res[res.length] = iurl; - } - else - { - res[res.length] = path + iurl; - } - i++; - } - } - } - }); - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - $("#banner", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteScans: function(doc, curUrl) - { - return $(".pageAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) - { - return ($("div.page", doc).size() > 0); - }, - - //This method is called before displaying full chapters in the page - //This function runs in the DOM of the current consulted page. - doSomethingBeforeWritingScans: function(doc, curUrl) - { - $("#viewer", doc).empty(); - $("").appendTo($("#viewer", doc)); - $("
").appendTo($("#viewer", doc)); - $("").appendTo($("#viewer", doc)); - $("#viewer", doc).css("padding-top", "10px"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol: function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +function parseToLink(str) +{ + str = str.replace(/[ .]/g,"-").replace(/\//g,""); + return str; +} +var MangasProject = +{ + mirrorName: "Mangas Project", + canListFullMangas: true, + mirrorIcon: "img/mangasproject.png", + languages: "pt", + //Return true if the url corresponds to the mirror + isMe: function(url) + { + return (url.indexOf("mangas.xpg.com.br/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://mangas.xpg.com.br/includes/getSeriesList.php", + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var obj = JSON.parse(objResponse).All; + var res = []; + for (var j = 0; j < obj.length; j++) + { + var url = "http://mangas.xpg.com.br/Manga/"+obj[j].seriesId+"-"+parseToLink(obj[j].seriesName); + res[res.length] = [obj[j].seriesName, url]; + } + callback("Mangas Project", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + var pos = urlManga.lastIndexOf("/"); + var poss = urlManga.indexOf("-", pos); + var id = urlManga.substring(pos + 1, poss); + $.ajax( + { + url: "http://mangas.xpg.com.br/includes/getChaptersList.php?series=" + id, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var objR = JSON.parse(objResponse)["1"]; + var res = []; + if (objR != undefined) + { + for (var j = 0; j < objR.length; j++) + { + var name = objR[j].chapValue + " " + objR[j].chapName; + for (var i = 0; i < objR[j].releases.length; i++) + { + res[res.length] = [name + " (" + objR[j].releases[i].groupName + ")", "http://mangas.xpg.com.br/reader/?rel=" + objR[j].releases[i].releaseId]; + } + } + } + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + currentChapterURL = $("meta[property='og:url']", doc).attr("content").replace("www.mangasproject", "mangas"); + var pos = currentChapterURL.indexOf("?rel="); + var id = currentChapterURL.substring(pos + 5, currentChapterURL.length); + $.ajax( + { + url: "http://mangas.xpg.com.br/reader/listPages.php", + type: 'POST', + data: + { + "rel": id, + "updating": 0 + }, + success: function(objResponse) + { + var obj = JSON.parse(objResponse); + name = obj.series; + currentMangaURL = "http://mangas.xpg.com.br/Manga/"+obj.seriesId+"-"+parseToLink(obj.series); + currentChapter = obj.number + " " + obj.name + " (" + obj.group + ")"; + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + } + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + //This function runs in the DOM of the current consulted page. + getListImages: function(doc, curUrl) + { + var url = $("meta[property='og:url']", doc).attr("content"); + var pos = url.indexOf("?rel="); + var id = url.substring(pos + 5, url.length); + var res = []; + $.ajax( + { + url: "http://mangas.xpg.com.br/reader/listPages.php", + type: 'POST', + data: + { + "rel": id + }, + async: false, + success: function(objResponse) + { + var obj = JSON.parse(objResponse); + if (obj != undefined) + { + var path = obj.path; + var i = 0; + while (obj.pages[i+'']) + { + var iurl = obj.pages[i+''].path; + if (iurl.indexOf("http") == 0) + { + res[res.length] = iurl; + } + else + { + res[res.length] = path + iurl; + } + i++; + } + } + } + }); + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + $("#banner", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteScans: function(doc, curUrl) + { + return $(".pageAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) + { + return ($("div.page", doc).size() > 0); + }, + //This method is called before displaying full chapters in the page + //This function runs in the DOM of the current consulted page. + doSomethingBeforeWritingScans: function(doc, curUrl) + { + $("#viewer", doc).empty(); + $("").appendTo($("#viewer", doc)); + $("
").appendTo($("#viewer", doc)); + $("").appendTo($("#viewer", doc)); + $("#viewer", doc).css("padding-top", "10px"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol: function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Mangas Project", MangasProject); diff --git a/MenudoFansub.js b/MenudoFansub.js index 8d7c734..b62d10c 100644 --- a/MenudoFansub.js +++ b/MenudoFansub.js @@ -1,136 +1,135 @@ -var MenudoFansub = { - mirrorName : "MenudoFansub", - canListFullMangas : false, - mirrorIcon : "img/menudofansub.png", - languages : "es", - isMe : function (url) { - return (url.indexOf("menudo-fansub.com/slide/") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://menudo-fansub.com/slide/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("MenudoFansub", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('menudo-fansub.com/slide/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - }, +var MenudoFansub = { + mirrorName : "MenudoFansub", + canListFullMangas : false, + mirrorIcon : "img/menudofansub.png", + languages : "es", + isMe : function (url) { + return (url.indexOf("menudo-fansub.com/slide/") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://menudo-fansub.com/slide/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("MenudoFansub", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('menudo-fansub.com/slide/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("MenudoFansub", MenudoFansub); diff --git a/MudaScantrad.js b/MudaScantrad.js index dc583ba..1ed9675 100644 --- a/MudaScantrad.js +++ b/MudaScantrad.js @@ -1,136 +1,135 @@ -var MudaScantrad = { - mirrorName : "Muda Scantrad", - canListFullMangas : false, - mirrorIcon : "img/generic.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("www.mudascantrad.com/MudaReader") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://www.mudascantrad.com/MudaReader/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Muda Scantrad", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement("div"); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('www.mudascantrad.com/MudaReader/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - } +var MudaScantrad = { + mirrorName : "Muda Scantrad", + canListFullMangas : false, + mirrorIcon : "img/generic.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("www.mudascantrad.com/MudaReader") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://www.mudascantrad.com/MudaReader/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Muda Scantrad", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement("div"); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('www.mudascantrad.com/MudaReader/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Muda Scantrad", MudaScantrad); diff --git a/Otakuyo.js b/Otakuyo.js index 1778b51..2b668ab 100644 --- a/Otakuyo.js +++ b/Otakuyo.js @@ -1,227 +1,204 @@ -var Otakuyo = -{ - mirrorName: "Otakuyo!!!", - canListFullMangas: false, - mirrorIcon: "img/otakuyo.png", - languages: "pt", - - //Return true if the url corresponds to the mirror - isMe: function(url) - { - return (url.indexOf("leitor.otakuyo.com") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://leitor.otakuyo.com/reader/search/", - type: 'POST', - data: - { - 'search': search - }, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('.list > .group > .title > a', div).each(function(index) - { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - - callback("Otakuyo!!!", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('.list > .element > .title > a', div).each(function(index) - { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages: function(doc, curUrl) - { - var res = []; - eval($('body', doc).html().match(/var pages = .*\n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - // No ads here - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans: function(doc, curUrl) - { - return $('#page', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return (curUrl.search('leitor.otakuyo.com/reader/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans: function(doc, curUrl) - { - if (typeof doc.createElement == 'function') - { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR", doc).css("text-align", "center"); - $(window).resize(function() - { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol : function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - } +var Otakuyo = +{ + mirrorName: "Otakuyo!!!", + canListFullMangas: false, + mirrorIcon: "img/otakuyo.png", + languages: "pt", + //Return true if the url corresponds to the mirror + isMe: function(url) + { + return (url.indexOf("leitor.otakuyo.com") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://leitor.otakuyo.com/reader/search/", + type: 'POST', + data: + { + 'search': search + }, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function(index) + { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback("Otakuyo!!!", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function(index) + { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages: function(doc, curUrl) + { + var res = []; + eval($('body', doc).html().match(/var pages = .*\n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + // No ads here + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans: function(doc, curUrl) + { + return $('#page', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return (curUrl.search('leitor.otakuyo.com/reader/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans: function(doc, curUrl) + { + if (typeof doc.createElement == 'function') + { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR", doc).css("text-align", "center"); + $(window).resize(function() + { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol : function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Otakuyo!!!", Otakuyo); diff --git a/OurManga.js b/OurManga.js index f8f86e1..cf75462 100644 --- a/OurManga.js +++ b/OurManga.js @@ -1,154 +1,153 @@ -var OurManga = { - mirrorName: "Our Manga", - canListFullMangas: false, - mirrorIcon: "img/ourmanga.png", - languages: "en", - isMe: function (e) { - return e.indexOf("ourmanga.com/") != -1 - }, - getMangaList: function (e, t) { - $.ajax({ - url: "http://www.ourmanga.com/directory/", - beforeSend: function (e) { - e.setRequestHeader("Cache-Control", "no-cache"); - e.setRequestHeader("Pragma", "no-cache") - }, - success: function (e) { - var n = document.createElement("div"); - n.innerHTML = e; - var r = []; - $("div.m_s_title a", n).each(function (e) { - if (e != 0 && $("a", $(this).parent()).size() == 1 && $(this).attr("href") != undefined && $(this).attr("href").trim() != "http://www.ourmanga.com/") { - r[r.length] = [$(this).text(), $(this).attr("href")] - } - }); - t("Our Manga", r) - } - }) - }, - getListChaps: function (e, t, n, r) { - $.ajax({ - url: e, - beforeSend: function (e) { - e.setRequestHeader("Cache-Control", "no-cache"); - e.setRequestHeader("Pragma", "no-cache") - }, - success: function (e) { - var t = document.createElement("div"); - t.innerHTML = e; - var i = []; - $(".manga_naruto_title a", t).each(function (e) { - if ($(this).parent().next().next().text().indexOf("Soon") == -1) { - i[i.length] = [$(this).text(), $(this).attr("href") + "/9001e"] - } - }); - r(i, n) - } - }) - }, - getInformationsFromCurrentPage: function (e, t, n) { - var r; - var i; - var s; - var o; - r = $(".inner_heading_left p", e).text().trim(); - i = $("select[name='chapter'] option:selected", e).text(); - var u = 0; - for (var a = 0; a < 4; a++) { - u = t.indexOf("/", u + 1) - } - o = t.substr(0, u + 1) + $("select[name='chapter'] option:selected", e).val() + "/9001e"; - s = t.substr(0, u + 1); - n({ - name: r, - currentChapter: i, - currentMangaURL: s, - currentChapterURL: o - }) - }, - getListImages: function (e, t) { - var n = []; - var r = 0; - for (var i = 0; i < 5; i++) { - r = t.indexOf("/", r + 1) - } - $("select[name='page'] option", e).each(function (e) { - n[n.length] = t.substr(0, r + 1) + $(this).val() - }); - return n - }, - removeBanners: function (e, t) { - $(".inner_banner", e).remove(); - $("#link_heading_banner", e).remove() - }, - whereDoIWriteScans: function (e, t) { - return $(".inner_full_view", e) - }, - whereDoIWriteNavigation: function (e, t) { - return $(".navAMR", e).add($(".inner_heading", e)) - }, - isCurrentPageAChapterPage: function (e, t) { - return $(".inner_full_view img", e).size() > 0 - }, - doSomethingBeforeWritingScans: function (e, t) { - $("#page").css("width", "auto"); - $("#inner_page").css("width", "auto"); - $("#inner_page").css("float", "none"); - $("#header").css("margin-left", "auto"); - $("#header").css("float", "none"); - $("#header").css("margin-right", "auto"); - $(".inner").css("width", "auto"); - $(".inner").css("float", "none"); - $(".inner div").css("width", "auto"); - $(".inner div").css("float", "none"); - $(".inner_heading", e).empty(); - $(".inner_full_view", e).empty(); - $(".inner_full_view", e).css("width", "100%"); - $(".inner_full_view", e).after($("")); - $(".navAMR", e).css("text-align", "center"); - $(".inner_heading", e).css("text-align", "center") - }, - nextChapterUrl: function (e, t, n) { - if ($(e).children("option:selected").next().size() != 0) { - return $(e).children("option:selected").next().val() - } - return null - }, - previousChapterUrl: function (e, t, n) { - if ($(e).children("option:selected").prev().size() != 0) { - return $(e).children("option:selected").prev().val() - } - return null - }, - getImageFromPageAndWrite: function (e, t, n, r) { - $.ajax({ - url: e, - success: function (e) { - var n = document.createElement("div"); - n.innerHTML = e; - var r = $(".inner_full_view img", n).attr("src"); - $(t).attr("src", r) - } - }) - }, - isImageInOneCol: function (e, t, n) { - return false - }, - getMangaSelectFromPage: function (e, t) { - var n = 0; - for (var r = 0; r < 4; r++) { - n = t.indexOf("/", n + 1) - } - $("select[name='chapter'] option", e).each(function (e) { - $(this).val(t.substr(0, n + 1) + $(this).val() + "/9001e") - }); - return $("select[name='chapter']", e) - }, - doAfterMangaLoaded: function (e, t) { - $("body > div:empty", e).remove() - } +var OurManga = { + mirrorName: "Our Manga", + canListFullMangas: false, + mirrorIcon: "img/ourmanga.png", + languages: "en", + isMe: function (e) { + return e.indexOf("ourmanga.com/") != -1 + }, + getMangaList: function (e, t) { + $.ajax({ + url: "http://www.ourmanga.com/directory/", + beforeSend: function (e) { + e.setRequestHeader("Cache-Control", "no-cache"); + e.setRequestHeader("Pragma", "no-cache") + }, + success: function (e) { + var n = document.createElement("div"); + n.innerHTML = e; + var r = []; + $("div.m_s_title a", n).each(function (e) { + if (e != 0 && $("a", $(this).parent()).size() == 1 && $(this).attr("href") != undefined && $(this).attr("href").trim() != "http://www.ourmanga.com/") { + r[r.length] = [$(this).text(), $(this).attr("href")] + } + }); + t("Our Manga", r) + } + }) + }, + getListChaps: function (e, t, n, r) { + $.ajax({ + url: e, + beforeSend: function (e) { + e.setRequestHeader("Cache-Control", "no-cache"); + e.setRequestHeader("Pragma", "no-cache") + }, + success: function (e) { + var t = document.createElement("div"); + t.innerHTML = e; + var i = []; + $(".manga_naruto_title a", t).each(function (e) { + if ($(this).parent().next().next().text().indexOf("Soon") == -1) { + i[i.length] = [$(this).text(), $(this).attr("href") + "/9001e"] + } + }); + r(i, n) + } + }) + }, + getInformationsFromCurrentPage: function (e, t, n) { + var r; + var i; + var s; + var o; + r = $(".inner_heading_left p", e).text().trim(); + i = $("select[name='chapter'] option:selected", e).text(); + var u = 0; + for (var a = 0; a < 4; a++) { + u = t.indexOf("/", u + 1) + } + o = t.substr(0, u + 1) + $("select[name='chapter'] option:selected", e).val() + "/9001e"; + s = t.substr(0, u + 1); + n({ + name: r, + currentChapter: i, + currentMangaURL: s, + currentChapterURL: o + }) + }, + getListImages: function (e, t) { + var n = []; + var r = 0; + for (var i = 0; i < 5; i++) { + r = t.indexOf("/", r + 1) + } + $("select[name='page'] option", e).each(function (e) { + n[n.length] = t.substr(0, r + 1) + $(this).val() + }); + return n + }, + removeBanners: function (e, t) { + $(".inner_banner", e).remove(); + $("#link_heading_banner", e).remove() + }, + whereDoIWriteScans: function (e, t) { + return $(".inner_full_view", e) + }, + whereDoIWriteNavigation: function (e, t) { + return $(".navAMR", e).add($(".inner_heading", e)) + }, + isCurrentPageAChapterPage: function (e, t) { + return $(".inner_full_view img", e).size() > 0 + }, + doSomethingBeforeWritingScans: function (e, t) { + $("#page").css("width", "auto"); + $("#inner_page").css("width", "auto"); + $("#inner_page").css("float", "none"); + $("#header").css("margin-left", "auto"); + $("#header").css("float", "none"); + $("#header").css("margin-right", "auto"); + $(".inner").css("width", "auto"); + $(".inner").css("float", "none"); + $(".inner div").css("width", "auto"); + $(".inner div").css("float", "none"); + $(".inner_heading", e).empty(); + $(".inner_full_view", e).empty(); + $(".inner_full_view", e).css("width", "100%"); + $(".inner_full_view", e).after($("")); + $(".navAMR", e).css("text-align", "center"); + $(".inner_heading", e).css("text-align", "center") + }, + nextChapterUrl: function (e, t, n) { + if ($(e).children("option:selected").next().size() != 0) { + return $(e).children("option:selected").next().val() + } + return null + }, + previousChapterUrl: function (e, t, n) { + if ($(e).children("option:selected").prev().size() != 0) { + return $(e).children("option:selected").prev().val() + } + return null + }, + getImageFromPageAndWrite: function (e, t, n, r) { + $.ajax({ + url: e, + success: function (e) { + var n = document.createElement("div"); + n.innerHTML = e; + var r = $(".inner_full_view img", n).attr("src"); + $(t).attr("src", r) + } + }) + }, + isImageInOneCol: function (e, t, n) { + return false + }, + getMangaSelectFromPage: function (e, t) { + var n = 0; + for (var r = 0; r < 4; r++) { + n = t.indexOf("/", n + 1) + } + $("select[name='chapter'] option", e).each(function (e) { + $(this).val(t.substr(0, n + 1) + $(this).val() + "/9001e") + }); + return $("select[name='chapter']", e) + }, + doAfterMangaLoaded: function (e, t) { + $("body > div:empty", e).remove() + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Our Manga", OurManga); diff --git a/PunchMangas.js b/PunchMangas.js index 183ee04..41e1015 100644 --- a/PunchMangas.js +++ b/PunchMangas.js @@ -1,234 +1,197 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var PunchMangas = { - //Name of the mirror - mirrorName : "PunchMangas", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/punchmangas.png", - //Languages of scans for the mirror - languages : "pt", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("punchmangas.com.br/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.punchmangas.com.br/lmangas/Todos/titulo/c", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - //console.log($("#listagemMangas li", div).size()); - $("#listagemMangas > ul > li", div).each(function(index) { - //console.log($($("a", $(this))[0]).contents().size()); - res[res.length] = [$($("a", $(this))[0]).contents().filter(function(){ return this.nodeType == 3; }).text(), $("#lLancs a", $(this)).attr("href")]; - }); - callback("PunchMangas", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $("#listagemCaps > ul > li", div).each(function(index) { - res[res.length] = [$($("a", $(this))[0]).contents().filter(function(){ return this.nodeType == 3; }).text(), $("#menuOpcoes a", $(this)).attr("href")]; - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - var a = $("#paginaCaminho a[href^='http://www.punchmangas.com.br/listagem/']", doc); - name = a.text(); - currentMangaURL = a.attr("href"); - - currentChapter = $("#listaDeCaps option:selected", doc).text(); - currentChapterURL = $("#listaDeCaps option:selected", doc).val(); - - - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - var base; - - $("script", doc).each(function(index) { - if ($(this).text().indexOf("jQuery.preLoadImages(\"") != -1) { - var posdeb = $(this).text().indexOf("jQuery.preLoadImages(\""); - var posfin = $(this).text().indexOf("\"", posdeb + 23); - - base = $(this).text().substring(posdeb + 22, posfin); - } - }); - $("#listaDePaginas option", doc).each(function(index) { - var num = $(this).val(); - if (parseInt(num, 10) < 10) num = "0" + num; - res[res.length] = base + num + ".jpg"; - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#imagemPagina", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#controles", doc).add($("#leitorRodape", doc)); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#imagemAtual", doc).size() > 0); - }, - - //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. - $("#controles", doc).empty(); - $("#leitorTopo", doc).css("height", "auto"); - - $("#leitorRodape", doc).empty(); - $("#imagemPagina", doc).empty(); - $("#imagemPagina", doc).css("background-color", "black"); - $("#imagemPagina", doc).css("padding-top", "10px"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $( image ).attr( "src", urlImg ); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#listaDeCaps", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var PunchMangas = { + //Name of the mirror + mirrorName : "PunchMangas", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/punchmangas.png", + //Languages of scans for the mirror + languages : "pt", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("punchmangas.com.br/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.punchmangas.com.br/lmangas/Todos/titulo/c", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + //console.log($("#listagemMangas li", div).size()); + $("#listagemMangas > ul > li", div).each(function(index) { + //console.log($($("a", $(this))[0]).contents().size()); + res[res.length] = [$($("a", $(this))[0]).contents().filter(function(){ return this.nodeType == 3; }).text(), $("#lLancs a", $(this)).attr("href")]; + }); + callback("PunchMangas", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#listagemCaps > ul > li", div).each(function(index) { + res[res.length] = [$($("a", $(this))[0]).contents().filter(function(){ return this.nodeType == 3; }).text(), $("#menuOpcoes a", $(this)).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + var a = $("#paginaCaminho a[href^='http://www.punchmangas.com.br/listagem/']", doc); + name = a.text(); + currentMangaURL = a.attr("href"); + currentChapter = $("#listaDeCaps option:selected", doc).text(); + currentChapterURL = $("#listaDeCaps option:selected", doc).val(); + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + var base; + $("script", doc).each(function(index) { + if ($(this).text().indexOf("jQuery.preLoadImages(\"") != -1) { + var posdeb = $(this).text().indexOf("jQuery.preLoadImages(\""); + var posfin = $(this).text().indexOf("\"", posdeb + 23); + base = $(this).text().substring(posdeb + 22, posfin); + } + }); + $("#listaDePaginas option", doc).each(function(index) { + var num = $(this).val(); + if (parseInt(num, 10) < 10) num = "0" + num; + res[res.length] = base + num + ".jpg"; + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#imagemPagina", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#controles", doc).add($("#leitorRodape", doc)); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#imagemAtual", doc).size() > 0); + }, + //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. + $("#controles", doc).empty(); + $("#leitorTopo", doc).css("height", "auto"); + $("#leitorRodape", doc).empty(); + $("#imagemPagina", doc).empty(); + $("#imagemPagina", doc).css("background-color", "black"); + $("#imagemPagina", doc).css("padding-top", "10px"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $( image ).attr( "src", urlImg ); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#listaDeCaps", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("PunchMangas", PunchMangas); diff --git a/Pururin.js b/Pururin.js index 617c53a..ffeb538 100644 --- a/Pururin.js +++ b/Pururin.js @@ -1,227 +1,204 @@ -var Pururin = -{ - mirrorName: "Pururin", - canListFullMangas: false, - mirrorIcon: "img/pururin.png", - languages: "pt", - - //Return true if the url corresponds to the mirror - isMe: function(url) - { - return (url.indexOf("pururin.com.br/leitor/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList: function(search, callback) - { - $.ajax( - { - url: "http://pururin.com.br/leitor/reader/search/", - type: 'POST', - data: - { - 'search': search - }, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('.list > .group > .title > a', div).each(function(index) - { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - - callback("Pururin", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps: function(urlManga, mangaName, obj, callback) - { - $.ajax( - { - url: urlManga, - beforeSend: function(xhr) - { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function(objResponse) - { - var div = document.createElement("div"); - div.innerHTML = objResponse; - - var res = []; - $('td.p1 a', div).each(function(index) - { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - //This function runs in the DOM of the current consulted page. - getInformationsFromCurrentPage: function(doc, curUrl, callback) - { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback( - { - "name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages: function(doc, curUrl) - { - var res = []; - eval($('body', doc).html().match(/var pages = .*\n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - //Remove the banners from the current page - //This function runs in the DOM of the current consulted page. - removeBanners: function(doc, curUrl) - { - // No ads here - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans: function(doc, curUrl) - { - return $('#page', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - //This function runs in the DOM of the current consulted page. - whereDoIWriteNavigation: function(doc, curUrl) - { - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage: function(doc, curUrl) - { - return (curUrl.search('pururin.com.br/leitor/reader/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans: function(doc, curUrl) - { - if (typeof doc.createElement == 'function') - { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR", doc).css("text-align", "center"); - $(window).resize(function() - { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - nextChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").prev().size() != 0) - { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - //This function runs in the DOM of the current consulted page. - previousChapterUrl: function(select, doc, curUrl) - { - if ($(select).children("option:selected").next().size() != 0) - { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - //This function runs in the DOM of the current consulted page. - getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) - { - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - //This function runs in the DOM of the current consulted page. - isImageInOneCol : function(img, doc, curUrl) - { - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - //This function runs in the DOM of the current consulted page. - getMangaSelectFromPage: function(doc, curUrl) - { - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - //This function runs in the DOM of the current consulted page. - doAfterMangaLoaded: function(doc, curUrl) - { - $("body > div:empty", doc).remove(); - } +var Pururin = +{ + mirrorName: "Pururin", + canListFullMangas: false, + mirrorIcon: "img/pururin.png", + languages: "pt", + //Return true if the url corresponds to the mirror + isMe: function(url) + { + return (url.indexOf("pururin.com.br/leitor/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList: function(search, callback) + { + $.ajax( + { + url: "http://pururin.com.br/leitor/reader/search/", + type: 'POST', + data: + { + 'search': search + }, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function(index) + { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback("Pururin", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps: function(urlManga, mangaName, obj, callback) + { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) + { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function(objResponse) + { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('td.p1 a', div).each(function(index) + { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + //This function runs in the DOM of the current consulted page. + getInformationsFromCurrentPage: function(doc, curUrl, callback) + { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback( + { + "name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages: function(doc, curUrl) + { + var res = []; + eval($('body', doc).html().match(/var pages = .*\n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + //Remove the banners from the current page + //This function runs in the DOM of the current consulted page. + removeBanners: function(doc, curUrl) + { + // No ads here + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans: function(doc, curUrl) + { + return $('#page', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + //This function runs in the DOM of the current consulted page. + whereDoIWriteNavigation: function(doc, curUrl) + { + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage: function(doc, curUrl) + { + return (curUrl.search('pururin.com.br/leitor/reader/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans: function(doc, curUrl) + { + if (typeof doc.createElement == 'function') + { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR", doc).css("text-align", "center"); + $(window).resize(function() + { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + nextChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").prev().size() != 0) + { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + //This function runs in the DOM of the current consulted page. + previousChapterUrl: function(select, doc, curUrl) + { + if ($(select).children("option:selected").next().size() != 0) + { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + //This function runs in the DOM of the current consulted page. + getImageFromPageAndWrite: function(urlImg, image, doc, curUrl) + { + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + //This function runs in the DOM of the current consulted page. + isImageInOneCol : function(img, doc, curUrl) + { + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + //This function runs in the DOM of the current consulted page. + getMangaSelectFromPage: function(doc, curUrl) + { + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + //This function runs in the DOM of the current consulted page. + doAfterMangaLoaded: function(doc, curUrl) + { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Pururin", Pururin); diff --git a/ReadManga.js b/ReadManga.js index e95b852..0c2a68a 100644 --- a/ReadManga.js +++ b/ReadManga.js @@ -1,143 +1,142 @@ -var ReadManga = { - mirrorName : "ReadManga", - canListFullMangas : false, - mirrorIcon : "img/readmanga.png", - languages : "ru", - isMe : function (url) { - return (url.indexOf("readmanga.me/") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://readmanga.me/search", - type : 'POST', - data : { - q : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $("#mangaResults td a:first-child", div).each(function (index) { - var tit = $($(this).contents()[0]).text(); - titsp = tit.split("|"); - res[res.length] = [titsp[0].trim(), "http://readmanga.me" + $(this).attr("href")]; - }); - callback("ReadManga", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga + "?mature=1", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - var mng_nm = (urlManga.split('/')).pop(); - $("div.expandable td > a", div).each(function (index) { - var str = $(this).attr("href"); - str = str.split('/')[1]; - if (str == mng_nm) { - res[res.length] = [$($(this).contents()[0]).text(), "http://readmanga.me" + $(this).attr("href")]; - } - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $($("#mangaBox h1 a:first-child", doc).contents()[0]).text(); - var nameurl = "http://readmanga.me" + $("#mangaBox h1 a:first-child", doc).attr("href"); - var curChapName = $("#chapterSelectorSelect:first option:selected", doc).text(); - var chapurl = "http://readmanga.me" + $("#chapterSelectorSelect:first option:selected", doc).val(); - callback({ - "name" : name, - "currentChapter" : curChapName, - "currentMangaURL" : nameurl, - "currentChapterURL" : chapurl - }); - }, - getListImages : function (doc, curUrl2) { - var res = []; - var dir = ""; - var scansstr = ""; - $("script", doc).each(function (index) { - if ($(this).text().indexOf("var pictures = [{") != -1) { - var possc = $(this).text().indexOf("var pictures = [{") + 12; - var finsc = $(this).text().indexOf("]", possc); - scansstr = $(this).text().substring(possc, finsc); - var pos = scansstr.indexOf('"'); - while (pos != -1) { - var end = scansstr.indexOf('"', pos + 1); - res[res.length] = scansstr.substring(pos + 1, end); - pos = scansstr.indexOf('"', end + 1); - } - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".baner", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $("#mangaBox", doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return ($("img#mangaPicture", doc).size() > 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $("#mangaBox", doc).prev().remove(); - $("#mangaBox", doc).empty(); - $(".footerControl", doc).remove(); - $("#mangaBox", doc).css("width", "100%"); - $("#mangaBox", doc).css("padding", "0"); - $("#mangaBox", doc).css("padding-top", "10px"); - $("#mangaBox", doc).css("padding-bottom", "10px"); - $("#mangaBox", doc).css("border", "0"); - $("#mangaBox", doc).css("background-color", "black"); - $("#mangaBox", doc).before($("")); - $("#mangaBox", doc).after($("")); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg) - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - $("#chapterSelectorSelect option", doc).each(function (index) { - $(this).val("http://readmanga.me" + $(this).val()); - }); - return $($("#chapterSelectorSelect", doc)[0]); - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - }, +var ReadManga = { + mirrorName : "ReadManga", + canListFullMangas : false, + mirrorIcon : "img/readmanga.png", + languages : "ru", + isMe : function (url) { + return (url.indexOf("readmanga.me/") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://readmanga.me/search", + type : 'POST', + data : { + q : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("#mangaResults td a:first-child", div).each(function (index) { + var tit = $($(this).contents()[0]).text(); + titsp = tit.split("|"); + res[res.length] = [titsp[0].trim(), "http://readmanga.me" + $(this).attr("href")]; + }); + callback("ReadManga", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga + "?mature=1", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + var mng_nm = (urlManga.split('/')).pop(); + $("div.expandable td > a", div).each(function (index) { + var str = $(this).attr("href"); + str = str.split('/')[1]; + if (str == mng_nm) { + res[res.length] = [$($(this).contents()[0]).text(), "http://readmanga.me" + $(this).attr("href")]; + } + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $($("#mangaBox h1 a:first-child", doc).contents()[0]).text(); + var nameurl = "http://readmanga.me" + $("#mangaBox h1 a:first-child", doc).attr("href"); + var curChapName = $("#chapterSelectorSelect:first option:selected", doc).text(); + var chapurl = "http://readmanga.me" + $("#chapterSelectorSelect:first option:selected", doc).val(); + callback({ + "name" : name, + "currentChapter" : curChapName, + "currentMangaURL" : nameurl, + "currentChapterURL" : chapurl + }); + }, + getListImages : function (doc, curUrl2) { + var res = []; + var dir = ""; + var scansstr = ""; + $("script", doc).each(function (index) { + if ($(this).text().indexOf("var pictures = [{") != -1) { + var possc = $(this).text().indexOf("var pictures = [{") + 12; + var finsc = $(this).text().indexOf("]", possc); + scansstr = $(this).text().substring(possc, finsc); + var pos = scansstr.indexOf('"'); + while (pos != -1) { + var end = scansstr.indexOf('"', pos + 1); + res[res.length] = scansstr.substring(pos + 1, end); + pos = scansstr.indexOf('"', end + 1); + } + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".baner", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $("#mangaBox", doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return ($("img#mangaPicture", doc).size() > 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $("#mangaBox", doc).prev().remove(); + $("#mangaBox", doc).empty(); + $(".footerControl", doc).remove(); + $("#mangaBox", doc).css("width", "100%"); + $("#mangaBox", doc).css("padding", "0"); + $("#mangaBox", doc).css("padding-top", "10px"); + $("#mangaBox", doc).css("padding-bottom", "10px"); + $("#mangaBox", doc).css("border", "0"); + $("#mangaBox", doc).css("background-color", "black"); + $("#mangaBox", doc).before($("")); + $("#mangaBox", doc).after($("")); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg) + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + $("#chapterSelectorSelect option", doc).each(function (index) { + $(this).val("http://readmanga.me" + $(this).val()); + }); + return $($("#chapterSelectorSelect", doc)[0]); + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("ReadManga", ReadManga); diff --git a/Redhawkscans.js b/Redhawkscans.js index 4faafc2..6be6615 100644 --- a/Redhawkscans.js +++ b/Redhawkscans.js @@ -1,137 +1,136 @@ -var Redhawkscans = { - mirrorName : "Redhawkscans", - canListFullMangas : false, - mirrorIcon : "img/redhawkscans.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("manga.redhawkscans.com/") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://manga.redhawkscans.com/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Redhawkscans", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - type : 'POST', - data : { - 'adult' : true - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement("div"); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads.banner.iframe", doc).remove(); - $(".ads.banner", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#pageAMR', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('manga.redhawkscans.com/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; - script.type = 'text/rocketscript'; - doc.body.appendChild(script); - } - $("#page", doc).before(""); - $("#page", doc).after(""); - $("#page", doc).css("max-width", "none"); - $("#page", doc).empty(); - $("#page", doc).attr('id', 'pageAMR'); - $(".navAMR").css("text-align", "center"); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var Redhawkscans = { + mirrorName : "Redhawkscans", + canListFullMangas : false, + mirrorIcon : "img/redhawkscans.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("manga.redhawkscans.com/") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://manga.redhawkscans.com/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Redhawkscans", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + type : 'POST', + data : { + 'adult' : true + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement("div"); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads.banner.iframe", doc).remove(); + $(".ads.banner", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#pageAMR', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('manga.redhawkscans.com/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; + script.type = 'text/rocketscript'; + doc.body.appendChild(script); + } + $("#page", doc).before(""); + $("#page", doc).after(""); + $("#page", doc).css("max-width", "none"); + $("#page", doc).empty(); + $("#page", doc).attr('id', 'pageAMR'); + $(".navAMR").css("text-align", "center"); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Redhawkscans", Redhawkscans); diff --git a/S2scans.js b/S2scans.js index bae4091..fcc20e9 100644 --- a/S2scans.js +++ b/S2scans.js @@ -1,145 +1,144 @@ -var S2scans = { - mirrorName : "S2scans", - canListFullMangas : false, - mirrorIcon : "img/S2scans.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("s2scanlations.com/online/") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://s2scanlations.com/online/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("S2scans", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - type : 'POST', - data : { - 'adult' : true - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded') - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) {}, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return ($("#content #page img.open", doc).length > 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.type = "text/javascript"; - script.onload = OnceLoaded; - script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; - script.innerText += "function OnceLoaded() {changePage = function(){};$(document).ready(function(){$(document).unbind('keydown');});}" - doc.body.appendChild(script); - function OnceLoaded() { - changePage = function(){}; - $(document).ready(function(){$(document).unbind('keydown');}); - } - } - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $('#page', doc).css("overflow", "visible"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR").css("text-align", "center"); - $(window).resize(function() { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var S2scans = { + mirrorName : "S2scans", + canListFullMangas : false, + mirrorIcon : "img/S2scans.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("s2scanlations.com/online/") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://s2scanlations.com/online/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("S2scans", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + type : 'POST', + data : { + 'adult' : true + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded') + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) {}, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return ($("#content #page img.open", doc).length > 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.type = "text/javascript"; + script.onload = OnceLoaded; + script.innerText = "changePage = function(){}; $(document).ready(function(){$(document).unbind('keydown');});"; + script.innerText += "function OnceLoaded() {changePage = function(){};$(document).ready(function(){$(document).unbind('keydown');});}" + doc.body.appendChild(script); + function OnceLoaded() { + changePage = function(){}; + $(document).ready(function(){$(document).unbind('keydown');}); + } + } + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $('#page', doc).css("overflow", "visible"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR").css("text-align", "center"); + $(window).resize(function() { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("S2scans", S2scans); diff --git a/SimpleScans.js b/SimpleScans.js index 204c8c3..27bfc16 100644 --- a/SimpleScans.js +++ b/SimpleScans.js @@ -1,134 +1,133 @@ -var SimpleScans = { - mirrorName: "Simple Scans", - canListFullMangas: false, - mirrorIcon: "img/simplescans.png", - languages: "en", - isMe: function (e) { - return e.indexOf("www.simple-scans.com/slide/") !== -1 - }, - getMangaList: function (e, t) { - $.ajax({ - url: "http://www.simple-scans.com/slide/search/", - type: "POST", - data: { - search: e - }, - beforeSend: function (e) { - e.setRequestHeader("Cache-Control", "no-cache"); - e.setRequestHeader("Pragma", "no-cache") - }, - success: function (e) { - var n = document.createElement("div"); - n.innerHTML = e.replace(/ .group > .title > a", n).each(function (e) { - r[r.length] = [$(this).attr("title"), $(this).attr("href")] - }); - t("Simple Scans", r) - } - }) - }, - getListChaps: function (e, t, n, r) { - $.ajax({ - url: e, - beforeSend: function (e) { - e.setRequestHeader("Cache-Control", "no-cache"); - e.setRequestHeader("Pragma", "no-cache") - }, - success: function (e) { - var t = document.createElement("div"); - t.innerHTML = e.replace(/ .title > a", t).each(function (e) { - i[i.length] = [$(this).attr("title"), $(this).attr("href")] - }); - r(i, n) - } - }) - }, - getInformationsFromCurrentPage: function (e, t, n) { - var r = $(".tbtitle div a", e)[0].title; - var i = $(".tbtitle div a", e)[1].text; - var s = $(".tbtitle div a", e)[0].href; - var o = $(".tbtitle div a", e)[1].href; - n({ - name: r, - currentChapter: i, - currentMangaURL: s, - currentChapterURL: o - }) - }, - getListImages: function (e, t) { - var n = []; - $.ajax({ - url: t, - async: false, - success: function (e) { - var t = document.createElement(t); - t.innerHTML = e; - var r = JSON.parse($(t).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, "")); - r.forEach(function (e) { - n.push(e.url) - }) - } - }); - return n - }, - removeBanners: function (e, t) { - $(".ads", e).remove() - }, - whereDoIWriteScans: function (e, t) { - return $("#page", e) - }, - whereDoIWriteNavigation: function (e, t) { - return $(".navAMR", e) - }, - isCurrentPageAChapterPage: function (e, t) { - return t.search("www.simple-scans.com/slide/read/") > -1 - }, - doSomethingBeforeWritingScans: function (e, t) { - if (typeof e.createElement === 'function') { - script = e.createElement("script"); - script.innerText = "$(document).unbind('keydown');"; - e.body.appendChild(script); - } - $("#page", e).css("max-width", "none"); - $("#page", e).css("width", "100%"); - $("#page", e).before($("")); - $("#page", e).after($("")); - $("#page", e).empty(); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", e).css("max-width", "none"); - $("#page", e).css("width", "100%") - }) - }, - nextChapterUrl: function (e, t, n) { - if ($(e).children("option:selected").prev().size() !== 0) { - return $(e).children("option:selected").prev().val() - } - return null - }, - previousChapterUrl: function (e, t, n) { - if ($(e).children("option:selected").next().size() !== 0) { - return $(e).children("option:selected").next().val() - } - return null - }, - getImageFromPageAndWrite: function (e, t, n, r) { - $(t).attr("src", e) - }, - isImageInOneCol: function (e, t, n) { - return false - }, - getMangaSelectFromPage: function (e, t) { - return null - }, - doAfterMangaLoaded: function (e, t) { - $("body > div:empty", e).remove() - } +var SimpleScans = { + mirrorName: "Simple Scans", + canListFullMangas: false, + mirrorIcon: "img/simplescans.png", + languages: "en", + isMe: function (e) { + return e.indexOf("www.simple-scans.com/slide/") !== -1 + }, + getMangaList: function (e, t) { + $.ajax({ + url: "http://www.simple-scans.com/slide/search/", + type: "POST", + data: { + search: e + }, + beforeSend: function (e) { + e.setRequestHeader("Cache-Control", "no-cache"); + e.setRequestHeader("Pragma", "no-cache") + }, + success: function (e) { + var n = document.createElement("div"); + n.innerHTML = e.replace(/ .group > .title > a", n).each(function (e) { + r[r.length] = [$(this).attr("title"), $(this).attr("href")] + }); + t("Simple Scans", r) + } + }) + }, + getListChaps: function (e, t, n, r) { + $.ajax({ + url: e, + beforeSend: function (e) { + e.setRequestHeader("Cache-Control", "no-cache"); + e.setRequestHeader("Pragma", "no-cache") + }, + success: function (e) { + var t = document.createElement("div"); + t.innerHTML = e.replace(/ .title > a", t).each(function (e) { + i[i.length] = [$(this).attr("title"), $(this).attr("href")] + }); + r(i, n) + } + }) + }, + getInformationsFromCurrentPage: function (e, t, n) { + var r = $(".tbtitle div a", e)[0].title; + var i = $(".tbtitle div a", e)[1].text; + var s = $(".tbtitle div a", e)[0].href; + var o = $(".tbtitle div a", e)[1].href; + n({ + name: r, + currentChapter: i, + currentMangaURL: s, + currentChapterURL: o + }) + }, + getListImages: function (e, t) { + var n = []; + $.ajax({ + url: t, + async: false, + success: function (e) { + var t = document.createElement(t); + t.innerHTML = e; + var r = JSON.parse($(t).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, "")); + r.forEach(function (e) { + n.push(e.url) + }) + } + }); + return n + }, + removeBanners: function (e, t) { + $(".ads", e).remove() + }, + whereDoIWriteScans: function (e, t) { + return $("#page", e) + }, + whereDoIWriteNavigation: function (e, t) { + return $(".navAMR", e) + }, + isCurrentPageAChapterPage: function (e, t) { + return t.search("www.simple-scans.com/slide/read/") > -1 + }, + doSomethingBeforeWritingScans: function (e, t) { + if (typeof e.createElement === 'function') { + script = e.createElement("script"); + script.innerText = "$(document).unbind('keydown');"; + e.body.appendChild(script); + } + $("#page", e).css("max-width", "none"); + $("#page", e).css("width", "100%"); + $("#page", e).before($("")); + $("#page", e).after($("")); + $("#page", e).empty(); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", e).css("max-width", "none"); + $("#page", e).css("width", "100%") + }) + }, + nextChapterUrl: function (e, t, n) { + if ($(e).children("option:selected").prev().size() !== 0) { + return $(e).children("option:selected").prev().val() + } + return null + }, + previousChapterUrl: function (e, t, n) { + if ($(e).children("option:selected").next().size() !== 0) { + return $(e).children("option:selected").next().val() + } + return null + }, + getImageFromPageAndWrite: function (e, t, n, r) { + $(t).attr("src", e) + }, + isImageInOneCol: function (e, t, n) { + return false + }, + getMangaSelectFromPage: function (e, t) { + return null + }, + doAfterMangaLoaded: function (e, t) { + $("body > div:empty", e).remove() + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Simple Scans", SimpleScans); diff --git a/StopTazmo.js b/StopTazmo.js index bbd0047..6d5d872 100644 --- a/StopTazmo.js +++ b/StopTazmo.js @@ -1,138 +1,137 @@ -var StopTazmo = { - mirrorName: "StopTazmo", - canListFullMangas: false, - mirrorIcon: "img/stoptazmo.png", - languages: "en", - isMe: function (e) { - return e.indexOf("stoptazmo.com/") != -1 - }, - getMangaList: function (e, t) { - $.ajax({ - url: "http://example.com/", - beforeSend: function (e) { - e.setRequestHeader("Cache-Control", "no-cache"); - e.setRequestHeader("Pragma", "no-cache") - }, - success: function (e) { - var n = document.createElement("div"); - n.innerHTML = e; - var r = []; - $("#content > table:nth-child(3) td:first-child a", n).each(function (e) { - r[r.length] = [$(this).text().trim(), $(this).attr("href")] - }); - t("StopTazmo", r) - } - }) - }, - getListChaps: function (e, t, n, r) { - $.ajax({ - url: e, - beforeSend: function (e) { - e.setRequestHeader("Cache-Control", "no-cache"); - e.setRequestHeader("Pragma", "no-cache") - }, - success: function (e) { - var t = document.createElement("div"); - t.innerHTML = e; - var i = []; - $("#content table td:first-child", t).each(function (e) { - if ($("a", $(this).closest("tr")).size() > 0) { - i[i.length] = [$(this).text().trim(), $("a", $(this).closest("tr")).last().attr("href")] - } - }); - i.reverse(); - r(i, n) - } - }) - }, - getInformationsFromCurrentPage: function (e, t, n) { - var r; - var i; - var s; - var o; - r = $("select.selectmanga option:selected", e).text().trim(); - i = $("select.selectchapter option:selected", e).text(); - s = "http://stoptazmo.com/manga-series/" + $("select.selectmanga option:selected", e).val() + "/"; - o = "http://stoptazmo.com/downloads/manga_viewer.php?series=" + $("select.selectmanga option:selected", e).val() + "&chapter=" + $("select.selectchapter option:selected", e).val(); - n({ - name: r, - currentChapter: i, - currentMangaURL: s, - currentChapterURL: o - }) - }, - getListImages: function (e, t) { - var n = []; - $("script", e).each(function (e) { - if ($(this).text().indexOf("SLIDES = new slideshow('SLIDES');") != -1) { - var t = $(this).text(); - var r = t.indexOf("s.src = '"); - while (r != -1) { - var i = t.indexOf("'", r + 9); - n[n.length] = t.substring(r + 9, i); - r = t.indexOf("s.src = '", i + 1) - } - } - }); - return n - }, - removeBanners: function (e, t) {}, - whereDoIWriteScans: function (e, t) { - return $(".scansAMR", e) - }, - whereDoIWriteNavigation: function (e, t) { - return $(".navAMR", e) - }, - isCurrentPageAChapterPage: function (e, t) { - if ($("form[name='pageSelector1']", e).size() > 0) { - return $("img", $("form[name='pageSelector1'] td", e)[1]).size() > 0 - } else { - return false - } - }, - doSomethingBeforeWritingScans: function (e, t) { - $("#wrapper", e).css("width", "auto"); - $("#content", e).css("width", "100%"); - $("#content table", e).remove(); - $("").appendTo($("#content", e)); - $("
").appendTo($("#content", e)); - $("").appendTo($("#content", e)); - $(".navAMR", e).css("text-align", "center"); - $(".navAMR", e).css("width", "100%"); - $(".scansAMR", e).css("width", "100%"); - $(".scansAMR", e).css("background-color", "black"); - $(".scansAMR", e).css("padding-top", "10px") - }, - nextChapterUrl: function (e, t, n) { - if ($(e).children("option:selected").next().size() != 0) { - return $(e).children("option:selected").next().val() - } - return null - }, - previousChapterUrl: function (e, t, n) { - if ($(e).children("option:selected").prev().size() != 0) { - return $(e).children("option:selected").prev().val() - } - return null - }, - getImageFromPageAndWrite: function (e, t, n, r) { - $(t).attr("src", e) - }, - isImageInOneCol: function (e, t, n) { - return false - }, - getMangaSelectFromPage: function (e, t) { - var n = "http://stoptazmo.com/downloads/manga_viewer.php?series=" + $("select.selectmanga option:selected", e).val() + "&chapter="; - $("select.selectchapter option", e).each(function (e) { - $(this).val(n + $(this).val()) - }); - return $("select.selectchapter", e) - }, - doAfterMangaLoaded: function (e, t) { - $("body > div:empty", e).remove() - } +var StopTazmo = { + mirrorName: "StopTazmo", + canListFullMangas: false, + mirrorIcon: "img/stoptazmo.png", + languages: "en", + isMe: function (e) { + return e.indexOf("stoptazmo.com/") != -1 + }, + getMangaList: function (e, t) { + $.ajax({ + url: "http://example.com/", + beforeSend: function (e) { + e.setRequestHeader("Cache-Control", "no-cache"); + e.setRequestHeader("Pragma", "no-cache") + }, + success: function (e) { + var n = document.createElement("div"); + n.innerHTML = e; + var r = []; + $("#content > table:nth-child(3) td:first-child a", n).each(function (e) { + r[r.length] = [$(this).text().trim(), $(this).attr("href")] + }); + t("StopTazmo", r) + } + }) + }, + getListChaps: function (e, t, n, r) { + $.ajax({ + url: e, + beforeSend: function (e) { + e.setRequestHeader("Cache-Control", "no-cache"); + e.setRequestHeader("Pragma", "no-cache") + }, + success: function (e) { + var t = document.createElement("div"); + t.innerHTML = e; + var i = []; + $("#content table td:first-child", t).each(function (e) { + if ($("a", $(this).closest("tr")).size() > 0) { + i[i.length] = [$(this).text().trim(), $("a", $(this).closest("tr")).last().attr("href")] + } + }); + i.reverse(); + r(i, n) + } + }) + }, + getInformationsFromCurrentPage: function (e, t, n) { + var r; + var i; + var s; + var o; + r = $("select.selectmanga option:selected", e).text().trim(); + i = $("select.selectchapter option:selected", e).text(); + s = "http://stoptazmo.com/manga-series/" + $("select.selectmanga option:selected", e).val() + "/"; + o = "http://stoptazmo.com/downloads/manga_viewer.php?series=" + $("select.selectmanga option:selected", e).val() + "&chapter=" + $("select.selectchapter option:selected", e).val(); + n({ + name: r, + currentChapter: i, + currentMangaURL: s, + currentChapterURL: o + }) + }, + getListImages: function (e, t) { + var n = []; + $("script", e).each(function (e) { + if ($(this).text().indexOf("SLIDES = new slideshow('SLIDES');") != -1) { + var t = $(this).text(); + var r = t.indexOf("s.src = '"); + while (r != -1) { + var i = t.indexOf("'", r + 9); + n[n.length] = t.substring(r + 9, i); + r = t.indexOf("s.src = '", i + 1) + } + } + }); + return n + }, + removeBanners: function (e, t) {}, + whereDoIWriteScans: function (e, t) { + return $(".scansAMR", e) + }, + whereDoIWriteNavigation: function (e, t) { + return $(".navAMR", e) + }, + isCurrentPageAChapterPage: function (e, t) { + if ($("form[name='pageSelector1']", e).size() > 0) { + return $("img", $("form[name='pageSelector1'] td", e)[1]).size() > 0 + } else { + return false + } + }, + doSomethingBeforeWritingScans: function (e, t) { + $("#wrapper", e).css("width", "auto"); + $("#content", e).css("width", "100%"); + $("#content table", e).remove(); + $("").appendTo($("#content", e)); + $("
").appendTo($("#content", e)); + $("").appendTo($("#content", e)); + $(".navAMR", e).css("text-align", "center"); + $(".navAMR", e).css("width", "100%"); + $(".scansAMR", e).css("width", "100%"); + $(".scansAMR", e).css("background-color", "black"); + $(".scansAMR", e).css("padding-top", "10px") + }, + nextChapterUrl: function (e, t, n) { + if ($(e).children("option:selected").next().size() != 0) { + return $(e).children("option:selected").next().val() + } + return null + }, + previousChapterUrl: function (e, t, n) { + if ($(e).children("option:selected").prev().size() != 0) { + return $(e).children("option:selected").prev().val() + } + return null + }, + getImageFromPageAndWrite: function (e, t, n, r) { + $(t).attr("src", e) + }, + isImageInOneCol: function (e, t, n) { + return false + }, + getMangaSelectFromPage: function (e, t) { + var n = "http://stoptazmo.com/downloads/manga_viewer.php?series=" + $("select.selectmanga option:selected", e).val() + "&chapter="; + $("select.selectchapter option", e).each(function (e) { + $(this).val(n + $(this).val()) + }); + return $("select.selectchapter", e) + }, + doAfterMangaLoaded: function (e, t) { + $("body > div:empty", e).remove() + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("StopTazmo", StopTazmo); diff --git a/SubManga.js b/SubManga.js index 1bd028c..a5e2460 100644 --- a/SubManga.js +++ b/SubManga.js @@ -1,241 +1,209 @@ -var SubManga = { - //Name of the mirror - mirrorName : "SubManga", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/submanga.png", - //Languages of scans for the mirror - languages : "es", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("submanga.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://submanga.com/series/n", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("#w .b468 td:first-child a", div).each(function(index) { - $("b",$(this)).remove(); - var tit = $(this).attr("href"); - tit = tit.replace("submanga.me", "submanga.com"); - res[res.length] = [$(this).remove("b").text(), tit]; - }); - callback("SubManga", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga + "/completa", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $("#w .b468 .caps td:first-child a", div).each(function(index) { - var ref = $(this).attr("href"); - var pos = ref.lastIndexOf("/"); - ref = "http://submanga.com/c/" + ref.substr(pos + 1, ref.length); - res[res.length] = [$("strong", $(this)).text(), ref]; - }); - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("td.l a:nth-child(3)", doc).text(); - var ref = $("td.l a:nth-child(3)", doc).attr("href").replace("/scanlation/", "/").substr(2); - var pos = ref.lastIndexOf("/"); - ref = "http://submanga.com/" + ref.substr(0, pos); - currentMangaURL = ref; - - currentChapter = $("td.l a:nth-child(4)", doc).text(); - ref = $("td.l a:nth-child(4)", doc).attr("href").replace("/scanlation/", "/"); - pos = ref.lastIndexOf("/"); - ref = "http://submanga.com/c/" + ref.substr(pos + 1, ref.length); - currentChapterURL = ref; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - var path = curUrl; - - $("table#t select option", doc).each( - function(index){ - res[index] = path + "/" + $(this).val(); - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $("#scan", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#t", doc).size() > 0 && $("div a img", doc).size() > 0); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans : function(doc, curUrl) { - // this code remove the fixed style from table create for this extension - // submanga have a style position: fixed for tables, this cause the table create for this extension dont work - $("link",doc).remove(); - $("body",doc).attr("bgcolor","#000"); - $("body",doc).attr("margin","0"); - $("body",doc).attr("padding","0"); - - $("#t",doc).attr("bgcolor","#1c6a6d"); - $("#t",doc).attr("width","100%"); - $("#t",doc).css("sppanding","4px"); - $("#t",doc).css("font","400 11px 'verdana'"); - $("#t",doc).css("margin","4px"); - $("#t",doc).css("padding","6px"); - - $("#t a",doc).css("text-decoration","none"); - $("#t a",doc).css("color","white"); - $("#t th",doc).last().remove(); - $("#t th",doc).last().remove(); - $("#t th",doc).last().remove(); - $("#t select",doc).last().remove(); - - //This function runs in the DOM of the current consulted page. - $("body div", doc).empty(); - $("body div", doc).append("
"); - $("#scan", doc).before($("")); - $("#scan", doc).after($("")); - $(".navAMR", doc).css("text-align", "center"); - - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var src = $("div a img", div).attr("src"); - - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //$("body > div:empty", doc).remove(); - } +var SubManga = { + //Name of the mirror + mirrorName : "SubManga", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/submanga.png", + //Languages of scans for the mirror + languages : "es", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("submanga.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://submanga.com/series/n", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#w .b468 td:first-child a", div).each(function(index) { + $("b",$(this)).remove(); + var tit = $(this).attr("href"); + tit = tit.replace("submanga.me", "submanga.com"); + res[res.length] = [$(this).remove("b").text(), tit]; + }); + callback("SubManga", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga + "/completa", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("#w .b468 .caps td:first-child a", div).each(function(index) { + var ref = $(this).attr("href"); + var pos = ref.lastIndexOf("/"); + ref = "http://submanga.com/c/" + ref.substr(pos + 1, ref.length); + res[res.length] = [$("strong", $(this)).text(), ref]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("td.l a:nth-child(3)", doc).text(); + var ref = $("td.l a:nth-child(3)", doc).attr("href").replace("/scanlation/", "/").substr(2); + var pos = ref.lastIndexOf("/"); + ref = "http://submanga.com/" + ref.substr(0, pos); + currentMangaURL = ref; + currentChapter = $("td.l a:nth-child(4)", doc).text(); + ref = $("td.l a:nth-child(4)", doc).attr("href").replace("/scanlation/", "/"); + pos = ref.lastIndexOf("/"); + ref = "http://submanga.com/c/" + ref.substr(pos + 1, ref.length); + currentChapterURL = ref; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + var path = curUrl; + $("table#t select option", doc).each( + function(index){ + res[index] = path + "/" + $(this).val(); + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $("#scan", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#t", doc).size() > 0 && $("div a img", doc).size() > 0); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans : function(doc, curUrl) { + // this code remove the fixed style from table create for this extension + // submanga have a style position: fixed for tables, this cause the table create for this extension dont work + $("link",doc).remove(); + $("body",doc).attr("bgcolor","#000"); + $("body",doc).attr("margin","0"); + $("body",doc).attr("padding","0"); + $("#t",doc).attr("bgcolor","#1c6a6d"); + $("#t",doc).attr("width","100%"); + $("#t",doc).css("sppanding","4px"); + $("#t",doc).css("font","400 11px 'verdana'"); + $("#t",doc).css("margin","4px"); + $("#t",doc).css("padding","6px"); + $("#t a",doc).css("text-decoration","none"); + $("#t a",doc).css("color","white"); + $("#t th",doc).last().remove(); + $("#t th",doc).last().remove(); + $("#t th",doc).last().remove(); + $("#t select",doc).last().remove(); + //This function runs in the DOM of the current consulted page. + $("body div", doc).empty(); + $("body div", doc).append("
"); + $("#scan", doc).before($("")); + $("#scan", doc).after($("")); + $(".navAMR", doc).css("text-align", "center"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src = $("div a img", div).attr("src"); + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //$("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("SubManga", SubManga); diff --git a/TenManga.js b/TenManga.js index aa83c28..fd295a0 100644 --- a/TenManga.js +++ b/TenManga.js @@ -1,303 +1,273 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var TenManga = { - //Name of the mirror - mirrorName : "TenManga", - //True if the mirror can list all of its mangas. - canListFullMangas : false, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/tenmanga.png", - //Languages of scans for the mirror - languages : "en,zh", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("tenmanga.com/") != -1 || url.indexOf("dm72.com/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.fullcomic.com/list/?wd=" + search, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("dt > a:first-child", div).each(function(index) { - var title = $(this).text().replace(/ /g, " "); - res[res.length] = [title, $(this).attr("href")]; - }); - callback("TenManga", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga + ((urlManga.indexOf("tenmanga.com/") != -1) ? "?waring=1" : ""), - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - if (urlManga.indexOf("tenmanga.com/") != -1) { - $(".chapter_list tr td:first-child a", div).each(function(index) { - if (index != $(".chapter_list tr td:first-child a", div).size() - 1) { - res[res.length] = [$(this).text(), "http://www.tenmanga.com" + $(this).attr("href")]; - } - }); - } else if (urlManga.indexOf("www.dm72.com/") != -1) { - $(".chapter_list tr td:first-child a", div).each(function(index) { - res[res.length] = [$(this).text(), "http://www.dm72.com" + $(this).attr("href")]; - }); - } else { - $(".chapter_list tr td:first-child a", div).each(function(index) { - res[res.length] = [$(this).text(), $(this).attr("href")]; - }); - } - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - if (curUrl.indexOf("tenmanga.com/") != -1) { - name = $(".chapter_bar div.postion span.normal a:nth-child(2)", doc).text().trim(); - currentMangaURL = $(".chapter_bar div.postion span.normal a:nth-child(2)", doc).attr("href"); - - currentChapter = $("select#chapter:first option:selected", doc).text(); - currentChapterURL = $("select#chapter:first option:selected", doc).val(); - } else if (curUrl.indexOf("www.dm72.com/") != -1) { - name = $(".juan .top_guide > div:first a:nth-child(3)", doc).text().trim(); - currentMangaURL = "http://www.dm72.com" + $(".juan .top_guide > div:first a:nth-child(3)", doc).attr("href"); - - currentChapter = $("select#juan_list:first option:selected", doc).text(); - currentChapterURL = "http://www.dm72.com" + $("select#juan_list:first option:selected", doc).val(); - } else { - name = $(".main_bar div.postion span.normal a:nth-child(2)", doc).text().trim(); - currentMangaURL = $(".main_bar div.postion span.normal a:nth-child(2)", doc).attr("href"); - - currentChapter = $("select#chapter:first option:selected", doc).text(); - currentChapterURL = $("select#chapter:first option:selected", doc).val(); - } - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - if (curUrl.indexOf("tenmanga.com/") != -1) { - $("select#page:first option", doc).each(function(index) { - res[res.length] = $(this).val(); - }); - } else if (curUrl.indexOf("www.dm72.com/") != -1) { - var base = "http://www.dm72.com" + $("select#juan_list:first option:selected", doc).val(); - var pos = base.lastIndexOf("/"); - base = base.substr(0, pos); - $("select#pic_list:first option", doc).each(function(index) { - res[res.length] = base + $(this).val(); - }); - } else { - $("select#page:first option", doc).each(function(index) { - res[res.length] = $(this).val(); - }); - } - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("iframe", doc).remove(); - if (curUrl.indexOf("tenmanga.com/") != -1) { - $(".outer", doc).parent().next().remove(); - } - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scansAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - if (curUrl.indexOf("tenmanga.com/") != -1) { - return ($("img#comicpic", doc).size() > 0); - } else if (curUrl.indexOf("www.dm72.com/") != -1) { - return ($("img#comicpic", doc).size() > 0); - } else { - return ($("img", $(".outer", doc).next().next()).size() > 0); - } - }, - - //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. - if (curUrl.indexOf("tenmanga.com/") != -1) { - $(".outer", doc).nextAll().remove(); - $(".outer", doc).after($("")); - $(".outer", doc).after($("
")); - $(".outer", doc).after($("")); - } else if (curUrl.indexOf("www.dm72.com/") != -1) { - $("#juan_list").remove(); - $(".juan", doc).next().remove(); - $(".juan", doc).next().remove(); - $(".juan", doc).after($("")); - $(".juan", doc).after($("
")); - $(".juan", doc).after($("")); - } else { - $(".outer", doc).nextAll().remove(); - $(".outer", doc).after($("")); - $(".outer", doc).after($("
")); - $(".outer", doc).after($("")); - } - $(".navAMR", doc).css("text-align", "center"); - $(".navAMR", doc).css("width", "100%"); - $(".scansAMR", doc).css("background-color", "black"); - $(".scansAMR", doc).css("padding-top", "10px"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $.ajax( - { - url: urlImg, - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var src; - if (curUrl.indexOf("tenmanga.com/") != -1) { - src = $("img#comicpic", div).attr("src"); - } else if (curUrl.indexOf("www.dm72.com/") != -1) { - src = $("img#comicpic", div).attr("src"); - } else { - src = $($("img", $(".outer", div).next().next())[0]).attr("src"); - } - - $( image ).attr( "src", src); - } - }); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if (curUrl.indexOf("tenmanga.com/") != -1) { - return $("select#chapter:first", doc); - } else if (curUrl.indexOf("www.dm72.com/") != -1) { - $("select#juan_list:first option", doc).each(function(index) { - $(this).val("http://www.dm72.com" + $(this).val()); - }); - return $("select#juan_list:first", doc); - } else { - return $("select#chapter:first", doc); - } - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var TenManga = { + //Name of the mirror + mirrorName : "TenManga", + //True if the mirror can list all of its mangas. + canListFullMangas : false, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/tenmanga.png", + //Languages of scans for the mirror + languages : "en,zh", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("tenmanga.com/") != -1 || url.indexOf("dm72.com/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.fullcomic.com/list/?wd=" + search, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("dt > a:first-child", div).each(function(index) { + var title = $(this).text().replace(/ /g, " "); + res[res.length] = [title, $(this).attr("href")]; + }); + callback("TenManga", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga + ((urlManga.indexOf("tenmanga.com/") != -1) ? "?waring=1" : ""), + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + if (urlManga.indexOf("tenmanga.com/") != -1) { + $(".chapter_list tr td:first-child a", div).each(function(index) { + if (index != $(".chapter_list tr td:first-child a", div).size() - 1) { + res[res.length] = [$(this).text(), "http://www.tenmanga.com" + $(this).attr("href")]; + } + }); + } else if (urlManga.indexOf("www.dm72.com/") != -1) { + $(".chapter_list tr td:first-child a", div).each(function(index) { + res[res.length] = [$(this).text(), "http://www.dm72.com" + $(this).attr("href")]; + }); + } else { + $(".chapter_list tr td:first-child a", div).each(function(index) { + res[res.length] = [$(this).text(), $(this).attr("href")]; + }); + } + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + if (curUrl.indexOf("tenmanga.com/") != -1) { + name = $(".chapter_bar div.postion span.normal a:nth-child(2)", doc).text().trim(); + currentMangaURL = $(".chapter_bar div.postion span.normal a:nth-child(2)", doc).attr("href"); + currentChapter = $("select#chapter:first option:selected", doc).text(); + currentChapterURL = $("select#chapter:first option:selected", doc).val(); + } else if (curUrl.indexOf("www.dm72.com/") != -1) { + name = $(".juan .top_guide > div:first a:nth-child(3)", doc).text().trim(); + currentMangaURL = "http://www.dm72.com" + $(".juan .top_guide > div:first a:nth-child(3)", doc).attr("href"); + currentChapter = $("select#juan_list:first option:selected", doc).text(); + currentChapterURL = "http://www.dm72.com" + $("select#juan_list:first option:selected", doc).val(); + } else { + name = $(".main_bar div.postion span.normal a:nth-child(2)", doc).text().trim(); + currentMangaURL = $(".main_bar div.postion span.normal a:nth-child(2)", doc).attr("href"); + currentChapter = $("select#chapter:first option:selected", doc).text(); + currentChapterURL = $("select#chapter:first option:selected", doc).val(); + } + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + if (curUrl.indexOf("tenmanga.com/") != -1) { + $("select#page:first option", doc).each(function(index) { + res[res.length] = $(this).val(); + }); + } else if (curUrl.indexOf("www.dm72.com/") != -1) { + var base = "http://www.dm72.com" + $("select#juan_list:first option:selected", doc).val(); + var pos = base.lastIndexOf("/"); + base = base.substr(0, pos); + $("select#pic_list:first option", doc).each(function(index) { + res[res.length] = base + $(this).val(); + }); + } else { + $("select#page:first option", doc).each(function(index) { + res[res.length] = $(this).val(); + }); + } + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("iframe", doc).remove(); + if (curUrl.indexOf("tenmanga.com/") != -1) { + $(".outer", doc).parent().next().remove(); + } + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scansAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + if (curUrl.indexOf("tenmanga.com/") != -1) { + return ($("img#comicpic", doc).size() > 0); + } else if (curUrl.indexOf("www.dm72.com/") != -1) { + return ($("img#comicpic", doc).size() > 0); + } else { + return ($("img", $(".outer", doc).next().next()).size() > 0); + } + }, + //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. + if (curUrl.indexOf("tenmanga.com/") != -1) { + $(".outer", doc).nextAll().remove(); + $(".outer", doc).after($("")); + $(".outer", doc).after($("
")); + $(".outer", doc).after($("")); + } else if (curUrl.indexOf("www.dm72.com/") != -1) { + $("#juan_list").remove(); + $(".juan", doc).next().remove(); + $(".juan", doc).next().remove(); + $(".juan", doc).after($("")); + $(".juan", doc).after($("
")); + $(".juan", doc).after($("")); + } else { + $(".outer", doc).nextAll().remove(); + $(".outer", doc).after($("")); + $(".outer", doc).after($("
")); + $(".outer", doc).after($("")); + } + $(".navAMR", doc).css("text-align", "center"); + $(".navAMR", doc).css("width", "100%"); + $(".scansAMR", doc).css("background-color", "black"); + $(".scansAMR", doc).css("padding-top", "10px"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $.ajax( + { + url: urlImg, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var src; + if (curUrl.indexOf("tenmanga.com/") != -1) { + src = $("img#comicpic", div).attr("src"); + } else if (curUrl.indexOf("www.dm72.com/") != -1) { + src = $("img#comicpic", div).attr("src"); + } else { + src = $($("img", $(".outer", div).next().next())[0]).attr("src"); + } + $( image ).attr( "src", src); + } + }); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if (curUrl.indexOf("tenmanga.com/") != -1) { + return $("select#chapter:first", doc); + } else if (curUrl.indexOf("www.dm72.com/") != -1) { + $("select#juan_list:first option", doc).each(function(index) { + $(this).val("http://www.dm72.com" + $(this).val()); + }); + return $("select#juan_list:first", doc); + } else { + return $("select#chapter:first", doc); + } + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("TenManga", TenManga); diff --git a/ThHour.js b/ThHour.js index f7dc321..d5eb949 100644 --- a/ThHour.js +++ b/ThHour.js @@ -1,137 +1,135 @@ -var ThHour = { - mirrorName : "13Th Hour Scanlations", - canListFullMangas : false, - mirrorIcon : "img/13thHour.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("reader.13thhour.net/") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://reader.13thhour.net/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("13Th Hour Scanlations", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement("div"); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads.banner.iframe", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('reader.13thhour.net/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.type = 'text/javascript'; - script.innerText = "$(document).unbind('keyup');"; - script.innerText += "$(document).unbind('keydown');"; - script.innerText += "$(document).unbind('keypress');"; - doc.body.appendChild(script); - } - - $("#page", doc).before(""); - $("#page", doc).after(""); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var ThHour = { + mirrorName : "13Th Hour Scanlations", + canListFullMangas : false, + mirrorIcon : "img/13thHour.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("reader.13thhour.net/") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://reader.13thhour.net/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("13Th Hour Scanlations", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement("div"); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads.banner.iframe", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('reader.13thhour.net/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.type = 'text/javascript'; + script.innerText = "$(document).unbind('keyup');"; + script.innerText += "$(document).unbind('keydown');"; + script.innerText += "$(document).unbind('keypress');"; + doc.body.appendChild(script); + } + $("#page", doc).before(""); + $("#page", doc).after(""); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("13Th Hour Scanlations", ThHour); diff --git a/TheSpectrum.js b/TheSpectrum.js index 0c08aa8..2f11e7b 100644 --- a/TheSpectrum.js +++ b/TheSpectrum.js @@ -1,209 +1,208 @@ -var TheSpectrum = { - mirrorName: "The Spectrum", - canListFullMangas: true, - mirrorIcon: "img/thespectrum.png", - languages: "en", - isMe: function (url) { - return (url.indexOf("thespectrum.net/") != -1 || url.indexOf("mangamonger.com/") != -1); - }, - getMangaList: function (search, callback) { - $.ajax({ - url: "http://www.thespectrum.net/manga_scans/", - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $("span#all a", div).each(function (index) { - if (index > 1) { - res[res.length] = [$(this).text(), "http://www.thespectrum.net" + $(this).attr("href")]; - } - }); - callback("The Spectrum", res); - } - }); - }, - getListChaps: function (urlManga, mangaName, obj, callback) { - $.ajax({ - url: urlManga, - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var linka; - $("a", $($("#mainmid .mainbgtop > p", div))).each(function (index) { - if (linka == undefined && $(this).attr("target") != "" && $(this).attr("target") != "_blank" && $(this).attr("href").indexOf("thespectrum.net/") != -1) { - linka = $(this).attr("href"); - } - }); - $.ajax({ - url: linka, - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (resp) { - var div2 = document.createElement("div"); - div2.innerHTML = resp; - var res = []; - $(".viewerLabel .selectchapter option", div2).each(function (index) { - res[res.length] = [$(this).text(), linka + "?ch=" + $(this).val() + "&page=1"]; - }); - res.reverse(); - callback(res, obj); - } - }); - } - }); - }, - getInformationsFromCurrentPage: function (doc, curUrl, callback) { - var currentMangaURL; - var nameManga; - var currentChapter; - var currentChapterURL; - currentMangaURL = ""; - $(".viewerLabel", $("#mainGallery .post form[name='pageSelector1']", doc)).each(function (index) { - if (nameManga == undefined && !$(this).hasClass("hidden")) { - nameManga = $(this).text().trim(); - } - }); - chrome.extension.sendRequest({ - action: "getListManga", - mirror: "The Spectrum" - }, function (res) { - var tmpNM = nameManga.replace(/[^a-zA-Z0-9]/g, ""); - for (var i = 0; i < res.length; i++) { - if (tmpNM == res[i][0].replace(/[^a-zA-Z0-9]/g, "")) { - currentMangaURL = res[i][1]; - nameManga = res[i][0]; - break; - } - } - currentChapter = $(".viewerLabel .selectchapter option:selected", doc).text(); - chrome.extension.sendRequest({ - action: "getListChap", - mirror: "The Spectrum", - mangaUrl: currentMangaURL, - mangaName: nameManga - }, function (res) { - var base = res[0][1]; - if (base.indexOf(".html") != -1) { - var pos = base.indexOf(".html"); - base = base.substr(0, pos) + ".html"; - } - else { - var pos = base.lastIndexOf("/"); - base = base.substr(0, pos) + "/"; - } - currentChapterURL = base + "?ch=" + $(".viewerLabel .selectchapter option:selected", doc).val() + "&page=1"; - callback({ - "name": nameManga, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL - }); - }); - }); - }, - getListImages: function (doc, curUrl) { - var ref = curUrl; - pos = ref.lastIndexOf(".html"); - if (pos != -1) { - ref = ref.substr(0, pos) + ".html?ch=" + $(".viewerLabel .selectchapter option:selected", doc).text() + "&page="; - } - else { - pos = ref.lastIndexOf("/"); - ref = ref.substr(0, pos) + "/?ch=" + $(".viewerLabel .selectchapter option:selected", doc).text() + "&page="; - } - var res = []; - $(".viewerLabel select.selectpage option", doc).each(function (index) { - res[index] = ref + $(this).val(); - }); - return res; - }, - removeBanners: function (doc, curUrl) { - $("iframe", doc).remove(); - }, - whereDoIWriteScans: function (doc, curUrl) { - return $(".scansAMR", doc); - }, - whereDoIWriteNavigation: function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage: function (doc, curUrl) { - return (curUrl.search('view.thespectrum.net/series/') > -1) - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - if ($("#midtable", doc).size() > 0) { - $("#midtable", doc).wrap($("
")); - $("#midtable", doc).remove(); - $(".scansAMR", doc).before($("")); - $(".scansAMR", doc).after($("")); - $(".navAMR", doc).css("text-align", "center"); - } - else { - $("body > table", doc).css("display", "none"); - $("body > table", doc).after($("")); - $("body > table", doc).next().after($("
")); - $("body > table", doc).next().next().after($("")); - $(".navAMR", doc).css("text-align", "center"); - } - }, - nextChapterUrl: function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - var chap = $(select).children("option:selected").next().val(); - return chap; - } - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - var chap = $(select).children("option:selected").prev().val(); - return chap; - } - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - $.ajax({ - url: urlImg, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src; - if (curUrl.indexOf("view.thespectrum.net") != -1) { - src = $(".imgContainer img#mainimage", div).attr("src"); - } - else { - src = "http://view.mangamonger.com" + $(".imgContainer img#mainimage", div).attr("src"); - } - $(image).attr("src", src); - } - }); - }, - isImageInOneCol: function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - $(".viewerLabel .selectchapter option", doc).each(function (index) { - var base = $("#mainGallery .post h1 > a", doc).attr("href"); - if (base == undefined || base.length == 0) { - base = $("#head #title a", doc).attr("href"); - } - $(this).val(base + "?ch=" + $(this).val() + "&page=1"); - }); - return $(".viewerLabel .selectchapter", doc); - }, - doAfterMangaLoaded: function (doc, curUrl) { - $("body > div:empty", doc).remove(); - }, +var TheSpectrum = { + mirrorName: "The Spectrum", + canListFullMangas: true, + mirrorIcon: "img/thespectrum.png", + languages: "en", + isMe: function (url) { + return (url.indexOf("thespectrum.net/") != -1 || url.indexOf("mangamonger.com/") != -1); + }, + getMangaList: function (search, callback) { + $.ajax({ + url: "http://www.thespectrum.net/manga_scans/", + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $("span#all a", div).each(function (index) { + if (index > 1) { + res[res.length] = [$(this).text(), "http://www.thespectrum.net" + $(this).attr("href")]; + } + }); + callback("The Spectrum", res); + } + }); + }, + getListChaps: function (urlManga, mangaName, obj, callback) { + $.ajax({ + url: urlManga, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var linka; + $("a", $($("#mainmid .mainbgtop > p", div))).each(function (index) { + if (linka == undefined && $(this).attr("target") != "" && $(this).attr("target") != "_blank" && $(this).attr("href").indexOf("thespectrum.net/") != -1) { + linka = $(this).attr("href"); + } + }); + $.ajax({ + url: linka, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (resp) { + var div2 = document.createElement("div"); + div2.innerHTML = resp; + var res = []; + $(".viewerLabel .selectchapter option", div2).each(function (index) { + res[res.length] = [$(this).text(), linka + "?ch=" + $(this).val() + "&page=1"]; + }); + res.reverse(); + callback(res, obj); + } + }); + } + }); + }, + getInformationsFromCurrentPage: function (doc, curUrl, callback) { + var currentMangaURL; + var nameManga; + var currentChapter; + var currentChapterURL; + currentMangaURL = ""; + $(".viewerLabel", $("#mainGallery .post form[name='pageSelector1']", doc)).each(function (index) { + if (nameManga == undefined && !$(this).hasClass("hidden")) { + nameManga = $(this).text().trim(); + } + }); + chrome.extension.sendRequest({ + action: "getListManga", + mirror: "The Spectrum" + }, function (res) { + var tmpNM = nameManga.replace(/[^a-zA-Z0-9]/g, ""); + for (var i = 0; i < res.length; i++) { + if (tmpNM == res[i][0].replace(/[^a-zA-Z0-9]/g, "")) { + currentMangaURL = res[i][1]; + nameManga = res[i][0]; + break; + } + } + currentChapter = $(".viewerLabel .selectchapter option:selected", doc).text(); + chrome.extension.sendRequest({ + action: "getListChap", + mirror: "The Spectrum", + mangaUrl: currentMangaURL, + mangaName: nameManga + }, function (res) { + var base = res[0][1]; + if (base.indexOf(".html") != -1) { + var pos = base.indexOf(".html"); + base = base.substr(0, pos) + ".html"; + } + else { + var pos = base.lastIndexOf("/"); + base = base.substr(0, pos) + "/"; + } + currentChapterURL = base + "?ch=" + $(".viewerLabel .selectchapter option:selected", doc).val() + "&page=1"; + callback({ + "name": nameManga, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL + }); + }); + }); + }, + getListImages: function (doc, curUrl) { + var ref = curUrl; + pos = ref.lastIndexOf(".html"); + if (pos != -1) { + ref = ref.substr(0, pos) + ".html?ch=" + $(".viewerLabel .selectchapter option:selected", doc).text() + "&page="; + } + else { + pos = ref.lastIndexOf("/"); + ref = ref.substr(0, pos) + "/?ch=" + $(".viewerLabel .selectchapter option:selected", doc).text() + "&page="; + } + var res = []; + $(".viewerLabel select.selectpage option", doc).each(function (index) { + res[index] = ref + $(this).val(); + }); + return res; + }, + removeBanners: function (doc, curUrl) { + $("iframe", doc).remove(); + }, + whereDoIWriteScans: function (doc, curUrl) { + return $(".scansAMR", doc); + }, + whereDoIWriteNavigation: function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage: function (doc, curUrl) { + return (curUrl.search('view.thespectrum.net/series/') > -1) + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + if ($("#midtable", doc).size() > 0) { + $("#midtable", doc).wrap($("
")); + $("#midtable", doc).remove(); + $(".scansAMR", doc).before($("")); + $(".scansAMR", doc).after($("")); + $(".navAMR", doc).css("text-align", "center"); + } + else { + $("body > table", doc).css("display", "none"); + $("body > table", doc).after($("")); + $("body > table", doc).next().after($("
")); + $("body > table", doc).next().next().after($("")); + $(".navAMR", doc).css("text-align", "center"); + } + }, + nextChapterUrl: function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + var chap = $(select).children("option:selected").next().val(); + return chap; + } + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + var chap = $(select).children("option:selected").prev().val(); + return chap; + } + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + $.ajax({ + url: urlImg, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src; + if (curUrl.indexOf("view.thespectrum.net") != -1) { + src = $(".imgContainer img#mainimage", div).attr("src"); + } + else { + src = "http://view.mangamonger.com" + $(".imgContainer img#mainimage", div).attr("src"); + } + $(image).attr("src", src); + } + }); + }, + isImageInOneCol: function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + $(".viewerLabel .selectchapter option", doc).each(function (index) { + var base = $("#mainGallery .post h1 > a", doc).attr("href"); + if (base == undefined || base.length == 0) { + base = $("#head #title a", doc).attr("href"); + } + $(this).val(base + "?ch=" + $(this).val() + "&page=1"); + }); + return $(".viewerLabel .selectchapter", doc); + }, + doAfterMangaLoaded: function (doc, curUrl) { + $("body > div:empty", doc).remove(); + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("The Spectrum", TheSpectrum); diff --git a/Titania.js b/Titania.js index bbf7661..633f3c4 100644 --- a/Titania.js +++ b/Titania.js @@ -1,259 +1,227 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var Titania = { - //Name of the mirror - mirrorName : "Titania Scanlations", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/titania.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("www.titaniascans.com/reader/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://www.titaniascans.com/reader/", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $(".selector .options a", div).each(function(index) { - res[res.length] = [$(this).attr("title").trim(), $(this).attr("href")]; - }); - callback("Titania Scanlations", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $(".theList a:has(.chapter)", div).each(function(index) { - res[res.length] = [$("b", $(this)).text().trim(), $(this).attr("href")]; - }); - - callback(res, obj); - } - }); - }, - - retrieveInfo: function(sel) { - var _obj = {}; - var curval = $(sel.contents()[0]).text(); - $("a", sel).each(function(index) { - if ($(".option", $(this)).text().trim() == curval) { - _obj = {name: curval, url: $(this).attr("href")}; - } - }); - return _obj; - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - var manga = Titania.retrieveInfo($($(".selector", doc)[0])); - var chapter = Titania.retrieveInfo($($(".selector", doc)[1])); - name = manga.name; - currentChapter = chapter.name; - currentChapterURL = chapter.url; - currentMangaURL = manga.url; - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - $("script", doc).each(function(index) { - if ($(this).text().indexOf("imageArray = new Array();") != -1) { - var txt = $(this).text(); - var pos = txt.indexOf("imageArray["); - while (pos != -1) { - var debur = txt.indexOf("'", pos); - var finur = txt.indexOf("'", debur + 1); - res[res.length] = txt.substring(debur + 1, finur); - pos = txt.indexOf("imageArray[", finur + 1); - } - } - }); - - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".ads", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scanAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#theManga #thePic", doc).size() > 0); - }, - - //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. - - $("#theManga", doc).empty(); - var cloned = $("#theManga", doc).clone(); - $("#theManga", doc).after(cloned); - cloned.attr("id", "amrManga"); - $("#theManga", doc).remove(); - $("#amrManga", doc).css("width", "auto"); - $("#amrManga", doc).css("margin", "0"); - $("#theHead", doc).remove(); - $("").appendTo($("#amrManga", doc)); - $("
").appendTo($("#amrManga", doc)); - $("").appendTo($("#amrManga", doc)); - $(".navAMR", doc).css("text-align", "center"); - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keyup');\n"; - script.innerText += "$(document).unbind('hashchange');"; - doc.body.appendChild(script); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $( image ).attr( "src", urlImg ); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var sel = $($(".selector", doc)[1]); - var ret = $(""); - var curval = $(sel.contents()[0]).text(); - $("a", sel).each(function(index) { - var iscur = false; - if ($(".option", $(this)).text().trim() == curval) { - iscur = true; - } - $("").appendTo(ret); - }); - return ret; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - $('#infoSpread').remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var Titania = { + //Name of the mirror + mirrorName : "Titania Scanlations", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/titania.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("www.titaniascans.com/reader/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://www.titaniascans.com/reader/", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $(".selector .options a", div).each(function(index) { + res[res.length] = [$(this).attr("title").trim(), $(this).attr("href")]; + }); + callback("Titania Scanlations", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $(".theList a:has(.chapter)", div).each(function(index) { + res[res.length] = [$("b", $(this)).text().trim(), $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + retrieveInfo: function(sel) { + var _obj = {}; + var curval = $(sel.contents()[0]).text(); + $("a", sel).each(function(index) { + if ($(".option", $(this)).text().trim() == curval) { + _obj = {name: curval, url: $(this).attr("href")}; + } + }); + return _obj; + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + var manga = Titania.retrieveInfo($($(".selector", doc)[0])); + var chapter = Titania.retrieveInfo($($(".selector", doc)[1])); + name = manga.name; + currentChapter = chapter.name; + currentChapterURL = chapter.url; + currentMangaURL = manga.url; + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + $("script", doc).each(function(index) { + if ($(this).text().indexOf("imageArray = new Array();") != -1) { + var txt = $(this).text(); + var pos = txt.indexOf("imageArray["); + while (pos != -1) { + var debur = txt.indexOf("'", pos); + var finur = txt.indexOf("'", debur + 1); + res[res.length] = txt.substring(debur + 1, finur); + pos = txt.indexOf("imageArray[", finur + 1); + } + } + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".ads", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scanAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#theManga #thePic", doc).size() > 0); + }, + //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. + $("#theManga", doc).empty(); + var cloned = $("#theManga", doc).clone(); + $("#theManga", doc).after(cloned); + cloned.attr("id", "amrManga"); + $("#theManga", doc).remove(); + $("#amrManga", doc).css("width", "auto"); + $("#amrManga", doc).css("margin", "0"); + $("#theHead", doc).remove(); + $("").appendTo($("#amrManga", doc)); + $("
").appendTo($("#amrManga", doc)); + $("").appendTo($("#amrManga", doc)); + $(".navAMR", doc).css("text-align", "center"); + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keyup');\n"; + script.innerText += "$(document).unbind('hashchange');"; + doc.body.appendChild(script); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $( image ).attr( "src", urlImg ); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var sel = $($(".selector", doc)[1]); + var ret = $(""); + var curval = $(sel.contents()[0]).text(); + $("a", sel).each(function(index) { + var iscur = false; + if ($(".option", $(this)).text().trim() == curval) { + iscur = true; + } + $("").appendTo(ret); + }); + return ret; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + $('#infoSpread').remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Titania Scanlations", Titania); diff --git a/Trinitybakuma.js b/Trinitybakuma.js index 8cdba21..abb4e64 100644 --- a/Trinitybakuma.js +++ b/Trinitybakuma.js @@ -1,184 +1,183 @@ -var Trinitybakuma = { - mirrorName : "Trinity BAKumA", - canListFullMangas : true, - mirrorIcon : "img/trinitybakuma.png", - languages : "en", - isMe : function (url) { - "use strict"; - return (url.indexOf("trinitybakuma.com/manga/") !== -1); - }, - getMangaList : function (search, callback) { - "use strict"; - $.ajax({ - url : "http://trinitybakuma.com/manga/", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ 0); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - "use strict"; - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "$(document).unbind('keyup');"; - doc.body.appendChild(script); - } - $("#theManga", doc).empty(); - var cloned = $("#theManga", doc).clone(); - $("#theManga", doc).after(cloned); - cloned.attr("id", "amrManga"); - $("#theManga", doc).remove(); - $("#amrManga", doc).css("width", "auto"); - $("#amrManga", doc).css("margin", "0"); - $("#theHead", doc).remove(); - $("").appendTo($("#amrManga", doc)); - $("
").appendTo($("#amrManga", doc)); - $("").appendTo($("#amrManga", doc)); - $(".navAMR", doc).css("text-align", "center"); - }, - nextChapterUrl : function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - "use strict"; - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - "use strict"; - var sel = $($(".selector2", doc)[1]); - var ret = $(""); - var curval = $(sel.contents()[0]).text(); - var pos = curval.indexOf(": "); - curval = curval.substring(pos + 2, curval.length).trim(); - $("a", sel).each(function (index) { - var iscur = false; - if ($(".option", $(this)).text().trim() === curval) { - iscur = true; - } - $("").appendTo(ret); - }); - return ret; - }, - doAfterMangaLoaded : function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - $('#infoSpread').hide(); - } +var Trinitybakuma = { + mirrorName : "Trinity BAKumA", + canListFullMangas : true, + mirrorIcon : "img/trinitybakuma.png", + languages : "en", + isMe : function (url) { + "use strict"; + return (url.indexOf("trinitybakuma.com/manga/") !== -1); + }, + getMangaList : function (search, callback) { + "use strict"; + $.ajax({ + url : "http://trinitybakuma.com/manga/", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ 0); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + "use strict"; + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "$(document).unbind('keyup');"; + doc.body.appendChild(script); + } + $("#theManga", doc).empty(); + var cloned = $("#theManga", doc).clone(); + $("#theManga", doc).after(cloned); + cloned.attr("id", "amrManga"); + $("#theManga", doc).remove(); + $("#amrManga", doc).css("width", "auto"); + $("#amrManga", doc).css("margin", "0"); + $("#theHead", doc).remove(); + $("").appendTo($("#amrManga", doc)); + $("
").appendTo($("#amrManga", doc)); + $("").appendTo($("#amrManga", doc)); + $(".navAMR", doc).css("text-align", "center"); + }, + nextChapterUrl : function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + "use strict"; + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + "use strict"; + var sel = $($(".selector2", doc)[1]); + var ret = $(""); + var curval = $(sel.contents()[0]).text(); + var pos = curval.indexOf(": "); + curval = curval.substring(pos + 2, curval.length).trim(); + $("a", sel).each(function (index) { + var iscur = false; + if ($(".option", $(this)).text().trim() === curval) { + iscur = true; + } + $("").appendTo(ret); + }); + return ret; + }, + doAfterMangaLoaded : function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + $('#infoSpread').hide(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Trinity BAKumA", Trinitybakuma); diff --git a/TwinDragons.js b/TwinDragons.js index c84f946..8ed68a7 100644 --- a/TwinDragons.js +++ b/TwinDragons.js @@ -1,225 +1,197 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) Enter here your copyright mention... // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -//CHANGE here the classname -var TwinDragons = { - //CHANGE : Name of the mirror - mirrorName : "Twin Dragons no Fansub", - //CHANGE : True if the mirror can list all of its mangas. - canListFullMangas : true, - //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) - mirrorIcon : "img/TwinDragons.png", - languages: "es", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("twindragons-scans.com/reader") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - //CHANGE URL HERE - url: "http://twindragons-scans.com/reader/reader/list/", - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $('.list.series > .group > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback("Twin Dragons no Fansub", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - //CHANGE URL HERE - url: urlManga, - - //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - $('.list > .element > .title > a', div).each(function(index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - - callback(res, obj); - } - }); - }, - - /******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). - ********************************************************************************************************/ - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - var res = []; - eval($('body', doc).html().match(/var pages = .*\n/)[0]); - pages.forEach(function(page) - { - res.push(page.url); - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(".ads", doc).remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - return $('#page', doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) - //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return (curUrl.search('twindragons-scans.com/reader/reader/read/') > -1); - }, - - //This method is called before displaying full chapters in the page - doSomethingBeforeWritingScans : function(doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function() { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $(image).attr("src", urlImg); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - //DO ANYTHING ELSE YOU NEED - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) Enter here your copyright mention... // +// // +/////////////////////////////////////////////////////////////////////////////*/ +//CHANGE here the classname +var TwinDragons = { + //CHANGE : Name of the mirror + mirrorName : "Twin Dragons no Fansub", + //CHANGE : True if the mirror can list all of its mangas. + canListFullMangas : true, + //CHANGE : Extension internal link to the icon of the mirror. (if not filled, will be blank...) + mirrorIcon : "img/TwinDragons.png", + languages: "es", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("twindragons-scans.com/reader") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + //CHANGE URL HERE + url: "http://twindragons-scans.com/reader/reader/list/", + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list.series > .group > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Twin Dragons no Fansub", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + //CHANGE URL HERE + url: urlManga, + //KEEP THE HEADERS, THEY PREVENT CHROME TO LOAD URL FROM CACHE + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function(index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + /******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). + ********************************************************************************************************/ + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + var res = []; + eval($('body', doc).html().match(/var pages = .*\n/)[0]); + pages.forEach(function(page) + { + res.push(page.url); + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(".ads", doc).remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + return $('#page', doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //YOU MUST RETURN TWO PLACES (ON TOP AND AT THE BOTTOM OF THE CHAPTER) + //you can change the DOM of the page before this method is called in doSomethingBeforeWritingScans + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return (curUrl.search('twindragons-scans.com/reader/reader/read/') > -1); + }, + //This method is called before displaying full chapters in the page + doSomethingBeforeWritingScans : function(doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function() { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $(image).attr("src", urlImg); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //DO NOT CHANGE IF NOT NEEDED, NOT USED BY ANY EXISTING MIRROR AND CHAPTER'S DISPLAY IS WORKING FINE FOR THEM + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //RETURN A SELECT IF NEEDED, ELSE, THE EXTENSIOn WILL FIND CHAPTER BY IT'S OWN MEANS + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + //DO ANYTHING ELSE YOU NEED + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Twin Dragons no Fansub", TwinDragons); diff --git a/UnixManga.js b/UnixManga.js index 2b4a439..7e7f67f 100644 --- a/UnixManga.js +++ b/UnixManga.js @@ -1,302 +1,268 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Matteo TeoMan Mangano (MM.teoman at gmail dot com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ -var getListChapsInnerCnt = 0; - function getListChapsInner(urlManga, mangaName, obj, callback, res, level) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - if ($("div[id='mycontent']", div).size() > 0) - { - // Regular chapters and sub-chapters - $("table.snif tr td a", div).each(function(index) { - if (index > 2 && $(this).attr("title") != "") - { - if ($(this).attr("title").indexOf("-") == -1 || level >= 1) - res[res.length] = [$(this).attr("title"), $(this).attr("href").replace(".html", "_nas.html")]; - else - { - //res[res.length] = [$(this).attr("title"), $(this).attr("href")]; - getListChapsInnerCnt++; - //getListChapsInner($(this).attr("href"), mangaName, obj, callback, res, level + 1); - var subUrl = $(this).attr("href"); - window.setTimeout (function () { getListChapsInner(subUrl, mangaName, obj, callback, res, level + 1); }, 500 * getListChapsInnerCnt); - } - } - }); - } - else if ($("div[id='content']", div).size() > 0) - { - // It is a single chapter so we directly have the images here - var pos = urlManga.lastIndexOf("/"); - var name = urlManga.substr(pos + 1, urlManga.length - pos - 6); - while(name.indexOf("_") != -1) - name = name.replace("_", " "); - if (name.indexOf(mangaName) == -1) - name = mangaName + " " + name; - res[res.length] = [name, urlManga.substr(0, urlManga.length - 5) + "_nas.html"]; - } - - if (getListChapsInnerCnt <= 0) { - callback(res, obj); - getListChapsInnerCnt = 0; - } else { - getListChapsInnerCnt--; - } - } - }); - } - - -var UnixManga = { - //Name of the mirror - mirrorName : "UnixManga", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/UnixManga.png", - //Languages of scans for the mirror - languages : "en", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("http://unixmanga.com") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - type: 'POST', - url: "http://unixmanga.com/onlinereading/manga-lists.html", - data: {word: search}, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $("table.snif tr td a", div).each(function(index) { - res[res.length] = [$(this).attr("title"), $(this).attr("href")]; - }); - callback("UnixManga", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - var res = []; - getListChapsInner(urlManga, mangaName, obj, callback, res, 0); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - var pos1 = curUrl.indexOf("/onlinereading/"); -// var pos2 = curUrl.indexOf("/", pos1 + 15); -// if (pos2 == -1 && $("div[id='mycontent']", doc).size() != 0) -// pos2 = curUrl.indexOf(".html", pos1 + 15); - var pos2 = -1; - if ($("div[id='mycontent']", doc).size() == 0) - pos2 = curUrl.indexOf("/", pos1 + 15); - else - pos2 = curUrl.indexOf(".html", pos1 + 15); - if (pos2 != -1) - { - // Regular chapters - name = curUrl.substr(pos1 + 15, pos2 - pos1 - 15); - currentChapter = curUrl.substr(pos2 + 1, curUrl.length - pos2 - 10); - currentMangaURL = curUrl.substr(0, pos2) + ".html"; - } - else - { - // It is a single chapter so we directly have the images here - name = curUrl.substr(pos1 + 15, curUrl.length - pos1 - 24); - currentChapter = curUrl.substr(pos1 + 15, curUrl.length - pos1 - 24); - currentMangaURL = curUrl.substr(0, curUrl.length - 9) + ".html"; - } - while(name.indexOf("_") != -1) - name = name.replace("_", " "); - while(currentChapter.indexOf("_") != -1) - currentChapter = currentChapter.replace("_", " "); - currentChapterURL = curUrl; - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - $("div[id='content'] a", doc).each( - function(index){ - var url = $(this).attr("href").replace("/?image=", "/"); - var pos = url.indexOf("&server="); - if (pos != -1) - res[res.length] = url.substr(0, pos); - } - ); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scansAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - if ($("div[id='content'] a", doc).size() == 0) - return false; - return ($("div[id='content'] a", doc).first().attr("href").indexOf("?image") != -1); - }, - - //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. - //PREPARE THE PAGE TO HOST NAVIGATION AND THE FULL CHAPTER - //you may need to change elements in the page, add elements, remove others and change css - $("div[id='content'] a", doc).each( - function(index){ - if ($(this).text() != "BACK TO MAIN LIST" && index < 29) - $(this).remove(); - } - ); - $("div[id='content']", doc).before($("")); - $("div[id='content']", doc).before($("
")); - $("div[id='content']", doc).after($("")); - $("div[id='content']", doc).after($("div[id='content'] a").append("
")); - $("div[id='content']", doc).remove(); - $(".navAMR").css("text-align", "center"); - $(".scansAMR", doc).css("width", "100%"); - $(".td2", doc).css("color", "#FFFFFF"); - $("#wrap", doc).css("width", "auto"); - $("#menu", doc).css("width", "800px"); - $("#bottom", doc).remove(); - - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $( image ).attr( "src", urlImg ); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return null; - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - - //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES - $("body > div:empty", doc).remove(); - - //DO ANYTHING ELSE YOU NEED - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Matteo TeoMan Mangano (MM.teoman at gmail dot com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var getListChapsInnerCnt = 0; + function getListChapsInner(urlManga, mangaName, obj, callback, res, level) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + if ($("div[id='mycontent']", div).size() > 0) + { + // Regular chapters and sub-chapters + $("table.snif tr td a", div).each(function(index) { + if (index > 2 && $(this).attr("title") != "") + { + if ($(this).attr("title").indexOf("-") == -1 || level >= 1) + res[res.length] = [$(this).attr("title"), $(this).attr("href").replace(".html", "_nas.html")]; + else + { + //res[res.length] = [$(this).attr("title"), $(this).attr("href")]; + getListChapsInnerCnt++; + //getListChapsInner($(this).attr("href"), mangaName, obj, callback, res, level + 1); + var subUrl = $(this).attr("href"); + window.setTimeout (function () { getListChapsInner(subUrl, mangaName, obj, callback, res, level + 1); }, 500 * getListChapsInnerCnt); + } + } + }); + } + else if ($("div[id='content']", div).size() > 0) + { + // It is a single chapter so we directly have the images here + var pos = urlManga.lastIndexOf("/"); + var name = urlManga.substr(pos + 1, urlManga.length - pos - 6); + while(name.indexOf("_") != -1) + name = name.replace("_", " "); + if (name.indexOf(mangaName) == -1) + name = mangaName + " " + name; + res[res.length] = [name, urlManga.substr(0, urlManga.length - 5) + "_nas.html"]; + } + if (getListChapsInnerCnt <= 0) { + callback(res, obj); + getListChapsInnerCnt = 0; + } else { + getListChapsInnerCnt--; + } + } + }); + } +var UnixManga = { + //Name of the mirror + mirrorName : "UnixManga", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/UnixManga.png", + //Languages of scans for the mirror + languages : "en", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("http://unixmanga.com") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + type: 'POST', + url: "http://unixmanga.com/onlinereading/manga-lists.html", + data: {word: search}, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $("table.snif tr td a", div).each(function(index) { + res[res.length] = [$(this).attr("title"), $(this).attr("href")]; + }); + callback("UnixManga", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + var res = []; + getListChapsInner(urlManga, mangaName, obj, callback, res, 0); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + var pos1 = curUrl.indexOf("/onlinereading/"); +// var pos2 = curUrl.indexOf("/", pos1 + 15); +// if (pos2 == -1 && $("div[id='mycontent']", doc).size() != 0) +// pos2 = curUrl.indexOf(".html", pos1 + 15); + var pos2 = -1; + if ($("div[id='mycontent']", doc).size() == 0) + pos2 = curUrl.indexOf("/", pos1 + 15); + else + pos2 = curUrl.indexOf(".html", pos1 + 15); + if (pos2 != -1) + { + // Regular chapters + name = curUrl.substr(pos1 + 15, pos2 - pos1 - 15); + currentChapter = curUrl.substr(pos2 + 1, curUrl.length - pos2 - 10); + currentMangaURL = curUrl.substr(0, pos2) + ".html"; + } + else + { + // It is a single chapter so we directly have the images here + name = curUrl.substr(pos1 + 15, curUrl.length - pos1 - 24); + currentChapter = curUrl.substr(pos1 + 15, curUrl.length - pos1 - 24); + currentMangaURL = curUrl.substr(0, curUrl.length - 9) + ".html"; + } + while(name.indexOf("_") != -1) + name = name.replace("_", " "); + while(currentChapter.indexOf("_") != -1) + currentChapter = currentChapter.replace("_", " "); + currentChapterURL = curUrl; + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + $("div[id='content'] a", doc).each( + function(index){ + var url = $(this).attr("href").replace("/?image=", "/"); + var pos = url.indexOf("&server="); + if (pos != -1) + res[res.length] = url.substr(0, pos); + } + ); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scansAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + if ($("div[id='content'] a", doc).size() == 0) + return false; + return ($("div[id='content'] a", doc).first().attr("href").indexOf("?image") != -1); + }, + //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. + //PREPARE THE PAGE TO HOST NAVIGATION AND THE FULL CHAPTER + //you may need to change elements in the page, add elements, remove others and change css + $("div[id='content'] a", doc).each( + function(index){ + if ($(this).text() != "BACK TO MAIN LIST" && index < 29) + $(this).remove(); + } + ); + $("div[id='content']", doc).before($("")); + $("div[id='content']", doc).before($("
")); + $("div[id='content']", doc).after($("")); + $("div[id='content']", doc).after($("div[id='content'] a").append("
")); + $("div[id='content']", doc).remove(); + $(".navAMR").css("text-align", "center"); + $(".scansAMR", doc).css("width", "100%"); + $(".td2", doc).css("color", "#FFFFFF"); + $("#wrap", doc).css("width", "auto"); + $("#menu", doc).css("width", "800px"); + $("#bottom", doc).remove(); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $( image ).attr( "src", urlImg ); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return null; + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + //THE FOLLOWING LINE IS NECESSARY IN MOST OF CASES + $("body > div:empty", doc).remove(); + //DO ANYTHING ELSE YOU NEED + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("UnixManga", UnixManga); diff --git a/VNSharing.js b/VNSharing.js index 41b99ec..cf94452 100644 --- a/VNSharing.js +++ b/VNSharing.js @@ -1,246 +1,212 @@ -/*///////////////////////////////////////////////////////////////////////////// -// // -// All Mangas Reader : Follow updates of your favorite mangas sites. // -// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // -// // -/////////////////////////////////////////////////////////////////////////////*/ - -/******************************************************************************************************** - IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. - However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) - of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within - the object doc (example, replace $("select") by $("select", doc) in jQuery). -********************************************************************************************************/ - -var VNSharing = { - //Name of the mirror - mirrorName : "VNSharing", - //True if the mirror can list all of its mangas. - canListFullMangas : true, - //Extension internal link to the icon of the mirror. - mirrorIcon : "img/vnsharing.png", - //Languages of scans for the mirror - languages : "vi", - - //Return true if the url corresponds to the mirror - isMe : function(url) { - return (url.indexOf("truyen.vnsharing.net/") != -1); - }, - - //Return the list of all or part of all mangas from the mirror - //The search parameter is filled if canListFullMangas is false - //This list must be an Array of [["manga name", "url"], ...] - //This function must call callback("Mirror name", [returned list]); - getMangaList : function(search, callback) { - $.ajax( - { - url: "http://truyen.vnsharing.net/DanhSach", - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - var res = []; - $(".listing tr td:first-child a", div).each(function(index) { - var trad = $(this).closest("td").next().text(); - res[res.length] = [$(this).text().trim() + " (" + trad.trim() + ")", "http://truyen.vnsharing.net" + $(this).attr("href")]; - }); - callback("VNSharing", res); - } - }); - }, - - //Find the list of all chapters of the manga represented by the urlManga parameter - //This list must be an Array of [["chapter name", "url"], ...] - //This list must be sorted descending. The first element must be the most recent. - //This function MUST call callback([list of chapters], obj); - getListChaps : function(urlManga, mangaName, obj, callback) { - $.ajax( - { - url: urlManga, - - beforeSend: function(xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - - success: function( objResponse ){ - var div = document.createElement( "div" ); - div.innerHTML = objResponse; - - var res = []; - - $(".listing:first tr td:first-child a", div).each(function(index) { - res[res.length] = [$(this).text().trim(), "http://truyen.vnsharing.net" + $(this).attr("href")]; - }); - - callback(res, obj); - } - }); - }, - - //This method must return (throught callback method) an object like : - //{"name" : Name of current manga, - // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), - // "currentMangaURL": Url to access current manga, - // "currentChapterURL": Url to access current chapter} - getInformationsFromCurrentPage : function(doc, curUrl, callback) { - //This function runs in the DOM of the current consulted page. - var name; - var currentChapter; - var currentMangaURL; - var currentChapterURL; - - name = $("#navsubbar a:first", doc).text().trim(); - var pos = name.indexOf("\n"); - if (pos != -1) name = name.substr(pos).trim(); - var team = $($("#navsubbar a", doc)[1]).text().trim(); - pos = team.indexOf("\n"); - if (pos != -1) team = team.substr(pos).trim(); - name += " (" + team + ")"; - - currentMangaURL = $("#navsubbar a:first", doc).attr("href"); - - currentChapter = $("#selectChapter option:selected", doc).text(); - currentChapterURL = currentMangaURL + "/" + $("#selectChapter option:selected", doc).val(); - - /*console.log(" name : " + name + - " currentChapter : " + currentChapter + - " currentMangaURL : " + currentMangaURL + - " currentChapterURL : " + currentChapterURL);*/ - - callback({"name": name, - "currentChapter": currentChapter, - "currentMangaURL": currentMangaURL, - "currentChapterURL": currentChapterURL}); - }, - - //Returns the list of the urls of the images of the full chapter - //This function can return urls which are not the source of the - //images. The src of the image is set by the getImageFromPageAndWrite() function. - getListImages : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - /*var res = []; - var mg = "http://truyen.vnsharing.net" + $("#navsubbar a:first", doc).attr("href"); - var chap = mg + "/" + $("#selectChapter option:selected", doc).val(); - - $("#selectPage option", doc).each(function(index) { - res[res.length] = chap + "#" + $(this).val(); - }); -*/ - var res = []; - $("script", doc).each(function() { - if ($(this).text().indexOf("lstImages.push(\"") != -1) { - var pos = $(this).text().indexOf("lstImages.push(\""); - while (pos != -1) { - var posf = $(this).text().indexOf("\"", pos + 16); - var url = $(this).text().substring(pos + 16, posf); - res[res.length] = url; - pos = $(this).text().indexOf("lstImages.push(\"", posf); - } - } - }); - return res; - }, - - //Remove the banners from the current page - removeBanners : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("iframe", doc).parents("ins").remove(); - }, - - //This method returns the place to write the full chapter in the document - //The returned element will be totally emptied. - whereDoIWriteScans : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".scansAMR", doc); - }, - - //This method returns places to write the navigation bar in the document - //The returned elements won't be emptied. - whereDoIWriteNavigation : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return $(".navAMR", doc); - }, - - //Return true if the current page is a page containing scan. - isCurrentPageAChapterPage : function(doc, curUrl) { - return ($("#imgCurrent", doc).size() > 0); - }, - - //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. - $("#headnav", doc).next().remove(); - $("#headnav", doc).after($("")); - $("#headnav", doc).after($("
")); - $("#headnav", doc).after($("")); - $(".navAMR", doc).css("text-align", "center"); - $(".navAMR", doc).css("width", "100%"); - }, - - //This method is called to fill the next button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - nextChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - - //This method is called to fill the previous button's url in the manga site navigation bar - //The select containing the mangas list next to the button is passed in argument - previousChapterUrl : function(select, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - - //Write the image from the the url returned by the getListImages() function. - //The function getListImages can return an url which is not the source of the - //image. The src of the image is set by this function. - //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $( image ).attr( "src", urlImg ); - }, - - //If it is possible to know if an image is a credit page or something which - //must not be displayed as a book, just return true and the image will stand alone - //img is the DOM object of the image - isImageInOneCol : function(img, doc, curUrl) { - //This function runs in the DOM of the current consulted page. - return false; - }, - - //This function can return a preexisting select from the page to fill the - //chapter select of the navigation bar. It avoids to load the chapters - getMangaSelectFromPage : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - var res = []; - var mg = $("#navsubbar a:first", doc).attr("href"); - - $("#selectChapter option", doc).each(function(index) { - $(this).val(mg + "/" + $(this).val()); - }); - - return $("#selectChapter", doc); - }, - - //This function is called when the manga is full loaded. Just do what you want here... - doAfterMangaLoaded : function(doc, curUrl) { - //This function runs in the DOM of the current consulted page. - $("body > div:empty", doc).remove(); - } +/*///////////////////////////////////////////////////////////////////////////// +// // +// All Mangas Reader : Follow updates of your favorite mangas sites. // +// Copyright (c) 2011 Pierre-Louis DUHOUX (pl.duhoux at gmail d0t com) // +// // +/////////////////////////////////////////////////////////////////////////////*/ +/******************************************************************************************************** + IMPORTANT NOTE : methods which are running in the DOM of the page could directly use this DOM. + However, if you want to test the mirror with the lab, you must use the two arguments (doc and curUrl) + of these methods to avoid using window.location.href (replaced by curUrl) and manipulate the DOM within + the object doc (example, replace $("select") by $("select", doc) in jQuery). +********************************************************************************************************/ +var VNSharing = { + //Name of the mirror + mirrorName : "VNSharing", + //True if the mirror can list all of its mangas. + canListFullMangas : true, + //Extension internal link to the icon of the mirror. + mirrorIcon : "img/vnsharing.png", + //Languages of scans for the mirror + languages : "vi", + //Return true if the url corresponds to the mirror + isMe : function(url) { + return (url.indexOf("truyen.vnsharing.net/") != -1); + }, + //Return the list of all or part of all mangas from the mirror + //The search parameter is filled if canListFullMangas is false + //This list must be an Array of [["manga name", "url"], ...] + //This function must call callback("Mirror name", [returned list]); + getMangaList : function(search, callback) { + $.ajax( + { + url: "http://truyen.vnsharing.net/DanhSach", + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $(".listing tr td:first-child a", div).each(function(index) { + var trad = $(this).closest("td").next().text(); + res[res.length] = [$(this).text().trim() + " (" + trad.trim() + ")", "http://truyen.vnsharing.net" + $(this).attr("href")]; + }); + callback("VNSharing", res); + } + }); + }, + //Find the list of all chapters of the manga represented by the urlManga parameter + //This list must be an Array of [["chapter name", "url"], ...] + //This list must be sorted descending. The first element must be the most recent. + //This function MUST call callback([list of chapters], obj); + getListChaps : function(urlManga, mangaName, obj, callback) { + $.ajax( + { + url: urlManga, + beforeSend: function(xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function( objResponse ){ + var div = document.createElement( "div" ); + div.innerHTML = objResponse; + var res = []; + $(".listing:first tr td:first-child a", div).each(function(index) { + res[res.length] = [$(this).text().trim(), "http://truyen.vnsharing.net" + $(this).attr("href")]; + }); + callback(res, obj); + } + }); + }, + //This method must return (throught callback method) an object like : + //{"name" : Name of current manga, + // "currentChapter": Name of thee current chapter (one of the chapters returned by getListChaps), + // "currentMangaURL": Url to access current manga, + // "currentChapterURL": Url to access current chapter} + getInformationsFromCurrentPage : function(doc, curUrl, callback) { + //This function runs in the DOM of the current consulted page. + var name; + var currentChapter; + var currentMangaURL; + var currentChapterURL; + name = $("#navsubbar a:first", doc).text().trim(); + var pos = name.indexOf("\n"); + if (pos != -1) name = name.substr(pos).trim(); + var team = $($("#navsubbar a", doc)[1]).text().trim(); + pos = team.indexOf("\n"); + if (pos != -1) team = team.substr(pos).trim(); + name += " (" + team + ")"; + currentMangaURL = $("#navsubbar a:first", doc).attr("href"); + currentChapter = $("#selectChapter option:selected", doc).text(); + currentChapterURL = currentMangaURL + "/" + $("#selectChapter option:selected", doc).val(); + /*console.log(" name : " + name + + " currentChapter : " + currentChapter + + " currentMangaURL : " + currentMangaURL + + " currentChapterURL : " + currentChapterURL);*/ + callback({"name": name, + "currentChapter": currentChapter, + "currentMangaURL": currentMangaURL, + "currentChapterURL": currentChapterURL}); + }, + //Returns the list of the urls of the images of the full chapter + //This function can return urls which are not the source of the + //images. The src of the image is set by the getImageFromPageAndWrite() function. + getListImages : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + /*var res = []; + var mg = "http://truyen.vnsharing.net" + $("#navsubbar a:first", doc).attr("href"); + var chap = mg + "/" + $("#selectChapter option:selected", doc).val(); + $("#selectPage option", doc).each(function(index) { + res[res.length] = chap + "#" + $(this).val(); + }); +*/ + var res = []; + $("script", doc).each(function() { + if ($(this).text().indexOf("lstImages.push(\"") != -1) { + var pos = $(this).text().indexOf("lstImages.push(\""); + while (pos != -1) { + var posf = $(this).text().indexOf("\"", pos + 16); + var url = $(this).text().substring(pos + 16, posf); + res[res.length] = url; + pos = $(this).text().indexOf("lstImages.push(\"", posf); + } + } + }); + return res; + }, + //Remove the banners from the current page + removeBanners : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("iframe", doc).parents("ins").remove(); + }, + //This method returns the place to write the full chapter in the document + //The returned element will be totally emptied. + whereDoIWriteScans : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".scansAMR", doc); + }, + //This method returns places to write the navigation bar in the document + //The returned elements won't be emptied. + whereDoIWriteNavigation : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return $(".navAMR", doc); + }, + //Return true if the current page is a page containing scan. + isCurrentPageAChapterPage : function(doc, curUrl) { + return ($("#imgCurrent", doc).size() > 0); + }, + //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. + $("#headnav", doc).next().remove(); + $("#headnav", doc).after($("")); + $("#headnav", doc).after($("
")); + $("#headnav", doc).after($("")); + $(".navAMR", doc).css("text-align", "center"); + $(".navAMR", doc).css("width", "100%"); + }, + //This method is called to fill the next button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + nextChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + //This method is called to fill the previous button's url in the manga site navigation bar + //The select containing the mangas list next to the button is passed in argument + previousChapterUrl : function(select, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + //Write the image from the the url returned by the getListImages() function. + //The function getListImages can return an url which is not the source of the + //image. The src of the image is set by this function. + //If getListImages function returns the src of the image, just do $( image ).attr( "src", urlImg ); + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $( image ).attr( "src", urlImg ); + }, + //If it is possible to know if an image is a credit page or something which + //must not be displayed as a book, just return true and the image will stand alone + //img is the DOM object of the image + isImageInOneCol : function(img, doc, curUrl) { + //This function runs in the DOM of the current consulted page. + return false; + }, + //This function can return a preexisting select from the page to fill the + //chapter select of the navigation bar. It avoids to load the chapters + getMangaSelectFromPage : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + var res = []; + var mg = $("#navsubbar a:first", doc).attr("href"); + $("#selectChapter option", doc).each(function(index) { + $(this).val(mg + "/" + $(this).val()); + }); + return $("#selectChapter", doc); + }, + //This function is called when the manga is full loaded. Just do what you want here... + doAfterMangaLoaded : function(doc, curUrl) { + //This function runs in the DOM of the current consulted page. + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("VNSharing", VNSharing); diff --git a/Vortex.js b/Vortex.js index 1ce64e4..89e962c 100644 --- a/Vortex.js +++ b/Vortex.js @@ -1,139 +1,138 @@ -var Vortex = { - mirrorName : "Vortex Scans", - canListFullMangas : false, - languages : "en", - isMe : function (url) { - return (url.indexOf("reader.vortex-scans.com") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://reader.vortex-scans.com/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Vortex Scans", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - type : 'POST', - data : { - 'adult' : true - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('reader.vortex-scans.com/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - }, +var Vortex = { + mirrorName : "Vortex Scans", + canListFullMangas : false, + languages : "en", + isMe : function (url) { + return (url.indexOf("reader.vortex-scans.com") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://reader.vortex-scans.com/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Vortex Scans", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + type : 'POST', + data : { + 'adult' : true + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('reader.vortex-scans.com/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Vortex Scans", Vortex); diff --git a/WhuaMangas.js b/WhuaMangas.js index 2a66a36..14f247b 100644 --- a/WhuaMangas.js +++ b/WhuaMangas.js @@ -1,130 +1,129 @@ -var WhuaMangas = { - mirrorName : "Whua! Mangás", - canListFullMangas : true, - mirrorIcon : "img/whuamangas.png", - languages : "pt", - isMe : function (url) { - return (url.indexOf("leitor.whua-mangas.com") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://leitor.whua-mangas.com/reader/list/", - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list.series > .group:has(.element a) > .title > a', div).each(function (index) { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - callback("Whua! Mangás", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res.push([$(this).attr('title'), $(this).attr('href')]); - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement(div); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads.iframe.banner", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('leitor.whua-mangas.com/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement == 'function') { - script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $("#page", doc).empty(); - $(".navAMR", doc).css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "100%"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var WhuaMangas = { + mirrorName : "Whua! Mangás", + canListFullMangas : true, + mirrorIcon : "img/whuamangas.png", + languages : "pt", + isMe : function (url) { + return (url.indexOf("leitor.whua-mangas.com") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://leitor.whua-mangas.com/reader/list/", + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list.series > .group:has(.element a) > .title > a', div).each(function (index) { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback("Whua! Mangás", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res.push([$(this).attr('title'), $(this).attr('href')]); + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement(div); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads.iframe.banner", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('leitor.whua-mangas.com/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement == 'function') { + script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $("#page", doc).empty(); + $(".navAMR", doc).css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "100%"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Whua! Mangás", WhuaMangas); diff --git a/amanteanime.js b/amanteanime.js index 4b8f9ae..b3a05ae 100644 --- a/amanteanime.js +++ b/amanteanime.js @@ -1,108 +1,107 @@ -var amanteanime = { - mirrorName : "amanteanime", - canListFullMangas : false, - mirrorIcon : "img/amanteanime.png", - languages : "en,es", - isMe : function (url) { - return (url.indexOf("online.amanteanime.net") != -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://online.amanteanime.net/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("amanteanime", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var res = []; - $('.list > .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - removeBanners : function(doc, curUrl) { - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('online.amanteanime.net/reader/read/') > -1); - }, - getListImages : function(doc, curUrl) { - return null; - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - $("#page", doc).before($("")); - $("#page", doc).after($("")); - $(".navAMR").css("text-align", "center"); - }, - whereDoIWriteScans : function(doc, curUrl) { - return null; - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() != 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - whereDoIWriteScans : function(doc, curUrl) { - return $('#page', doc); - }, - getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function(img, doc, curUrl) { - return false; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() != 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, +var amanteanime = { + mirrorName : "amanteanime", + canListFullMangas : false, + mirrorIcon : "img/amanteanime.png", + languages : "en,es", + isMe : function (url) { + return (url.indexOf("online.amanteanime.net") != -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://online.amanteanime.net/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("amanteanime", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var res = []; + $('.list > .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + removeBanners : function(doc, curUrl) { + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('online.amanteanime.net/reader/read/') > -1); + }, + getListImages : function(doc, curUrl) { + return null; + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + $("#page", doc).before($("")); + $("#page", doc).after($("")); + $(".navAMR").css("text-align", "center"); + }, + whereDoIWriteScans : function(doc, curUrl) { + return null; + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() != 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + whereDoIWriteScans : function(doc, curUrl) { + return $('#page', doc); + }, + getImageFromPageAndWrite : function(urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function(img, doc, curUrl) { + return false; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() != 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, } - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("amanteanime", amanteanime); diff --git a/kireicake.js b/kireicake.js index a9880f7..6af3176 100644 --- a/kireicake.js +++ b/kireicake.js @@ -1,134 +1,133 @@ -var kireicake = { - mirrorName : "Kirei Cake", - canListFullMangas : false, - mirrorIcon : "img/KireiCake.png", - languages : "en", - isMe : function (url) { - return (url.indexOf("reader.kireicake.com") !== -1); - }, - getMangaList : function (search, callback) { - $.ajax({ - url : "http://reader.kireicake.com/reader/search/", - type : 'POST', - data : { - 'search' : search - }, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback("Kirei Cake", res); - } - }); - }, - getListChaps : function (urlManga, mangaName, obj, callback) { - $.ajax({ - url : urlManga, - beforeSend : function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success : function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse.replace(/ .element > .title > a', div).each(function (index) { - res[res.length] = [$(this).attr('title'), $(this).attr('href')]; - }); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage : function (doc, curUrl, callback) { - var name = $('.tbtitle div a', doc)[0].title; - var currentChapter = $('.tbtitle div a', doc)[1].text; - var currentMangaURL = $('.tbtitle div a', doc)[0].href; - var currentChapterURL = $('.tbtitle div a', doc)[1].href; - callback({ - "name" : name, - "currentChapter" : currentChapter, - "currentMangaURL" : currentMangaURL, - "currentChapterURL" : currentChapterURL - }); - }, - getListImages : function (doc, curUrl) { - var res = []; - $.ajax({ - url : curUrl, - async : false, - success : function (response) { - var div = document.createElement("div"); - div.innerHTML = response; - var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); - pages.forEach(function (page) { - res.push(page.url); - }); - } - }); - return res; - }, - removeBanners : function (doc, curUrl) { - $(".ads", doc).remove(); - }, - whereDoIWriteScans : function (doc, curUrl) { - return $('#page', doc); - }, - whereDoIWriteNavigation : function (doc, curUrl) { - return $(".navAMR", doc); - }, - isCurrentPageAChapterPage : function (doc, curUrl) { - return (curUrl.search('reader.kireicake.com/reader/read/') > -1); - }, - doSomethingBeforeWritingScans : function (doc, curUrl) { - if (typeof doc.createElement === 'function') { - var script = doc.createElement('script'); - script.innerText = "$(document).unbind('keydown');"; - doc.body.appendChild(script); - } - $("#page", doc).before(""); - $("#page", doc).after(""); - $("#page", doc).empty(); - $("#page", doc).css("width", "auto"); - $("#page", doc).css("max-width", "none"); - $(".navAMR").css("text-align", "center"); - $(window).resize(function () { - $("#page", doc).css("max-width", "none"); - $("#page", doc).css("width", "auto"); - }); - }, - nextChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").prev().size() !== 0) { - return $(select).children("option:selected").prev().val(); - } - return null; - }, - previousChapterUrl : function (select, doc, curUrl) { - if ($(select).children("option:selected").next().size() !== 0) { - return $(select).children("option:selected").next().val(); - } - return null; - }, - getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { - $(image).attr("src", urlImg); - }, - isImageInOneCol : function (img, doc, curUrl) { - return false; - }, - getMangaSelectFromPage : function (doc, curUrl) { - return null; - }, - doAfterMangaLoaded : function (doc, curUrl) { - $("body > div:empty", doc).remove(); - } +var kireicake = { + mirrorName : "Kirei Cake", + canListFullMangas : false, + mirrorIcon : "img/KireiCake.png", + languages : "en", + isMe : function (url) { + return (url.indexOf("reader.kireicake.com") !== -1); + }, + getMangaList : function (search, callback) { + $.ajax({ + url : "http://reader.kireicake.com/reader/search/", + type : 'POST', + data : { + 'search' : search + }, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .group > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback("Kirei Cake", res); + } + }); + }, + getListChaps : function (urlManga, mangaName, obj, callback) { + $.ajax({ + url : urlManga, + beforeSend : function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success : function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse.replace(/ .element > .title > a', div).each(function (index) { + res[res.length] = [$(this).attr('title'), $(this).attr('href')]; + }); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage : function (doc, curUrl, callback) { + var name = $('.tbtitle div a', doc)[0].title; + var currentChapter = $('.tbtitle div a', doc)[1].text; + var currentMangaURL = $('.tbtitle div a', doc)[0].href; + var currentChapterURL = $('.tbtitle div a', doc)[1].href; + callback({ + "name" : name, + "currentChapter" : currentChapter, + "currentMangaURL" : currentMangaURL, + "currentChapterURL" : currentChapterURL + }); + }, + getListImages : function (doc, curUrl) { + var res = []; + $.ajax({ + url : curUrl, + async : false, + success : function (response) { + var div = document.createElement("div"); + div.innerHTML = response; + var pages = JSON.parse($(div).html().match(/var pages = .*$/m)[0].replace(/^[^[]*|;$/g, '')); + pages.forEach(function (page) { + res.push(page.url); + }); + } + }); + return res; + }, + removeBanners : function (doc, curUrl) { + $(".ads", doc).remove(); + }, + whereDoIWriteScans : function (doc, curUrl) { + return $('#page', doc); + }, + whereDoIWriteNavigation : function (doc, curUrl) { + return $(".navAMR", doc); + }, + isCurrentPageAChapterPage : function (doc, curUrl) { + return (curUrl.search('reader.kireicake.com/reader/read/') > -1); + }, + doSomethingBeforeWritingScans : function (doc, curUrl) { + if (typeof doc.createElement === 'function') { + var script = doc.createElement('script'); + script.innerText = "$(document).unbind('keydown');"; + doc.body.appendChild(script); + } + $("#page", doc).before(""); + $("#page", doc).after(""); + $("#page", doc).empty(); + $("#page", doc).css("width", "auto"); + $("#page", doc).css("max-width", "none"); + $(".navAMR").css("text-align", "center"); + $(window).resize(function () { + $("#page", doc).css("max-width", "none"); + $("#page", doc).css("width", "auto"); + }); + }, + nextChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").prev().size() !== 0) { + return $(select).children("option:selected").prev().val(); + } + return null; + }, + previousChapterUrl : function (select, doc, curUrl) { + if ($(select).children("option:selected").next().size() !== 0) { + return $(select).children("option:selected").next().val(); + } + return null; + }, + getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) { + $(image).attr("src", urlImg); + }, + isImageInOneCol : function (img, doc, curUrl) { + return false; + }, + getMangaSelectFromPage : function (doc, curUrl) { + return null; + }, + doAfterMangaLoaded : function (doc, curUrl) { + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Kirei Cake", kireicake); diff --git a/mangapanda.js b/mangapanda.js index a11d546..e5721fe 100644 --- a/mangapanda.js +++ b/mangapanda.js @@ -1,157 +1,156 @@ -var mangapanda = { - mirrorName: "Manga Panda", - canListFullMangas: false, - mirrorIcon: "img/mangapanda.png", - languages: "en", - isMe: function (url) { - "use strict"; - return url.indexOf("www.mangapanda.com") !== -1; - }, - getMangaList: function (search, callback) { - "use strict"; - var urlManga = "http://www.mangapanda.com/search/?w=" + search; - $.ajax({ - url: urlManga, - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse; - $(".mangaresultinner .manga_name a", div).each(function () { - res[res.length] = [$(this).text(), "http://www.mangapanda.com" + $(this).attr("href")]; - }); - callback("Manga Panda", res); - } - }); - }, - getListChaps: function (urlManga, mangaName, obj, callback) { - "use strict"; - $.ajax({ - url: urlManga, - beforeSend: function (xhr) { - xhr.setRequestHeader("Cache-Control", "no-cache"); - xhr.setRequestHeader("Pragma", "no-cache"); - }, - success: function (objResponse) { - var div = document.createElement("div"), - res = []; - div.innerHTML = objResponse; - mangaName = $($("#mangaproperties h1", div)[0]).text().trim(); - if (mangaName.substr(mangaName.length - 5, 5) === "Manga") { - mangaName = mangaName.substring(0, mangaName.length - 5).trim(); - } - $("#chapterlist #listing tr td:first-child", div).each(function () { - var txt = "", - inlink = $(this).children("a").attr("href"); - $(this).contents().each(function () { - txt += $(this).text(); - }); - txt = txt.replace(mangaName.trim(), " "); - txt = txt.replace(/(\n| )+/g, " "); - res[res.length] = [txt.trim(), "http://www.mangapanda.com" + inlink]; - }); - res = res.reverse(); - callback(res, obj); - } - }); - }, - getInformationsFromCurrentPage: function (doc, curUrl, callback) { - "use strict"; - var name = $($("#mangainfo h2.c2 a", doc)[0]).text().trim(); - if (name.substr(name.length - 5, name.length) === "Manga") { - name = name.substr(0, name.length - 5); - } - var mangaurl = "http://www.mangapanda.com" + $($("#mangainfo h2.c2 a", doc)[0]).attr("href"); - var currentChapter = $("#mangainfo h1", doc).text(); - currentChapter = currentChapter.replace(name, ""); - var curChapUrl = "http://www.mangapanda.com" + $($("#mangainfo_son a", doc)[0]).attr("href"); - callback({ - "name": name.trim(), - "currentChapter": currentChapter.trim(), - "currentMangaURL": mangaurl.trim(), - "currentChapterURL": curChapUrl.trim() - }); - }, - getListImages: function (doc, curUrl) { - "use strict"; - var res = []; - $("#pageMenu option", doc).each(function (index) { - res[res.length] = "http://www.mangapanda.com" + $(this).val(); - }); - return res; - }, - removeBanners: function (doc, curUrl) { - "use strict"; - $("iframe", doc).remove(); - $("#adtop", doc).remove(); - }, - whereDoIWriteScans: function (doc, curUrl) { - "use strict"; - return $("#imgholder", doc); - }, - whereDoIWriteNavigation: function (doc, curUrl) { - "use strict"; - return $("#navAMRav", doc).add($("#navAMRap", doc)); - }, - isCurrentPageAChapterPage: function (doc, curUrl) { - "use strict"; - return $("img", $("#imgholder", doc)).size() !== 0; - }, - doSomethingBeforeWritingScans: function (doc, curUrl) { - "use strict"; - $("#imgholder", doc).empty(); - $("#imgholder", doc).css("width", "auto"); - $("#imgholder", doc).before($("")); - $("#imgholder", doc).after($("")); - $("#selection", doc).next().remove(); - $("#selection", doc).remove(); - $("#navAMRav", doc).css("text-align", "center"); - $("#navAMRap", doc).css("text-align", "center"); - $("#navi", doc).empty(); - $("#selectmanga", doc).empty(); - $("#wrapper_body", doc).css("width", "auto"); - $("#topchapter", doc).css("width", "950px"); - $("#topchapter", doc).css("text-align", "center"); - }, - nextChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").prev().size() !== 0) return $(select).children("option:selected").prev().val(); - return null; - }, - previousChapterUrl: function (select, doc, curUrl) { - "use strict"; - if ($(select).children("option:selected").next().size() !== 0) return $(select).children("option:selected").next().val(); - return null; - }, - getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { - "use strict"; - $.ajax({ - url: urlImg, - success: function (objResponse) { - var div = document.createElement("div"); - div.innerHTML = objResponse; - var src = $("#imgholder img", div).attr("src"); - $(image).attr("src", src); - } - }) - }, - isImageInOneCol: function (img, doc, curUrl) { - "use strict"; - return false; - }, - getMangaSelectFromPage: function (doc, curUrl) { - "use strict"; - return null; - }, - doAfterMangaLoaded: function (doc, curUrl) { - "use strict"; - $("body > div:empty", doc).remove(); - } +var mangapanda = { + mirrorName: "Manga Panda", + canListFullMangas: false, + mirrorIcon: "img/mangapanda.png", + languages: "en", + isMe: function (url) { + "use strict"; + return url.indexOf("www.mangapanda.com") !== -1; + }, + getMangaList: function (search, callback) { + "use strict"; + var urlManga = "http://www.mangapanda.com/search/?w=" + search; + $.ajax({ + url: urlManga, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse; + $(".mangaresultinner .manga_name a", div).each(function () { + res[res.length] = [$(this).text(), "http://www.mangapanda.com" + $(this).attr("href")]; + }); + callback("Manga Panda", res); + } + }); + }, + getListChaps: function (urlManga, mangaName, obj, callback) { + "use strict"; + $.ajax({ + url: urlManga, + beforeSend: function (xhr) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + xhr.setRequestHeader("Pragma", "no-cache"); + }, + success: function (objResponse) { + var div = document.createElement("div"), + res = []; + div.innerHTML = objResponse; + mangaName = $($("#mangaproperties h1", div)[0]).text().trim(); + if (mangaName.substr(mangaName.length - 5, 5) === "Manga") { + mangaName = mangaName.substring(0, mangaName.length - 5).trim(); + } + $("#chapterlist #listing tr td:first-child", div).each(function () { + var txt = "", + inlink = $(this).children("a").attr("href"); + $(this).contents().each(function () { + txt += $(this).text(); + }); + txt = txt.replace(mangaName.trim(), " "); + txt = txt.replace(/(\n| )+/g, " "); + res[res.length] = [txt.trim(), "http://www.mangapanda.com" + inlink]; + }); + res = res.reverse(); + callback(res, obj); + } + }); + }, + getInformationsFromCurrentPage: function (doc, curUrl, callback) { + "use strict"; + var name = $($("#mangainfo h2.c2 a", doc)[0]).text().trim(); + if (name.substr(name.length - 5, name.length) === "Manga") { + name = name.substr(0, name.length - 5); + } + var mangaurl = "http://www.mangapanda.com" + $($("#mangainfo h2.c2 a", doc)[0]).attr("href"); + var currentChapter = $("#mangainfo h1", doc).text(); + currentChapter = currentChapter.replace(name, ""); + var curChapUrl = "http://www.mangapanda.com" + $($("#mangainfo_son a", doc)[0]).attr("href"); + callback({ + "name": name.trim(), + "currentChapter": currentChapter.trim(), + "currentMangaURL": mangaurl.trim(), + "currentChapterURL": curChapUrl.trim() + }); + }, + getListImages: function (doc, curUrl) { + "use strict"; + var res = []; + $("#pageMenu option", doc).each(function (index) { + res[res.length] = "http://www.mangapanda.com" + $(this).val(); + }); + return res; + }, + removeBanners: function (doc, curUrl) { + "use strict"; + $("iframe", doc).remove(); + $("#adtop", doc).remove(); + }, + whereDoIWriteScans: function (doc, curUrl) { + "use strict"; + return $("#imgholder", doc); + }, + whereDoIWriteNavigation: function (doc, curUrl) { + "use strict"; + return $("#navAMRav", doc).add($("#navAMRap", doc)); + }, + isCurrentPageAChapterPage: function (doc, curUrl) { + "use strict"; + return $("img", $("#imgholder", doc)).size() !== 0; + }, + doSomethingBeforeWritingScans: function (doc, curUrl) { + "use strict"; + $("#imgholder", doc).empty(); + $("#imgholder", doc).css("width", "auto"); + $("#imgholder", doc).before($("")); + $("#imgholder", doc).after($("")); + $("#selection", doc).next().remove(); + $("#selection", doc).remove(); + $("#navAMRav", doc).css("text-align", "center"); + $("#navAMRap", doc).css("text-align", "center"); + $("#navi", doc).empty(); + $("#selectmanga", doc).empty(); + $("#wrapper_body", doc).css("width", "auto"); + $("#topchapter", doc).css("width", "950px"); + $("#topchapter", doc).css("text-align", "center"); + }, + nextChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").prev().size() !== 0) return $(select).children("option:selected").prev().val(); + return null; + }, + previousChapterUrl: function (select, doc, curUrl) { + "use strict"; + if ($(select).children("option:selected").next().size() !== 0) return $(select).children("option:selected").next().val(); + return null; + }, + getImageFromPageAndWrite: function (urlImg, image, doc, curUrl) { + "use strict"; + $.ajax({ + url: urlImg, + success: function (objResponse) { + var div = document.createElement("div"); + div.innerHTML = objResponse; + var src = $("#imgholder img", div).attr("src"); + $(image).attr("src", src); + } + }) + }, + isImageInOneCol: function (img, doc, curUrl) { + "use strict"; + return false; + }, + getMangaSelectFromPage: function (doc, curUrl) { + "use strict"; + return null; + }, + doAfterMangaLoaded: function (doc, curUrl) { + "use strict"; + $("body > div:empty", doc).remove(); + } }; - // Call registerMangaObject to be known by includer if (typeof registerMangaObject == 'function') { registerMangaObject("Manga Panda", mangapanda);