Compare commits

..

No commits in common. "0f88ae324e8e05d9cb89c017eb15c707a9691eb4" and "442e69187b9c4a941c16eefae2caaeea25b3abca" have entirely different histories.

9 changed files with 58 additions and 124 deletions

View File

@ -14,8 +14,8 @@
>Channels</div> >Channels</div>
</div> </div>
<template v-slot:tooltip> <template v-slot:popover>
<div> <div slot="popover">
<router-link <router-link
class="filter-clear" class="filter-clear"
:to="{ query: { ...$route.query, channels: undefined, networks: undefined } }" :to="{ query: { ...$route.query, channels: undefined, networks: undefined } }"

View File

@ -162,8 +162,8 @@
<Tooltip <Tooltip
class="search-compact" class="search-compact"
:open="searching" :open="searching"
@open="searching = true" @show="searching = true"
@close="searching = false" @hide="searching = false"
> >
<button <button
type="button" type="button"
@ -172,14 +172,12 @@
icon="search" icon="search"
/></button> /></button>
<template v-slot:tooltip> <Search
<Search slot="tooltip"
:searching="searching" :searching="searching"
class="compact" class="compact"
@search="searching = false" @search="searching = false"
@click.stop />
/>
</template>
</Tooltip> </Tooltip>
</div> </div>
</header> </header>

View File

@ -27,7 +27,10 @@ async function search() {
function searching(to) { function searching(to) {
if (to) { if (to) {
this.$refs.search.focus(); setTimeout(() => {
// nextTick does not seem to work
this.$refs.search.focus();
}, 20);
} }
} }
@ -76,12 +79,12 @@ export default {
padding: 0; padding: 0;
border: none; border: none;
.search-input { .search-input {
padding: .75rem .5rem .75rem .75rem; border: solid 1px var(--shadow-hint);
} }
.search-button { .search-button {
padding: 1rem 1rem .75rem .25rem; padding: 0 .5rem 0 1rem;
margin: 0; margin: 0;
} }
} }

View File

