Manga Loader (unmaintained)

Support for over 70 sites! Loads manga chapter into one page in a long strip format, supports switching chapters, minimal script with no dependencies, easy to implement new sites, loads quickly and works on mobile devices through bookmarklet

< Feedback on Manga Loader (unmaintained)

Question/comment

§
Posted: 31 Mei 2015

Problem identifying correct identifiers for Hentai Rules gallery

As it's not supported at the moment, I've been attempting to make the script support the Hentai Rules gallery myself to little success so far (and here I was thinking it would be easy, though my regex and css is rather rusty).

Take http://www.hentairules.net/galleries4/picture.php?/702/category/8 for example.

This is my best attempt so far (not making it universally functional on all the different iterations of the galleries there are for now):

{ // HentaiRulesGallery
match: "^http://www.hentairules.net/galleries4/picture.php?/.*/category/8",
img: '.theImage > #theMainImage',
next: '.navThumbs > a > linkNext',
},

In any case, it's not working. Where lies the error?

fuzetsuPembuat
§
Posted: 31 Mei 2015
Edited: 31 Mei 2015

Hmmm, some sites are trickier than others, it really depends on how cleanly coded the site in question is and how descriptive the IDs and classes are.

Did you add the @match at the top of the script? I forget that myself sometimes. It helps you debug why it isn't working, if the match isn't working it'll say something like "no implementation for this url" in the console. If the img matcher isn't working it'll say failed to retrieve 'img', and the same for the 'next'.

In this case I see a couple issues, the ? in the regex needs to be escaped, although I would just forgo it and go with a wildcard after picture.php

The img selector is pretty close but theImage is an ID not a class. So it should just be #theImage > #theMainImage if anything, but since it's an ID anyway you can just leave it at #theMainImage since that's already specific enough.

The next selector is also close but #linkNext would have been enough, since it's an ID.

This is how I implemented it.

{
  name: 'hentai-rules',
  match: "^http://www\\.hentairules\\.net/galleries[0-9]+/picture\\.php.+",
  img: '#theMainImage',
  next: '#linkNext',
  imgmod: {
    altProp: 'data-src'
  },
  numpages: function(cur) {
    return parseInt(getEl('.imageNumber').textContent.replace(/([0-9]+)\/([0-9]+)/, cur ? '$1' : '$2'));
  },
  curpage: function() {
    return this.numpages(true);
  }
}

The name, numpages, and curpage aren't necessary, but they help. The imgmod + altProp are there to specify an alternate source of the img url. It looks like the site lazy loads the images so sometimes if the script tries to get the url from the src attribute directly it'll be a progress bar gif instead of the actual image, getting the url from the data-src attribute prevents that.

Since I coded it anyway, I added it in v1.6.11.

EDIT: I noticed what you meant about making it work on every kind of gallery, that's an easy one I'd just change the match to "^http://www\\.hentairules\\.net/galleries[0-9]+/picture\\.php.+", v1.6.12

fuzetsuPembuat
§
Posted: 31 Mei 2015
Edited: 31 Mei 2015

If you're interested you can try adding:

// @match http://www.hentairules.net/galleries*/picture.php*

to the top of the script with the other @match declarations (if you didn't have it already), and:

{ // hentai-rules
  match: "^http://www\\.hentairules\\.net/galleries[0-9]+/picture\\.php.+",
  img: '#theMainImage',
  next: '#linkNext',
}

to the array of implementations. You'll see that it works even without the other stuff and that your original code was actually pretty close.

The advantage of curpage is that it'll properly number the starting page if you don't start from the first one and the advantage of numpages is that you'll be able to see how may pages are left in the gallery before actually reaching the end.

§
Posted: 01 Juni 2015

Ah, cool. I had actually forgotten to add the @match as you pointed out, and I wasn't sure the IDs were enough (I had the img and next as you do now as my first attempt, but thought it didn't work because they weren't specific enough).

The numpages and curpage were beyond my capabilities though, as I wasn't even sure if that was possible seeing how there were no index visible.

Thanks for the educational walkthrough on top of it.

Post reply

Sign in to post a reply.