anka-213 / webcomic_reader

Webcomic Reader userscript at
https://openuserjs.org/scripts/anka-213/Webcomic_Reader
MIT License
120 stars 27 forks source link

Could you add mangadex.com please? #102

Open SirMrMister opened 6 years ago

SirMrMister commented 6 years ago

With Batoto closing down, it's in the process of becoming (even if temporarily) the go-to online manga reader and follower, so it'd be nice if you could prioritize adding it to the list soon.

Thanks for your time!

Nosgoroth commented 6 years ago

This seems to at least work. If someone who has experience adding sites to the script can improve it and add it, that would be awesome.

screen shot 2018-01-31 at 15 14 22
kobuki commented 6 years ago

@Nosgoroth could you please copy-paste the contents of all your text boxes? I'll try to add mangadex to the script.

anka-213 commented 6 years ago

@Nosgoroth https://github.com/nosgoroth If you press the "F12" button on your keyboard when on the site, the developer tools will pop up. Press the "console" tab and look for the text "Using custom settings:". After that there sould be a copy of the settings in the format that sould be in the script. Could you paste those here, thanks?

El El lör 3 feb. 2018 a las 15:56, kobuki notifications@github.com escribió:

@Nosgoroth https://github.com/nosgoroth could you please copy-paste the contents of all your text boxes? I'll try to add mangadex to the script.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/anka-213/webcomic_reader/issues/102#issuecomment-362818045, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdBO6fsrW9o9EU0Us432zgHOgyQJ1Ioks5tRHOWgaJpZM4RsJHH .

Nosgoroth commented 6 years ago

Here's the json:

{
        url:    'https://mangadex.com/chapter/',
        img:    [['img#current_page']],
        back:   function(html, pos){
                var dhs=document.location.href.split("/");
                var p=parseInt(dhs[dhs.length-1]);
                if(p<=1) { return ''; }
                return dhs.slice(0,-1).join('/')+"/"+(p+pos-1);
                },
        next:   function(html, pos){
                var dhs=document.location.href.split("/");
                var p=parseInt(dhs[dhs.length-1]);
                return dhs.slice(0,-1).join('/')+"/"+(p+pos+1);
                },
        first:  function(html){
                var dhs=document.location.href.split("/");
                return dhs.slice(0,-1).join('/')+"/1";
                },
    },
kobuki commented 6 years ago

I can confirm it works after a simple copy-paste. However the fixed header stripe is making the viewing area smaller. @anka-213 do you think it's possible to hide it while reading? Also, it can't step to first/last image of next/prev chapter.

SirMrMister commented 6 years ago

Header can be hidden by using minimalistic layout.

More importantly though, these settings seem to skip pages. In particular, no matter what manga and chapter, it ALWAYS skips page 5, sometimes 7, 9 and 11, and other times 10-12 and 14.

One time it put page 13 after 17.

onetimeuser123 commented 6 years ago

Here's JSON that that pages correctly and will navigate to next/previous chapter:

{
    url:    'https://mangadex.com/chapter/',
    img:    [['img#current_page']],
    back:   function(html, pos){
            var backLink = '';
            var page = parseInt(html.match(/data\-page=\"(\d+)\"/)[1]);
            if (page <= 1) {
                var prevChapter = parseInt(html.match(/var prev_chapter_id = (\d+);/)[1]);
                if (prevChapter != "0") {
                    var prevPages = parseInt(html.match(/var prev_pages = (\d+);/)[1]);
                    backLink = "/chapter/" + prevChapter + "/" + prevPages;
                }
            } else {
                var prevPage = page - 1;
                backLink = decodeURI(link[pos]).split("/").slice(0, -1).join("/") + "/" + prevPage;
            }
            return backLink;
        },
    next:   function(html, pos){
            var nextLink = '';
            var page = parseInt(html.match(/data\-page=\"(\d+)\"/)[1]);
            var lastPage = parseInt(xpath('//select[@id="jump_page"]/option[last()]/@value', html));
            if (page >= lastPage) {
                var nextChapter = parseInt(html.match(/var next_chapter_id = (\d+);/)[1]);
                if (nextChapter != "0") {
                    nextLink = "/chapter/" + nextChapter + "/1";
                }
            } else {
                var nextPage = page + 1;
                nextLink = decodeURI(link[pos]).split("/").slice(0, -1).join("/") + "/" + nextPage;
            }
            return nextLink;
        },
    first:  function(html){
            var chapter = parseInt(html.match(/var chapter_id = (\d+);/)[1]);
            return "/" + chapter + "/1";
        },
    last:   function(html){
            var chapter = parseInt(html.match(/var chapter_id = (\d+);/)[1]);
            var lastPage = xpath('//select[@id="jump_page"]/option[last()]/@value', html);
            return "/" + chapter + "/" + lastPage;
        },
},
kobuki commented 6 years ago

It works, kind of.

SirMrMister commented 6 years ago

It'd be easier if you shared the string you get from using Import/Export in the site settings.

kobuki commented 6 years ago

Didn't @onetimeuser123 did just that?

SirMrMister commented 6 years ago

Nope, he copied it from the F12 window.

Doing it from the reader's settings, Site settings tab, then clicking "Import/Export" at the bottom would look more like this (this one is an incomplete example):

EDIT: I don't know what I did but that wasn't it.

Pasting there the one from F12 doesn't seem to work.

anka-213 commented 6 years ago

I should fix so those two are the same.

The version from the f12 window is the one that should be inserted in the source code (webcomicreader.user.js). If someone would open a pull request with it, I can merge it so everyone will get the update.

El El tis 20 feb. 2018 a las 13:27, SirMrMister notifications@github.com escribió:

Nope, he copied it from the F12 window.

Doing it from the reader's settings, Site settings tab, then clicking "Import/Export" at the bottom would look more like this (this one is an incomplete example):

{"last":{"url":"https://mangadex.com/chapter/100572/1","title":"Ch. 29 (Tsuki ga Michibiku Isekai Douchuu) - MangaDex "},"layout":"1","fit":"1","confpag":"cs:https://mangadex.com/chapter/"}

Pasting there the one from F12 doesn't seem to work.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/anka-213/webcomic_reader/issues/102#issuecomment-366962229, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdBO6ztIhvt9bI0uW0uDvQuhli9vAqQks5tWrpJgaJpZM4RsJHH .

SirMrMister commented 6 years ago

mangadex.com got changed to mangadex.org.

Trying to get the settings from one to the other without having to copy them again and delete the enters made me think of another feature request:

Be able to access and export the settings for websites you can't access. Without some resemblance of access to the .com, which immedieately redirected to .org, I couldn't get them.

Maurogch commented 6 years ago

Can we get a fix for this? The scripts posted don't work most of the time, upon trying to view the next page, it changes to another manga, and you can't move anymore.