Next page script

enter something useful

2018-04-09 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name       Next page script
// @namespace  http://use.i.E.your.homepage/
// @version    0.7
// @description  enter something useful
// @match      *://www.limundo.com/*
// @match      *://www.kupindo.com/*
// @match      *://www.vukajlija.com/*
// @match      *://vukajlija.com/*
// @match      *://www.kupujemprodajem.com/*
// @match      *://www.ana.rs/forum/*
// @match      *://www.polovniautomobili.com/*
// @match      *://www.2bike.rs/cikloberza/mali-oglasi*
// @require	   http://code.jquery.com/jquery-2.1.1.min.js
// @copyright  2012+, You
// ==/UserScript==
jQuery.noConflict();
(function ($) {
    console.log('--- Next page script ----');
    var end = false;
    var pages = [
    ];
    var loader = $('<div/>', {
        html: 'Loading...'
    }) .css({
        position: 'fixed',
        bottom: 0,
        right: 0,
        background: 'green',
        color: 'white',
        padding: '10px',
        'font-size': '16px',
        display: 'none',
        'z-index': 1000
    }) .appendTo($('body'));
    var gotoTop = $('<div/>', {
        html: '&uarr;'
    }) .css({
        position: 'fixed',
        bottom: 0,
        right: 0,
        background: 'green',
        color: 'white',
        padding: '10px',
        width: '50px',
        'text-align': 'center',
        'font-size': '16px',
        cursor: 'pointer'
    }) .appendTo($('body')) .on('click', function () {
        $(window) .scrollTop(0);
    });
    var sites = {
        'limundo': {
            link: '.pagination li:eq(-2) a',
            content: '#main'
        },
        'kupindo': {
            link: 'a.next_prev_link:not(:first-child)',
            content: '#container_right'
        },
        'vukajlija': {
            link: 'li.next_page a',
            content: '#left-column'
        },
        'kupujemprodajem': {
            link: function ($page) {
                var f = document.forms.pagingList;
                var currentPageLink = $page.find('li.this-page').last();

                //check if there is next page (link sledeca)
                if (!currentPageLink.next().is('li')){
                    return null;
                }
                currentPage = currentPageLink.html();
                if (currentPage) {
                   f.elements['data[page]'].value = parseInt(currentPage) + 1;
                   return 'search.php?' + $(f) .serialize();
                } else {
                    return null;
                }

            },
            content: '#searchResultTableHolder',
            specific: function ($currentPage, $loadedPage) {
                //because pagging is out of content (after content in dom) this change is needed
                //to know on which page you are currently on
                var pagging = $loadedPage.find('.pageBarHolder').last()[0].outerHTML;
                $currentPage
                    .find(this.content)
                    .append(pagging);
                $currentPage.find('.pageBarHolder').last().html(pagging);
            }
        },
        'ana': {
            link: 'a.navPages:last',
            content: '#main_content_section'
        },
        '2bike': {
            link: '.pagination .next a',
            content: '.listingWrapper'
        },
        'polovniautomobili': {
            link: '.js-pagination-next',
            content: '.js-hide-on-filter:nth-of-type(3)'
        }
    };
    var site = null,
        $lastLoadedPage = null,
        $win = $(window),
        win = window,
        $doc = $(document),
        winHeight = window.innerHeight,
        //content left to trigger loading, 0.8 of current viewport height
        bottomTrigger = winHeight * 0.8;

    var contentHeightToScroll = function () {
        //content left to scroll, under the viewport
    	return $doc.height() - ($win.scrollTop() + winHeight);
    };

    //next image script for kupujemprodajme
    $('body').on('keydown', function (e) {
        switch(e.keyCode) {
            case 37:
                $('.big-left-arrow').click();
                break;
            case 39:
                $('.big-right-arrow').click();
                break;
        }
    });

    $win.scroll(function () {
        if (contentHeightToScroll() < bottomTrigger) {
            if (!site) {
                $.each(sites, function (siteKey, siteData) {
                    if (location.href.indexOf(siteKey) !== - 1) {
                        site = siteData;
                        return false;
                    }
                });
            }

            var url;
            if ($.type(site.link) == 'string') {
                var link = $(site.link) .last();
                if (link.length) {
                    url = link.attr('href');
                }
            } else {
                url = site.link($lastLoadedPage || $('body'));
            }
            if (url) {
                if (pages.indexOf(url) != - 1) {
                    return ;
                }
                console.log('load: ' + url);

                loader.show();
                pages.push(url);
                $.get(url, function (data) {
                    loader.hide();
                    console.log('done');
                    //debugger;
                    console.log($(site.content));
                    data = $(data);
                    $lastLoadedPage = data;
                    data.find(site.content).find('script').remove();
                    $(site.content).append(data.find(site.content).children());
                    if (site.specific) {
                        site.specific($('body'), $lastLoadedPage);
                    }
                });
            }
        }
    });
}(jQuery));