Fixed qu init selector. Fixed Aziani scene page scope.

This commit is contained in:
DebaucheryLibrarian 2021-01-02 03:20:39 +01:00
parent 70795a69c8
commit 8739ec08cf
2 changed files with 10 additions and 10 deletions

View File

@ -117,7 +117,7 @@ async function fetchLatest(site, page) {
} }
async function fetchScene(url, site) { async function fetchScene(url, site) {
const res = await get(url, '.page-content .row'); const res = await get(url, '.trailer');
if (res.ok) { if (res.ok) {
return scrapeScene(res.item, url, site); return scrapeScene(res.item, url, site);

View File

@ -408,8 +408,12 @@ const quFuncs = {
videos, videos,
}; };
function init(element, window) { function init(context, selector, window) {
if (!element) return null; if (!context) {
return null;
}
const element = selector ? context.querySelector(selector) : context;
const legacyContextFuncs = Object.entries(legacyFuncs) // dynamically attach methods with context const legacyContextFuncs = Object.entries(legacyFuncs) // dynamically attach methods with context
.reduce((acc, [key, func]) => ({ .reduce((acc, [key, func]) => ({
@ -444,21 +448,17 @@ function init(element, window) {
function initAll(context, selector, window) { function initAll(context, selector, window) {
if (Array.isArray(context)) { if (Array.isArray(context)) {
return context.map(element => init(element, window)); return context.map(element => init(element, null, window));
} }
return Array.from(context.querySelectorAll(selector)) return Array.from(context.querySelectorAll(selector))
.map(element => init(element, window)); .map(element => init(element, null, window));
} }
function extract(htmlValue, selector, options) { function extract(htmlValue, selector, options) {
const { window } = new JSDOM(htmlValue, { virtualConsole, ...options }); const { window } = new JSDOM(htmlValue, { virtualConsole, ...options });
if (selector) { return init(window.document, selector, window);
return init(window.document.querySelector(selector), window);
}
return init(window.document, window);
} }
function extractAll(htmlValue, selector, options) { function extractAll(htmlValue, selector, options) {