BDSMLR - force endless scrolling

Convert Next >> navigation into Endless scrolling

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         BDSMLR - force endless scrolling
// @namespace    bdsmlr_endless_scrolling
// @version      1.0.0
// @license      BSD
// @description  Convert Next >> navigation into Endless scrolling
// @match        https://bdsmlr.com/
// @match        https://bdsmlr.com/dashboard*
// @match        https://*.bdsmlr.com/
// @match        https://*.bdsmlr.com/post/*
// @match        https://bdsmlr.com/search/*
// @match        https://*.bdsmlr.com/search/*
// @match        https://bdsmlr.com/blog/*
// @match        https://bdsmlr.com/originalblogposts/*
// @match        https://bdsmlr.com/likes*
// @grant        GM_xmlhttpRequest
// @connect      bdsmlr.com
// @run-at document-end
// ==/UserScript==

let processing = false

$(window).scroll(function () {
  if ($(window).scrollTop() >= ($(document).height() - (5 * $(window).height())) - 700) {
    if (processing) {
      return false;
    }

    processing = true;

    const rightLiA = document.querySelector('.rightli a')

    if (rightLiA) {
      const url = rightLiA.href

      GM_xmlhttpRequest({
        method: 'GET',
        url: url,
        headers: {
          "referer": "bdsmlr.com"
        },
        onload: function(response) {
          if ((response.readyState >= 2) && (response.status == 200)) {
            let newImgs = response.responseText.split('<div class="feed clearfix ">').shift().split('feed clearfix del')
            newImgs.shift()
            newImgs = '<div class="feed clearfix del' + newImgs.join('feed clearfix del')

            const lastElement = [...document.querySelectorAll('.feed.clearfix')].pop()
            lastElement.insertAdjacentHTML('beforebegin', newImgs)

            let hasNextPage = response.responseText.includes('" rel="next">')
            if (hasNextPage) {
              rightLiA.href = response.responseText.split('" rel="next">').shift().split('href="').pop().replace(/&amp;/gi, '&')
            } else {
              rightLiA.remove()
            }

            setTimeout(function () { processing = false }, 1000)
          } else {
            processing = false
          }
        },
        ontimeout: function(response) {
          processing = false
        },
        onerror: function(response) {
          processing = false
        }
      })
    }
  }
})