Added PornCZ.

This commit is contained in:
DebaucheryLibrarian
2020-07-22 04:12:20 +02:00
parent 9d89a38490
commit 46c6c4dd21
125 changed files with 462 additions and 7 deletions

View File

@@ -1,13 +1,13 @@
'use strict';
function capitalize(string, trim = true) {
function capitalize(string, { trim = true, uncapitalize = false } = {}) {
if (!string) {
return '';
}
const capitalized = string
.split(/\s+/)
.map(component => `${component.charAt(0).toUpperCase()}${component.slice(1)}`)
.map(component => `${component.charAt(0).toUpperCase()}${uncapitalize ? component.slice(1).toLowerCase() : component.slice(1)}`)
.join(' ');
return trim ? capitalized.trim() : capitalized;

View File

@@ -112,6 +112,15 @@ async function get(url, headers, options) {
});
}
async function head(url, headers, options) {
return queue.push(options?.queueMethod || defaultQueueMethod, {
method: 'HEAD',
url,
headers,
options,
});
}
async function post(url, body, headers, options) {
return queue.push(options?.queueMethod || defaultQueueMethod, {
method: 'POST',
@@ -125,4 +134,5 @@ async function post(url, body, headers, options) {
module.exports = {
get,
post,
head,
};

View File

@@ -170,6 +170,28 @@ function date(context, selector, format, match, attr = 'textContent') {
return extractDate(dateString, format, match);
}
function dateAgo(context, selector, match = /(\d+)\s*(\w+)/, attr = 'textContent') {
const timeString = q(context, selector, attr, 'textContent');
if (!timeString) {
return null;
}
const timeMatch = timeString.match(match);
if (timeMatch) {
const [n, period] = timeMatch.slice(1);
const thenDate = moment.utc().subtract(Number(n), period);
return {
date: thenDate.toDate(),
precision: period.replace(/s$/, ''),
};
}
return null;
}
function image(context, selector = 'img', attr, { origin, protocol = 'https' } = {}) {
const imageEl = (attr && q(context, selector, attr))
|| q(context, selector, 'data-src')
@@ -286,6 +308,7 @@ const quFuncs = {
cnt: content,
cnts: contents,
date,
dateAgo,
dur: duration,
duration,
element: q,