@ -19,11 +19,6 @@
<div class="tooltip"> <div class="tooltip">
<slot name="tooltip" /> <slot name="tooltip" />
</div> </div>
<div
class="tooltip-arrow"
:style="{ transform: `translate3d(${arrowOffset}px, 0, 0)` }"
/>
</div> </div>
</div> </div>
</teleport> </teleport>
@ -35,29 +30,19 @@ import { nextTick } from 'vue';
function getX(triggerBoundary, tooltipBoundary) { function getX(triggerBoundary, tooltipBoundary) {
const idealPosition = triggerBoundary.left + (triggerBoundary.width / 2) - (tooltipBoundary.width / 2); const idealPosition = triggerBoundary.left + (triggerBoundary.width / 2) - (tooltipBoundary.width / 2);
const rightEdgeOverflow = Math.max((idealPosition + tooltipBoundary.width) - window.innerWidth, 0);
// don't overflow left edge // don't overflow left edge
if (idealPosition < 0) { if (idealPosition < 0) {
return { return 0;
tooltipX: 0,
arrowOffset: idealPosition,
};
} }
// don't overflow right edge // don't overflow right edge
if (rightEdgeOverflow > 0) { if (idealPosition + tooltipBoundary.width > window.innerWidth) {
return { return window.innerWidth - tooltipBoundary.width;
tooltipX: window.innerWidth - tooltipBoundary.width,
arrowOffset: rightEdgeOverflow,
};
} }
// position at the center of trigger // position at the center of trigger
return { return idealPosition;
tooltipX: idealPosition,
arrowOffset: 0,
};
} }
async function calculate() { async function calculate() {
@ -68,11 +53,8 @@ async function calculate() {
const triggerBoundary = this.$refs.trigger.getBoundingClientRect(); const triggerBoundary = this.$refs.trigger.getBoundingClientRect();
const tooltipBoundary = this.$refs.tooltip.getBoundingClientRect(); const tooltipBoundary = this.$refs.tooltip.getBoundingClientRect();
const { tooltipX, arrowOffset } = this.getX(triggerBoundary, tooltipBoundary);
this.tooltipY = triggerBoundary.top + triggerBoundary.height; this.tooltipY = triggerBoundary.top + triggerBoundary.height;
this.tooltipX = tooltipX; this.tooltipX = this.getX(triggerBoundary, tooltipBoundary);
this.arrowOffset = arrowOffset;
} }
async function open() { async function open() {
@ -84,7 +66,6 @@ async function open() {
await nextTick(); await nextTick();
this.calculate(); this.calculate();
this.$emit('open');
} }
function close() { function close() {
@ -92,9 +73,6 @@ function close() {
this.tooltipY = 0; this.tooltipY = 0;
this.tooltipX = 0; this.tooltipX = 0;
this.arrowOffset = 0;
this.$emit('close');
} }
function toggle() { function toggle() {
@ -122,10 +100,8 @@ export default {
opened: false, opened: false,
tooltipX: 0, tooltipX: 0,
tooltipY: 0, tooltipY: 0,
arrowOffset: 0,
}; };
}, },
emits: ['open', 'close'],
mounted, mounted,
methods: { methods: {
calculate, calculate,
@ -151,24 +127,24 @@ export default {
.tooltip-inner { .tooltip-inner {
position: relative; position: relative;
box-shadow: 0 0 3px var(--darken-weak); box-shadow: 0 0 3px var(--darken-weak);
&:after {
content: '';
width: 0;
height: 0;
position: absolute;
top: -.5rem;
left: calc(50% - .5rem);
border-left: .5rem solid transparent;
border-right: .5rem solid transparent;
border-bottom: .5rem solid var(--background-light);
margin: 0 auto;
filter: drop-shadow(0 0 3px var(--darken-weak));
}
} }
.tooltip { .tooltip {
position: relative; position: relative;
background: var(--background-light); background: var(--background-light);
} }
.tooltip-arrow {
content: '';
width: 0;
height: 0;
position: absolute;
top: -.5rem;
left: calc(50% - .5rem);
border-left: .5rem solid transparent;
border-right: .5rem solid transparent;
border-bottom: .5rem solid var(--background-light);
margin: 0 auto;
filter: drop-shadow(0 0 3px var(--darken-weak));
}
</style> </style>

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "traxxx", "name": "traxxx",
"version": "1.149.5", "version": "1.149.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "traxxx", "name": "traxxx",
"version": "1.149.5", "version": "1.149.4",
"description": "All the latest porn releases in one place", "description": "All the latest porn releases in one place",
"main": "src/app.js", "main": "src/app.js",
"scripts": { "scripts": {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
const qu = require('../utils/qu'); const qu = require('../utils/qu');
const http = require('../utils/http');
function scrapeAll(scenes) { function scrapeAll(scenes) {
return scenes.map(({ query }) => { return scenes.map(({ query }) => {
@ -34,6 +33,10 @@ function scrapeAll(scenes) {
async function scrapeScene({ query }, url) { async function scrapeScene({ query }, url) {
const release = { director: 'Mike Adriano' }; const release = { director: 'Mike Adriano' };
if (query.exists('a[href*="stackpath.com"]')) {
throw new Error('URL blocked by StackPath');
}
const pathname = new URL(url).pathname; const pathname = new URL(url).pathname;
release.entryId = pathname.match(/\/view\/(\d+)/)?.[1] || pathname.match(/\/view\/([\w-]+)/)?.[1]; release.entryId = pathname.match(/\/view\/(\d+)/)?.[1] || pathname.match(/\/view\/([\w-]+)/)?.[1];
@ -68,34 +71,10 @@ async function fetchLatest(channel, page = 1) {
} }
async function fetchScene(url, channel) { async function fetchScene(url, channel) {
const cookieJar = http.cookieJar(); const res = await qu.get(url);
const session = http.session({ cookieJar });
/* not working
const resA = await http.get(url, {
session,
extract: {
runScripts: 'dangerously',
},
});
cookieJar.setCookieSync(http.toughCookie.Cookie.parse(resA.document.cookie), url);
console.log(res.req);
*/
const res = await http.get(url, {
session,
});
if (res.ok) { if (res.ok) {
const item = qu.init(res.document); return scrapeScene(res.item, url, channel);
if (item.query.exists('a[href*="stackpath.com"]')) {
throw new Error('URL blocked by StackPath');
}
return scrapeScene(item, url, channel);
} }
return res.status; return res.status;

View File

@ -6,7 +6,7 @@ const util = require('util');
const stream = require('stream'); const stream = require('stream');
const tunnel = require('tunnel'); const tunnel = require('tunnel');
const Bottleneck = require('bottleneck'); const Bottleneck = require('bottleneck');
const { JSDOM, toughCookie } = require('jsdom'); const { JSDOM } = require('jsdom');
const logger = require('../logger')(__filename); const logger = require('../logger')(__filename);
const virtualConsole = require('./virtual-console')(__filename); const virtualConsole = require('./virtual-console')(__filename);
@ -110,7 +110,7 @@ async function request(method = 'get', url, body, requestOptions = {}, limiter)
if (Buffer.isBuffer(res.body)) { if (Buffer.isBuffer(res.body)) {
const html = res.body.toString(); const html = res.body.toString();
const window = new JSDOM(html, { virtualConsole, ...options.extract }).window; const window = new JSDOM(html, { virtualConsole }).window;
return { return {
...res, ...res,
@ -165,15 +165,7 @@ function getSession(options) {
return bhttp.session({ ...defaultOptions, ...options }); return bhttp.session({ ...defaultOptions, ...options });
} }
function getCookieJar(store, options) {
return new toughCookie.CookieJar(store, {
looseMode: true,
...options,
});
}
module.exports = { module.exports = {
toughCookie,
get, get,
head, head,
post, post,
@ -181,7 +173,5 @@ module.exports = {
put, put,
patch, patch,
session: getSession, session: getSession,
cookieJar: getCookieJar,
getSession, getSession,
getCookieJar,
}; };

View File

@ -118,12 +118,6 @@ function html(context, selector) {
return el && el.innerHTML; return el && el.innerHTML;
} }
function htmls(context, selector) {
const els = all(context, selector, null, true);
return els.map(el => el.innerHTML);
}
function texts(context, selector, applyTrim = true, filter = true) { function texts(context, selector, applyTrim = true, filter = true) {
const el = q(context, selector, null, applyTrim); const el = q(context, selector, null, applyTrim);
if (!el) return null; if (!el) return null;
@ -369,28 +363,27 @@ const legacyFuncs = {
const quFuncs = { const quFuncs = {
all, all,
cnt: content, html,
cnts: contents,
content, content,
contents, contents,
cnt: content,
cnts: contents,
count, count,
date, date,
dateAgo, dateAgo,
dur: duration, dur: duration,
duration, duration,
el: q,
element: q, element: q,
el: q,
exists, exists,
html,
htmls,
image, image,
images, images,
img: image, img: image,
imgs: images, imgs: images,
length: duration, length: duration,
meta, meta,
num: number,
number, number,
num: number,
poster, poster,
q, q,
sourceSet, sourceSet,
@ -451,8 +444,8 @@ function initAll(context, selector, window) {
.map(element => init(element, window)); .map(element => init(element, window));
} }
function extract(htmlValue, selector, options) { function extract(htmlValue, selector) {
const { window } = new JSDOM(htmlValue, { virtualConsole, ...options }); const { window } = new JSDOM(htmlValue, { virtualConsole });
if (selector) { if (selector) {
return init(window.document.querySelector(selector), window); return init(window.document.querySelector(selector), window);
@ -461,8 +454,8 @@ function extract(htmlValue, selector, options) {
return init(window.document, window); return init(window.document, window);
} }
function extractAll(htmlValue, selector, options) { function extractAll(htmlValue, selector) {
const { window } = new JSDOM(htmlValue, { virtualConsole, ...options }); const { window } = new JSDOM(htmlValue, { virtualConsole });
return initAll(window.document, selector, window); return initAll(window.document, selector, window);
} }
@ -474,8 +467,8 @@ async function request(method = 'get', urlValue, body, selector, headers, option
if (res.ok) { if (res.ok) {
const item = queryAll const item = queryAll
? initAll(res.document, selector, res.window) ? extractAll(res.body.toString(), selector)
: init(res.document, selector, res.window); : extract(res.body.toString(), selector);
return { return {
item, item,
@ -513,10 +506,6 @@ async function postAll(urlValue, body, selector, headers, options) {
return request('post', urlValue, body, selector, headers, options, true); return request('post', urlValue, body, selector, headers, options, true);
} }
function session(headers, options) {
return http.session(headers, options);
}
module.exports = { module.exports = {
extractDate, extractDate,
extract, extract,
@ -543,6 +532,5 @@ module.exports = {
post, post,
postAll, postAll,
prefixUrl, prefixUrl,
session,
...legacyFuncs, ...legacyFuncs,
}; };