2021-10-11 22:36
I created a small script that will help you faster skim CamRips archive - basically works as infinite list so you can scroll faster without having to wait for the page to load
I thought I can share it - maybe someone finds it useful
how to use:
I thought I can share it - maybe someone finds it useful
how to use:
- open https://www.camrips.net/sex/couple/page/212/ or any page you want to start from
- paste the script in the dev console (F12)
- you can now scroll - the page will load 10 pages at a time when you get to the end of the page
Code:
let currentPage = Math.floor(
Number(window.location.toString().match(/\/page\/(\d*)\//)?.[1] || 1)
);
const SELECTOR = ".container > div.row:not(.py-5):not(.mt-5)";
const BEFORE = document.querySelector(".container >.row.py-5");
async function fetchPage(pageNo = 1, type = "couple") {
const url = `https://www.camrips.net/sex/${type}/page/${pageNo}/`;
const response = await fetch(url);
if (!response.ok) throw response;
const text = await response.text();
return text;
}
function parseContent(text) {
const parser = new DOMParser();
const doc = parser.parseFromString(text, "text/html");
const container = doc.querySelector(SELECTOR);
return container.outerHTML;
}
async function appendNextPage(pageNo = currentPage + 1) {
const html = await fetchPage(pageNo);
const content = parseContent(html);
const element = document.createElement("div");
BEFORE.before(element);
element.outerHTML = content;
}
const debounce = (func, wait, immediate = false) => {
let timeout;
return (...args) => {
const later = () => {
timeout = null; // added this to set same behaviour as ES5
if (!immediate) func(...args); // this is called conditionally, just like in the ES5 version
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func(...args);
};
};
const run = () => {
const observer = new IntersectionObserver(
debounce(
async () => {
for (let i = 1; i < 10; i++) {
appendNextPage();
currentPage++;
}
},
1000,
true
),
{
threshold: [0.5, 1.0],
}
);
observer.observe(BEFORE);
};
run();