// ==UserScript== // @name Manga OnlineViewer // @description Shows all pages at once in online view: MangaFox, MangaReader/MangaPanda, MangaStream, MangaInn, MangaHere, MangaShare, Batoto, MangaDevil, MangaCow, MangaChapter, 7manga, MangaPirate.net and MangaBee/OneManga.me manga sites. // @version 12.29 // @date 2017-06-07 // @author Tago // @namespace https://github.com/TagoDR // @require https://code.jquery.com/jquery-latest.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/AlertifyJS/1.10.0/alertify.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest // @include /https?://(www.)?mangafox.me/manga/.+/.+// // @include /https?://(www.)?(mangareader|mangapanda)(.net|.com)/.+/.+/ // @include /https?://(www.)?(mangastream|readms)(.net|.com)/r.*/.+/ // @include /https?://(www.)?mangainn.net/manga/chapter/.+/ // @include /https?://(www.)?mangahere.co/manga/.+/.+/ // @include /https?://(www.)?bato.to/reader.*/ // @include /https?://(www.)?(mangaspy|mangamap).com/.+/[0-9]+/ // @include /https?://(www.)?mangadoom.co/.+/[0-9]+/ // @include /https?://(www.)?mangamint.com/[a-z\-]+[0-9]+/ // @include /https?://(www.)?eatmanga.com/Manga-Scan/.+/.+// // @include /https?://.*senmanga.com/.+/.+\/?/ // @include /https?://manga.lyght.net/series/.+\.html/ // @include /https?://(www.)?dynasty-scans.com/chapters/.+/ // @include /https?://(www.)?tenmanga.com/chapter/.+/ // @include /https?://(www.)?mangapark.me/manga/.+/.+/ // @include /https?://(www.)?mangago.me/read-manga/.+/.+/ // @include /https?://(www.)?ninemanga.com/chapter/.+/.+\.html/ // @include /https?://(www.)?mangatown.com/manga/.+/.+/ // @include /https?://(www.)?readmanga.today/.+/[0-9]+/ // @include /https?://(www.)?kissmanga.com/Manga/.+/.+?id=[0-9]+/ // @include /https?://view.thespectrum.net/.+/ // @include /https?://read.egscans.com/.+/ // @include /https?://(www.)?comicastle.org/comic/.+/[0-9]+.* // @include /.+/read/.+/ // @history 12.22 New Themes // @history 12.23 Added custom Theme // @history 12.24 Remove inline Library // @history 12.25 Added ComiCastle // @history 12.27 Added Always Load option // @history 12.28 Fixed keybinds // @history 12.29 Bug Fix // @downloadURL none // ==/UserScript== console.log("Loading " + GM_info.script.name); /*! color-scheme.js, =u;n=0<=u?++o:--o)for(r=a=0;a<=3;r=++a)i[4*n+r]=this.col[n].get_hex(this._web_safe,r);return i},t.prototype.colorset=function(){var t,e;for(t=n(this.colors()),e=[];t.length>0;)e.push(t.splice(0,4));return e},t.prototype.from_hue=function(t){if(null==t)throw"from_hue needs an argument";return this.col[0].set_hue(t),this},t.prototype.rgb2ryb=function(){var t,n,r,o,a,u,s,h,l;return s=1<=arguments.length?e.call(arguments,0):[],null!=s[0]&&i(s[0])&&(s=s[0]),u=s[0],n=s[1],t=s[2],h=Math.min(u,n,t),u-=h,n-=h,t-=h,o=Math.max(u,n,t),l=Math.min(u,n),u-=l,n-=l,t>0&&n>0&&(t/=2,n/=2),l+=n,t+=n,a=Math.max(u,l,t),a>0&&(r=o/a,u*=r,l*=r,t*=r),u+=h,l+=h,t+=h,[Math.floor(u),Math.floor(l),Math.floor(t)]},t.prototype.rgb2hsv=function(){var t,n,r,o,a,u,s,h,l,c;return h=1<=arguments.length?e.call(arguments,0):[],null!=h[0]&&i(h[0])&&(h=h[0]),s=h[0],r=h[1],t=h[2],s/=255,r/=255,t/=255,u=Math.min.apply(Math,[s,r,t]),a=Math.max.apply(Math,[s,r,t]),n=a-u,c=a,n>0?(l=n/a,o=s===a?(r-t)/n:r===a?2+(t-s)/n:4+(s-r)/n,o*=60,o%=360,[o,l,c]):[0,0,c]},t.prototype.rgbToHsv=function(){var t,n,r,o,a,u,s,h,l,c;if(h=1<=arguments.length?e.call(arguments,0):[],null!=h[0]&&i(h[0])&&(h=h[0]),s=h[0],r=h[1],t=h[2],s/=255,r/=255,t/=255,a=Math.max(s,r,t),u=Math.min(s,r,t),o=void 0,l=void 0,c=a,n=a-u,l=0===a?0:n/a,a===u)o=0;else{switch(a){case s:o=(r-t)/n+(r= 0";if(t>1)throw"distance("+t+") - argument must be <= 1";return this._distance=t,this},t.prototype.scheme=function(e){if(null==e)return this._scheme;if(null==t.SCHEMES[e])throw"'"+e+"' isn't a valid scheme name";return this._scheme=e,this},t.prototype.variation=function(e){if(null==e)throw"variation needs an argument";if(null==t.PRESETS[e])throw"'$v' isn't a valid variation name";return this._set_variant_preset(t.PRESETS[e]),this},t.prototype._set_variant_preset=function(t){var e,n,r;for(r=[],e=n=0;n<=3;e=++n)r.push(this.col[e].set_variant_preset(t));return r},n=function(t){var e,r,o;if(null==t||"object"!=typeof t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return e="",null!=t.global&&(e+="g"),null!=t.ignoreCase&&(e+="i"),null!=t.multiline&&(e+="m"),null!=t.sticky&&(e+="y"),new RegExp(t.source,e);o=new t.constructor;for(r in t)o[r]=n(t[r]);return o},t.mutablecolor=function(){function e(e){if(null==e)throw"No hue specified";this.saturation=[],this.value=[],this.base_red=0,this.base_green=0,this.base_blue=0,this.base_saturation=0,this.base_value=0,this.set_hue(e),this.set_variant_preset(t.PRESETS.default)}return e.prototype.hue=0,e.prototype.saturation=[],e.prototype.value=[],e.prototype.base_red=0,e.prototype.base_green=0,e.prototype.base_saturation=0,e.prototype.base_value=0,e.prototype.get_hue=function(){return this.hue},e.prototype.set_hue=function(e){var n,r,o,a,i,u,s,h,l,c;n=function(t,e,n){return t+Math.round((e-t)*n)},this.hue=Math.round(e%360),i=this.hue%15+(this.hue-Math.floor(this.hue)),c=i/15,u=this.hue-Math.floor(i),s=(u+15)%360,o=t.COLOR_WHEEL[u],a=t.COLOR_WHEEL[s],h={red:0,green:1,blue:2,value:3};for(r in h)l=h[r],this["base_"+r]=n(o[l],a[l],c);return this.base_saturation=n(100,100,c)/100,this.base_value/=100},e.prototype.rotate=function(t){var e;return e=(this.hue+t)%360,this.set_hue(e)},e.prototype.get_saturation=function(t){var e,n;return n=this.saturation[t],e=n<0?-n*this.base_saturation:n,e>1&&(e=1),e<0&&(e=0),e},e.prototype.get_value=function(t){var e,n;return n=this.value[t],e=n<0?-n*this.base_value:n,e>1&&(e=1),e<0&&(e=0),e},e.prototype.set_variant=function(t,e,n){return this.saturation[t]=e,this.value[t]=n},e.prototype.set_variant_preset=function(t){var e,n,r;for(r=[],e=n=0;n<=3;e=++n)r.push(this.set_variant(e,t[2*e],t[2*e+1]));return r},e.prototype.get_hex=function(t,e){var n,r,o,a,i,u,s,h,l,c,f,p,_,m,d,v,g;for(l=Math.max.apply(Math,function(){var t,e,n,o;for(n=["red","green","blue"],o=[],e=0,t=n.length;e0?g/l:0,_=[],p=["red","green","blue"],h=0,u=p.length;h 0) { var cancel = false; if (!settings.alwaysLoad) { //Main AlertifyJS CSS $("head").append(""); // Default Theme CSS $("head").append(""); // Custom CSS $("head").append(""); alertify.dialog('waitAlert', function factory() { return { setup: function () { return { buttons: [{ text: "No, cancel!!", key: 27 /*Esc*/ , className: alertify.defaults.theme.ok }], options: { closable: false, transition: "zoom", movable: false, maximizable: false, resizable: false } }; } }; }, false, 'alert'); alertify.waitAlert("Starting MangaOnlineViewer", "Please wait, 3 seconds...
(You can change the settings to Always Load without asking)", function (closeEvent) { cancel = true; console.log("MangaOnlineViwer Aborted "); }); } setTimeout(function () { if (cancel) { return; } if (Manga.before !== undefined) { Manga.before(); } cache.Manga = Manga; $("body > :not(#MangaOnlineViewer)").remove(); $("body").removeClass().addClass(settings.Theme); $("script").remove(); $("head > :not(title, meta)").remove(); //$("head").append(""); reader(); $("#PagesPerSecond option[value=" + settings.Timer + "]").attr("selected", "true"); $("#DefaultZoom option[value=" + settings.Zoom + "]").attr("selected", "true"); $(".ChapterControl a[href*='undefined']").attr("href", ""); configCSS(); setTimeout(function () { try { addPages(); controls(); setKeyDownEvents(); checkImagesLoaded(); console.log("Site rebuild done"); setTimeout(function () { loadPages(); }, 50); } catch (e) { console.log(e); } }, 50); }, settings.alwaysLoad ? 50 : 3000); } } //Inject CSS for this script function configCSS() { $("style, link[type='text/css'], link[href$='css']").remove(); var css = ""; $("head").append(css); var bg = scheme.colors(); var themes = [ // 1-body 2-text 3-lines 4-painel 5-Buttons ["Dark", "#000000", "#ffffff", "#666666", "#333333", "#282828"], ["Light", "#eeeeec", "#2e3436", "#888a85", "#babdb6", "#c8cec2"], ["Clear", "#ffffff", "#2e3436", "#888a85", "#eeeeec", "#d3d7cf"], ["Dark_Blue", "#000000", "#91a0b0", "#586980", "#3e4b5b", "#222c3b"], ["Tango_Blue", "#000000", "#82a0bf", "#3d669b", "#304c77", "#102747"], ["Lime", "#000000", "#8abd59", "#608d34", "#38531f", "#233413"], ["Plum", "#000000", "#ad7fa8", "#75507b", "#49324d", "#311b37"], ["Light_Plum", "#eeeeec", "#5c3566", "#9b71a2", "#ad7fa8", "#d2b8ce"], ["Earthy", "#000000", "#ffffff", "#693d3d", "#46211a", "#683327"], ["Cool_Blues", "#000000", "#c4dfe6", "#66a5ad", "#07575b", "#003b46"], ["Custom_Dark", "#000000", "#" + bg[2], "#" + bg[3], "#" + bg[0], "#" + bg[1]], ["Custom_Light", "#eeeeec", "#" + bg[3], "#" + bg[2], "#" + bg[0], "#" + bg[1]] ]; for (var i = 0; i < themes.length; i++) { addTheme(themes[i]); $("#ThemeSelector").append(""); } if (settings.Theme != "Custom_Dark" && settings.Theme != "Custom_Light") { $("#CustomThemeHue").hide(); } } function addTheme(theme) { $("style[name='" + theme[0] + "']").remove(); var css = ""; $("head").append(css); } //Build the reader main body function reader() { var reader = "
" + " " + "
" + " Bottom" + " Download" + " " + " " + "
" + "
" + " " + "
" + " Download" + " Top" + " " + " " + "
" + "
" + " " + "
" + " Enlarge" + " Restore" + " Reduce" + " Fit Width" + " settings" + "
" + "
Zoom: " + " " + settings.Zoom + " %" + "
" + "
" + " " + "
" + " 0 of " + " " + Manga.quant + " Pages Loaded " + " Go to Page:" + " " + "
" + " " + "
"; $("body").html(reader); } //Add Pages Place holders function addPages() { var pages = [], options = [], thumbs = []; for (var i = 1; i <= Manga.quant; i++) { pages.push( "
" + "
" + " " + " " + " " + " " + " " + " " + " " + i + "" + "
" + " " + "
"); options.push(""); thumbs.push( "
" + " " + " " + i + "" + "
"); } $("#Chapter").append(pages.join("")); $("#gotoPage").append(options.join("")); $("#Navigation").append(thumbs.join("")); } //Converts Images into Base64 function customBase64Encode(inputStr) { // Source: http://stackoverflow.com/questions/8778863/downloading-an-image-using-xmlhttprequest-in-a-userscript/8781262#8781262 var bbLen = 3, enCharLen = 4, inpLen = inputStr.length, inx = 0, jnx, keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", output = "", paddingBytes = 0; var bytebuffer = new Array(bbLen), encodedCharIndexes = new Array(enCharLen); while (inx < inpLen) { for (jnx = 0; jnx < bbLen; ++jnx) { /*--- Throw away high-order byte, as documented at: https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data */ if (inx < inpLen) bytebuffer[jnx] = inputStr.charCodeAt(inx++) & 0xff; else bytebuffer[jnx] = 0; } /*--- Get each encoded character, 6 bits at a time. index 0: first 6 bits index 1: second 6 bits (2 least significant bits from inputStr byte 1 + 4 most significant bits from byte 2) index 2: third 6 bits (4 least significant bits from inputStr byte 2 + 2 most significant bits from byte 3) index 3: forth 6 bits (6 least significant bits from inputStr byte 3) */ encodedCharIndexes[0] = bytebuffer[0] >> 2; encodedCharIndexes[1] = ((bytebuffer[0] & 0x3) << 4) | (bytebuffer[1] >> 4); encodedCharIndexes[2] = ((bytebuffer[1] & 0x0f) << 2) | (bytebuffer[2] >> 6); encodedCharIndexes[3] = bytebuffer[2] & 0x3f; //--- Determine whether padding happened, and adjust accordingly. paddingBytes = inx - (inpLen - 1); switch (paddingBytes) { case 1: // Set last character to padding char encodedCharIndexes[3] = 64; break; case 2: // Set last 2 characters to padding char encodedCharIndexes[3] = 64; encodedCharIndexes[2] = 64; break; default: break; // No padding - proceed } /*--- Now grab each appropriate character out of our keystring, based on our index array and append it to the output string. */ for (jnx = 0; jnx < enCharLen; ++jnx) output += keyStr.charAt(encodedCharIndexes[jnx]); } return output; } //Adds an image to the place-holder div function addImg(index, src, error) { var page = "#Page" + index + " .PageContent"; var img = "PageImg" + index + ""; $(page).append(img).slideToggle(); $("#ThumbNailImg" + index).attr("src", src); } //Adds an optional image just in case the primary does not load function addAltImg(index, src) { $("img#PageImg" + index).attr("altsrc", src); } //Default ajax operation function getHtml(url, action) { $.ajax({ type: "GET", url: url, dataType: "html", async: true, success: action }); } //Load Pages Entry function loadPages() { console.log("Loading Images"); if (Manga.pages !== undefined) { console.log("Method manual bulk"); Manga.pages(addImg, addAltImg, getHtml); } else { if (Manga.page !== undefined) { console.log("Method manual individual"); } else { console.log("Method automatic"); } console.log("Intervals: " + (Manga.timer || settings.Timer || "Default(1000)")); loadImg(0); } } //Load Images on the background function loadImg(index) { if (++index <= Manga.quant) { console.log("Page " + index); setTimeout(function () { if (Manga.page !== undefined) { Manga.page(index, addImg, addAltImg); } else { getHtml(resolveUrl(index), function (html) { addImg(index, $(html).find(Manga.img).attr("src")); }); } loadImg(index); }, Manga.timer || settings.Timer); } } //Get the pages url function resolveUrl(index) { var url = window.location.href; if (Manga.url !== undefined) { url = Manga.url(index); } else if (Manga.data !== undefined) { url = $(Manga.data).eq(index - 1).val(); } else { if (window.location.href.lastIndexOf("/") != window.location.href.length - 1) { url += "/"; } url += index; } return url; } // Generate Zip File for download function generateZip() { if (cache.downloadFiles === 0) { $(".MangaPage img").each(function () { var img = $(this); var str = img.parent().prev().children("span").text(); while (str.length < 3) str = "0" + str; var filename = "Page " + str + ".png"; var src = img.attr("src"); if (src.indexOf("base64") > -1) { var base64 = src.replace("data:image/png;base64,", ""); var i = base64.indexOf(","); if (i !== -1) { base64 = base64.substring(index + 1, base64.length); } cache.zip.file(filename, base64, { base64: true, createFolders: true }); console.log(filename + " Added to Zip from Base64 Image"); cache.downloadFiles++; } else { try { GM_xmlhttpRequest({ method: "GET", url: src, overrideMimeType: "text/plain; charset=x-user-defined", onload: function (e) { var base64 = customBase64Encode(e.responseText); cache.zip.file(filename, base64, { base64: true, createFolders: true }); console.log(filename + " Added to Zip as Base64 Image"); cache.downloadFiles++; } }); } catch (e) { console.log(e); } } }); } if (cache.downloadFiles != cache.Manga.quant) { setTimeout(generateZip, 2000); console.log("Waiting for Files to Download " + cache.downloadFiles + " of " + cache.Manga.quant); } else { var blobLink = document.getElementById("blob"); try { blobLink.download = $(".ViewerTitle:first a").text().replace("(Return to Chapter List)", "").trim() + ".zip"; cache.zip.generateAsync({ type: "blob" }).then(function (content) { blobLink.href = window.URL.createObjectURL(content); console.log("Download Ready"); $("#blob")[0].click(); }); } catch (e) { console.log(e); blobLink.innerHTML += " (not supported on this browser)"; } } } //Checks if all images loaded correctly function checkImagesLoaded() { var p = $(".PageContent:empty").length; var total = $("#Counters b").html(); //$("#NavigationCounters b").html(); $(".PageContent img").filter(function () { var image = $(this); if (image.context.naturalWidth === 0 || image.readyState == "uninitialized") { return true; } else { applyDefaultZoom(this); } return false; }).each(function () { p++; reloadImage($(this)); }); $("#Counters i").html(total - p); $("#NavigationCounters i").html(total - p); NProgress.set((total - p) / total); console.log("Progress: " + (total - p) / total * 100 + "%"); if (p > 0) { setTimeout(function () { checkImagesLoaded(); }, 3000); } else { applyDefaultZoom(); console.log("Images Loading Complete"); $(".download").attr("href", "#download"); console.log("Download Avaliable"); if (settings.DownloadZip) { $("#blob").click(); } } } //Force reload the image function reloadImage(img) { var src = img.attr("src"); if ($(this).attr("altsrc") !== undefined) { var altsrc = img.attr("altsrc"); img.removeAttr("src"); img.attr("altsrc", src); setTimeout(function () { img.attr("src", altsrc); img.removeAttr("width"); }, 500); } else { img.removeAttr("src"); setTimeout(function () { img.attr("src", src); img.removeAttr("width"); }, 500); } } //After pages load apply default Zoom function applyDefaultZoom(page) { var pages = page || ".PageContent img"; var w = settings.Zoom; if (w == 1000) { $("#fitwidth").click(); } else { $("#Zoom b").html(w); $(pages).removeAttr("width"); $(pages).each(function () { $(this).attr("width", $(this).width() * (w / 100)); }); } } //Clean key press configurations and set some when specified function setKeyDownEvents() { try { $(document).unbind("keyup keydown keypress onload"); $(window).unbind("keyup keydown keypress onload"); document.onkeydown = null; document.onkeypress = null; window.onkeydown = null; window.onkeypress = null; window.onload = null; document.body.onload = null; } catch (e) { console.log("Keybinds error: " + e); } function processKey(e) { var a = e.keyCode || e.which; if ($.inArray(a, [39, 46, 190, 37, 44, 188, 43, 107, 61, 45, 109, 42, 106, 56, 104, 53, 101]) != -1) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); switch (a) { case 39: //down:right case 46: //press:right / down:. case 190: //press:. $(".ChapterControl:first .next")[0].click(); break; case 37: //down:left case 44: //press:left / down:, case 188: //press:, $(".ChapterControl:first .prev")[0].click(); break; case 43: //+ case 107: //numpad+ case 61: //= $("#enlarge").click(); break; case 45: //- case 109: //numpad- $("#reduce").click(); break; case 42: //5 case 106: //numpad5 case 56: //8 case 104: //numpad8 $("#restore").click(); break; case 53: //* case 101: //numpad* $("#fitwidth").click(); break; } return false; } } if (navigator.userAgent.match(/mozilla/i)) { $(document).keypress(processKey); } else { $(document).keydown(processKey); } } //Controls for the extra features added to the sites function controls() { // Size Controls $("#enlarge").click(function () { $("#Zoom b").html(parseInt($("#Zoom b").html()) + 10); $(".PageContent img").removeAttr("width"); $(".PageContent img").each(function () { $(this).attr("width", $(this).width() * ($("#Zoom b").html() / 100)); }); }); $("#reduce").click(function () { $("#Zoom b").html(parseInt($("#Zoom b").html()) - 10); $(".PageContent img").removeAttr("width"); $(".PageContent img").each(function () { $(this).attr("width", $(this).width() * ($("#Zoom b").html() / 100)); }); }); $("#restore").click(function () { $("#Zoom b").html("100"); $(".PageContent img").removeAttr("width"); }); $("#fitwidth").click(function () { $("#Zoom b").html("1000"); $(".PageContent img").each(function () { $(this).attr("width", $("html").width()); }); }); $("#fitIfOversized").change(function () { $("#Chapter").toggleClass("fitWidthIfOversized"); if ($(this).is(":checked")) { setValueGM("MangaFitWidthIfOversized", true); } else { setValueGM("MangaFitWidthIfOversized", false); } console.log("fitIfOversized: " + getValueGM("MangaFitWidthIfOversized")); }); $("#alwaysLoad").change(function () { if ($(this).is(":checked")) { setValueGM("MangaAlwaysLoad", true); } else { setValueGM("MangaAlwaysLoad", false); } console.log("alwaysLoad: " + getValueGM("MangaAlwaysLoad")); }); $("#showThumbnails").change(function () { $("#Navigation").toggleClass("disabled"); if ($(this).is(":checked")) { setValueGM("MangaShowThumbnails", true); } else { setValueGM("MangaShowThumbnails", false); } console.log("showThumbnails: " + getValueGM("MangaShowThumbnails")); }); //Download $("#downloadZip").change(function () { if ($(this).is(":checked")) { setValueGM("MangaDownloadZip", true); var msg = alertify.alert("Attention", "Next time a chapter finish loading you will be promted to save automatically"); msg.show(); } else { setValueGM("MangaDownloadZip", false); } console.log("downloadZip: " + getValueGM("MangaDownloadZip")); }); $("#blob").one("click", function () { generateZip(); }); $("#downloadManga").click(function () { $("#blob")[0].click(); }); $("#PagesPerSecond").change(function () { setValueGM("MangaTimer", $(this).val()); }); $("#DefaultZoom").change(function () { var w = $(this).val(); $("#Zoom b").html(w); setValueGM("MangaZoom", w); settings.Zoom = w; applyDefaultZoom(); }); // Theme Control $("#ThemeSelector").change(function () { $("#MangaOnlineViewer , body").removeClass(); $("#MangaOnlineViewer , body").addClass($(this).val()); setValueGM("MangaTheme", $(this).val()); if ($(this).val() == "Custom_Dark" || $(this).val() == "Custom_Light") { $("#CustomThemeHue").show(); } else { $("#CustomThemeHue").hide(); } }); new jscolor(document.getElementById("CustomThemeHue")); $("#CustomThemeHue").change(function () { var value = $(this).val(); console.log("Custom:" + value); var bg = scheme.from_hex(value).colors(); addTheme(["Custom_Dark", "#000000", "#" + bg[2], "#" + bg[3], "#" + bg[0], "#" + bg[1]]); addTheme(["Custom_Light", "#eeeeec", "#" + bg[3], "#" + bg[2], "#" + bg[0], "#" + bg[1]]); setValueGM("MangaCustomTheme", value); }); // Goto Page and ThumbNails function scrollToElement(ele) { $(window).scrollTop(ele.offset().top).scrollLeft(ele.offset().left); } $("#gotoPage").bind("change", function () { scrollToElement($("#Page" + $(this).val())); }); $(".ThumbNail").bind("click", function () { scrollToElement($("#Page" + $(this).find("span").html())); }); //Settings Control $("#settings").click(function () { $("#ViewerControls").slideToggle(); $("#ImageOptions").toggleClass("settingsOpen"); $("#Navigation").toggleClass("visible"); }); //Individual Page functions //Reload Page $(".Reload").click(function () { reloadImage($(this).parents(".MangaPage").find(".PageContent img")); }); //ZoomIn $(".ZoomIn").click(function () { var img = $(this).parents(".MangaPage").find(".PageContent img"); img.attr("width", img.width() + (img.width() / 3)); }); //ZoomOut $(".ZoomOut").click(function () { var img = $(this).parents(".MangaPage").find(".PageContent img"); img.attr("width", img.width() - (img.width() / 3)); }); //ZoomRestore $(".ZoomRestore").click(function () { $(".PageContent img").removeAttr("width"); }); //ZoomWidth $(".ZoomWidth").click(function () { var img = $(this).parents(".MangaPage").find(".PageContent img"); img.attr("width", $("html").width()); }); //Hide $(".Hide").click(function () { var img = $(this).parents(".MangaPage").find(".PageContent"); img.slideToggle("slow"); }); } $.MangaOnlineViewer = { start: function (m) { main(m); }, setSites: function (extraSites) { sites = extraSites; } }; var m = [ // == FoOlSlide ======================================================================================================================= { name: "FoOlSlide", url: /a^/, run: function () { return { title: $("title").text().trim(), series: $("div.tbtitle div.text a:first").attr("href"), quant: $(".topbar_right .dropdown li").length, prev: "#", next: "#", url: function (i) { var url = window.location.href.substr(0, window.location.href.lastIndexOf("/")) + "/"; return url.match(/page\/$/ ? url : url += "page/") + i; }, img: "img.open" }; } }, // == MangaFox ======================================================================================================================== { name: "MangaFox", url: /mangafox/, run: function () { return { title: $("#series .no").text().trim(), series: $("#series a:last").attr("href"), quant: $("select.m:first option:last").prev().val(), prev: $("#chnav p:first a").attr("href"), next: $("#chnav p:last a").attr("href"), url: function (i) { return i + ".html"; }, img: "img#image" }; } }, // == MangaReader ===================================================================================================================== { name: "MangaReader", url: /(mangareader|mangapanda)/, run: function () { return { title: $("#mangainfo h1").text(), series: $("#mangainfo a").attr("href"), quant: $("select#pageMenu option:last").html(), prev: $("#mangainfo_bas a:last").attr("href"), next: $("#mangainfo_bas a:first").attr("href"), img: "img#img", before: function () { if (window.location.pathname.match(/\/.+\/.+\/chapter-[0-9]+.*/)) { var path = window.location.pathname.split("/"); window.location.pathname = "/" + path[2] + "/" + path[3].match(/[0-9]+/); } else if (window.location.search) { window.location.href = window.location.pathname; } } }; } }, // == MangaStream ===================================================================================================================== { name: "MangaStream", url: /(mangastream|readms)/, run: function () { return { title: $(".btn:eq(1)").text().trim(), series: $("div.controls div.btn-group ul.dropdown-menu:first li a:last").attr("href"), quant: $("div.controls div.btn-group ul.dropdown-menu li:last").text().match(/[0-9]+/), prev: $(".dropdown-menu:eq(1) a").eq($(".dropdown-menu:eq(1) a").index($(".dropdown-menu:eq(1) a[href*='" + location.pathname + "']")) + 1).attr("href"), next: $(".dropdown-menu:eq(1) a").eq($(".dropdown-menu:eq(1) a").index($(".dropdown-menu:eq(1) a[href*='" + location.pathname + "']")) - 1).attr("href"), url: function (i) { return window.location.href.substring(0, window.location.href.lastIndexOf("\/") + 1) + i; }, img: "img#manga-page" }; } }, // == MangaInn ======================================================================================================================= { name: "MangaInn", url: /mangainn/, run: function () { return { title: $("#gotomangainfo2").text().replace(" - ", ""), series: $("#gotoMangaInfo").attr("href"), quant: $("select#cmbpages option:last").html(), prev: $("#chapters option:selected").prev().val(), next: $("#chapters option:selected").next().val(), url: function (i) { return location.href + "/page_" + i; }, img: "img#imgPage" }; } }, // == MangaHere ======================================================================================================================= { name: "MangaHere", url: /mangahere/, run: function () { return { title: $(".title h1").text(), series: $("div.title h2 a").attr("href"), quant: $(".right select:first option:last").html(), prev: $("#top_chapter_list option:selected").prev().val(), next: $("#top_chapter_list option:selected").next().val(), data: $(".right select.wid60:first").html().replace(/(\n *)/g, ""), img: "img#image" }; } }, // == Batoto ========================================================================================================================== { name: "Batoto", url: /bato\.to/, run: function () { return { title: $(".moderation_bar li:first").text(), series: $("div.moderation_bar a:first").attr("href"), quant: $("select#page_select:first option").length, prev: $("img[src$='pprev.png']:first").parent().attr("href"), next: $("img[src$='nnext.png']:first").parent().attr("href"), url: function (i) { return window.location.hash.replace("#", "/areader?id=") + "&p=" + i; }, img: "#comic_page" }; } }, // == WPManga ========================================================================================================================= { name: "WPManga", url: /(mangaspy|mangamap)/, run: function () { return { title: $(".wpm_pag h1").text().trim(), series: $("h1.ttl a").attr("href"), quant: $("select.cbo_wpm_pag:first option:last").html(), prev: $(".cbo_wpm_chp").attr("onchange").replace(/location.href=\'/, "").replace(/\'.+/, $(".cbo_wpm_chp option:selected").next().val()), next: $(".cbo_wpm_chp").attr("onchange").replace(/location.href=\'/, "").replace(/\'.+/, $(".cbo_wpm_chp option:selected").prev().val()), url: function (i) { var pathname = window.location.pathname.split("/"); return "/" + pathname[1] + "/" + pathname[2] + "/" + i + "/"; }, img: "img.manga-page , .prw > a img, .prw a img" }; } }, // == MangaDoom ======================================================================================================================= { name: "MangaDoom", url: /mangadoom/, run: function () { return { title: $(".widget-heading").text().trim(), series: $(".widget-heading a").attr("href"), quant: $(".selectPage:first option").length - 1, prev: $(".chapterSelect:first option:selected").next().val(), next: $(".chapterSelect:first option:selected").prev().val(), data: $(".selectPage:first option:not(:first)"), img: "img.img-responsive" }; } }, // == SenManga ======================================================================================================================== { name: "SenManga", url: /senmanga/, run: function () { return { title: $(".title").text().trim(), series: $(".title a").attr("href"), quant: $("select[name='page'] option:last").val(), prev: $(".title a").attr("href") + $("select[name='chapter'] option:selected").next().val(), next: $(".title a").attr("href") + $("select[name='chapter'] option:selected").prev().val(), url: function (i) { var pathname = window.location.pathname.split("/"); return "/" + pathname[1] + "/" + pathname[2] + "/" + i + "/"; }, img: "#picture", before: function () { $("body").contents().filter(function () { return this.nodeType == 3; //Node.TEXT_NODE }).remove(); } }; } }, // == EatManga ======================================================================================================================== { name: "EatManga", url: /eatmanga/, run: function () { return { title: $("#main_content h1").text().split(",")[0].trim(), series: $("ul#crumbs li a:eq(2)").attr("href"), quant: $("select#pages option:last").html(), prev: $("#top_chapter_list option:selected").next().val(), next: $("#top_chapter_list option:selected").prev().val(), data: $("select#pages").html(), img: "#eatmanga_image , #eatmanga_image_big" }; } }, // == MangaMint ====================================================================================================================== { name: "MangaMint", url: /mangamint/, run: function () { return { title: $("div#squeeze2 h2 a").text(), series: $("div#squeeze2 h2 a").attr("href"), quant: $("#manga_page option").length, prev: $("#select_node option:selected").prev().val(), next: $("#select_node option:selected").next().val(), url: function (i) { return window.location.href + "?page=" + (i - 1); }, img: "#images a img" }; } }, // == MangaLyght ====================================================================================================================== { name: "MangaLyght", url: /manga.lyght/, run: function () { return { title: $("div.entry h1 a").text().trim(), series: $("div.entry h1 a").attr("href"), quant: $(".selectpage option").length, prev: (window.location.pathname + "?ch=" + $(".selectchapter option:selected").prev().val()).replace(" ", "+"), next: (window.location.pathname + "?ch=" + $(".selectchapter option:selected").next().val()).replace(" ", "+"), data: $("form[name='pageSelector1']").attr("action") + "?ch=" + $(".selectchapter option:selected").val().replace(" ", "+") + "&page=", url: function (i) { return this.data + i; }, img: "#mainimage" }; } }, // == DynastyScans ==================================================================================================================== { name: "Dynasty-Scans", url: /dynasty\-scans/, run: function () { return { data: JSON.parse($("script:last").html().match(/\[.+\]/)), title: $("#chapter-title").text(), series: "#", quant: JSON.parse($("script:last").html().match(/\[.+\]/)).length, prev: "#", next: "#", page: function (i, addImg, addAltImg) { addImg(i, this.data[i - 1].image); } }; } }, // == TenManga ======================================================================================================================== { name: "TenManga", url: /tenmanga/, run: function () { return { title: $(".read-page a:nth(2)").text().replace("ยป", "").trim(), series: $(".read-page a:nth(1)").attr("href"), quant: $(".sl-page:first option").length, prev: $(".sl-chap:first option:selected").next().val(), next: $(".sl-chap:first option:selected").prev().val(), data: $(".sl-page:first option"), img: ".manga_pic" }; } }, // == MangaPark ======================================================================================================================= { name: "MangaPark", url: /mangapark/, run: function () { return { title: $(".loc a:first").text().trim(), series: "/manga/" + window.location.pathname.split("/")[2], quant: $("#sel_page_1 option").length, prev: $(".info a:nth(0)").attr("href"), next: $(".info a:nth(1)").attr("href"), img: ".img" }; } }, // == ReadManga.Today ================================================================================================================= { name: "ReadManga.Today", url: /readmanga.today/, run: function () { return { title: $("title").text().trim(), series: $(".btn:nth(4)").attr("href"), quant: $("select[name='category_type']:last option").length, prev: $("select[name='chapter_list'] option:selected").next("option").val(), next: $("select[name='chapter_list'] option:selected").prev("option").val(), pages: function (addImg, addAltImg, getHtml) { getHtml(window.location + "/all-pages", function (html) { var imgs = $(html).find("img.img-responsive-2"); for (var index = 1; index <= imgs.length; index++) { addImg(index, $(imgs[index - 1]).attr("src")); } }); } }; } }, // == EGScans ========================================================================================================================= { name: "EGScans", url: /read.egscans/, run: function () { return { title: $("select[name='manga'] option:selected").text().trim(), series: "#", quant: img_url.length - 1, prev: prev_chap, next: next_chap, data: img_url, page: function (i, addImg, addAltImg) { addImg(i, this.data[i]); }, before: function () { $(img_url).each(function (index, value) { var img = new Image(); img.src = value; }); } }; } }, // == KissManga ======================================================================================================================= { name: "KissManga", url: /kissmanga/, run: function () { return { title: $("#navsubbar a").text(), series: $("#navsubbar a").attr("href"), quant: $("#selectPage option:last").html() || $("#divImage img").length, prev: $(".selectChapter:first option:selected").prev().val(), next: $(".selectChapter:first option:selected").next().val(), data: lstImages, page: function (i, addImg, addAltImg) { addImg(i, this.data[i - 1]); } }; } }, // == MangaGo ========================================================================================================================= { name: "MangaGo", url: /mangago/, run: function () { return { title: $("#series").text(), series: $("#series").attr("href"), quant: $(".page a:first").text().replace(/page 1 of /, ""), prev: "#", next: "#", data: $(".page a"), url: function (i) { return $(this.data[i - 1]).attr("href"); }, img: "#page1" }; } }, // == NineManga ======================================================================================================================= { name: "NineManga", url: /ninemanga/, run: function () { return { title: $(".tip a:first").text(), series: $(".subgiude a:nth(1)").attr("href"), quant: $("#page:first option").length, prev: $(".chnav a:first").attr("href"), next: $(".chnav a:nth(1)").attr("href"), data: $("#page:first option"), img: ".manga_pic" }; } }, // == MangaTown ======================================================================================================================= { name: "MangaTown", url: /mangatown/, run: function () { return { title: $(".title h1").text(), series: $(".title h2 a").attr("href"), quant: $(".page_select select:first option").length, prev: $("#top_chapter_list option:selected").prev().val(), next: $("#top_chapter_list option:selected").next().val(), data: $(".page_select select option"), img: "#image" }; } }, // == TheSpectrum ===================================================================================================================== { name: "TheSpectrum", url: /thespectrum/, run: function () { return { title: $(".viewerLabel:nth(1)").text(), series: "#", quant: $(".selectpage option").length, prev: window.location.pathname + "?ch=" + $(".selectchapter option:selected").prev().val(), next: window.location.pathname + "?ch=" + $(".selectchapter option:selected").next().val(), data: window.location.pathname + "?" + $("form").serialize().substring(0, $("form").serialize().lastIndexOf("=")) + "=", url: function (i) { return this.data + i; }, img: "#imgContainer img" }; } }, // == ComiCastle ====================================================================================================================== { name: "ComiCastle", url: /comicastle/, run: function () { return { title: $(".form-control:first option:selected").text(), series: $(".navbar-header a").attr("href"), quant: $(".form-control:last option").length, prev: $(".form-control:first option:selected").prev().val(), next: $(".form-control:first option:selected").next().val(), data: $(".form-control:last option"), img: ".chapter-img" }; } } ]; $.MangaOnlineViewer.start(m); })(jQuery);