ameboide / webcomic_reader

Webcomic Reader userscript at http://userscripts.org/scripts/show/59842
76 stars 68 forks source link

Simple page-number-in-URL manipulation #30

Open agnesnutter opened 9 years ago

agnesnutter commented 9 years ago

As it is, this program looks for physical buttons linking to previous and next pages, but it would be great if I could set the default option simply to increment or decrement the page number by one. Many (even most) webcomics have a URL scheme that's something like webcomic.com/comic.php?p=#### or webcomic.com/page/####. This solves the following two problems:

1) sometimes, as in Homestuck, the next page button is different every page. The text changes and there's no id or class tag that makes it stand out. 2) sometimes, as in Questionable Content, when you click Next from the penultimate page, it takes you to the base domain name rather than the permalink to that page. This makes saving one's spot difficult.

I looked around and didn't find this setting, but it's possible I missed how to do it. (I expect there's probably some way I could make it work with RegEx or something, but I'm not very familiar with that. Plus, it should be a standard option, I think.)

ameboide commented 9 years ago

Currently there's no automagic setting to do it, but it can be done with a custom function:

return link[pos].replace(/(\d+)(?=\D*$)/, function(n){return parseInt(n)+1;});

As for the issues, 1 can be usually worked around with some path or pattern (like homestuck, it could be font > a) and 2 will lead to it failing on the main page, so I prefer to go for the links whenever possible.

I'll try to add it as one of the standard options to make it easier to use.