ameboide / webcomic_reader

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

Help adding Site omgbeaupeep.com #44

Open LoLsAlEd opened 9 years ago

LoLsAlEd commented 9 years ago

I was able to get the script to load one chapter using this code but unfourtunutly I am not skilled in Javascript, so I have no clue how to fix it and get the rest of the script working.

// @include        http://www.omgbeaupeep.com/*
{   url:    'omgbeaupeep.com',
    img:    [['#omv .picture']],
},

If someone could help me fix it that would be great.

anka-213 commented 8 years ago

It seems to work just fine with just that. It's easy enough to switch chapter manually, so it doesn't seem to be worth the effort of automating that. You can add extra: [[['.pager']]], as well, so show the pager is visible to simplify the chapter switching.

Is there any specific other feature you are missing?

LoLsAlEd commented 8 years ago

Nah not really, I'm pretty happy with how its working.

Thanks anyway.

anka-213 commented 8 years ago

I decided to make a chapter switcher anyways: ;)

    back: function(html, pos) {
        try {
            return xpath('//a[img[@alt="Previous Page"]]/@href', html);
        } catch (e) {
            var newChapter = xpath('//select[@name="chapter"]/*[@selected]/preceding-sibling::*[1]/@value', html);
            var currChapter = xpath('//select[@name="chapter"]/*[@selected]/@value', html);
            return link[pos].replace(currChapter, newChapter);
        }
    },
    next: function(html, pos) {
        try {
            return xpath('//a[img[@alt="Next Page"]]/@href', html);
        } catch (e) {
            var newChapter = xpath('//select[@name="chapter"]/*[@selected]/following-sibling::*[1]/@value', html);
            var currChapter = xpath('//select[@name="chapter"]/*[@selected]/@value', html);
            return link[pos].replace(currChapter, newChapter).replace(/\/[^\/]*$/, "/1");
        }
    },

The backwards version jumps to the start of the chapter, instead of the end, because I couldn't find a way to determine how many pages a chapter has.