forked from DebaucheryLibrarian/traxxx
Context q methods can accept alternative element as first argument. Added BoobPedia profile scraper. Showing fake boobs icon again.
This commit is contained in:
@@ -79,12 +79,18 @@ const funcs = {
|
||||
qt: qtrailer,
|
||||
};
|
||||
|
||||
function ctx(element) {
|
||||
function ctx(element, window) {
|
||||
const contextFuncs = Object.entries(funcs) // dynamically attach methods with context
|
||||
.reduce((acc, [key, func]) => ({ ...acc, [key]: (...args) => func(element, ...args) }), {});
|
||||
.reduce((acc, [key, func]) => ({
|
||||
...acc,
|
||||
[key]: (...args) => (window && args[0] instanceof window.HTMLElement // allow for different context
|
||||
? func(...args)
|
||||
: func(element, ...args)),
|
||||
}), {});
|
||||
|
||||
return {
|
||||
element,
|
||||
...(window && { window }),
|
||||
...contextFuncs,
|
||||
};
|
||||
}
|
||||
@@ -94,9 +100,9 @@ function ctxa(context, selector) {
|
||||
}
|
||||
|
||||
function ex(html) {
|
||||
const { document } = new JSDOM(html).window;
|
||||
const { window } = new JSDOM(html);
|
||||
|
||||
return ctx(document);
|
||||
return ctx(window.document, window);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user