Skip to content

Commit 6aed2fd

Browse files
committed
Update
1 parent d4b9f4e commit 6aed2fd

2 files changed

Lines changed: 56 additions & 31 deletions

File tree

bypass-various-popups.user.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name Bypass Various Popups
3-
// @version 0.15
3+
// @version 0.16
44
// @downloadURL https://userscripts.codonaft.com/bypass-various-popups.user.js
55
// @match https://*.archive.org/*
66
// @match https://chat.deepseek.com/*
@@ -9,7 +9,7 @@
99
// @match https://hqporner.com/*
1010
// @match https://pmvhaven.com/*
1111
// @match https://www.cvedetails.com/*
12-
// @match https://www.pornhub.com/*
12+
// @match https://*.pornhub.com/*
1313
// @match https://www.porntrex.com/*
1414
// @match https://www.xnxx.com/*
1515
// @match https://www.xvideos.com/*
@@ -23,6 +23,32 @@ if (performance.getEntriesByType('navigation')[0]?.responseStatus !== 200) retur
2323

2424
const randomPause = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
2525

26+
const simulateMouse = (document, node, events = ['mouseenter', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click']) => {
27+
if (!node) return;
28+
29+
console.log('simulateMouse', node, events);
30+
try {
31+
const { target, clientX, clientY } = getTopNode(document, node, 0.5, 0.5);
32+
console.log('simulateMouse target', target, clientX, clientY);
33+
events.forEach(i => target.dispatchEvent(new MouseEvent(i, { clientX, clientY, bubbles: true, cancelable: true })));
34+
} catch (e) {
35+
err(e, node);
36+
}
37+
};
38+
39+
const getTopNode = (document, node, x, y) => {
40+
if (!node) return;
41+
try {
42+
const rect = node.getBoundingClientRect();
43+
const clientX = rect.x + rect.width * x;
44+
const clientY = rect.y + rect.height * y;
45+
const target = document.elementFromPoint(clientX, clientY) || node;
46+
return { target, clientX, clientY };
47+
} catch (e) {
48+
err(e, node);
49+
}
50+
};
51+
2652
const process = (node, observer) => {
2753
if (node.matches('div[role=dialog]')) {
2854
setTimeout(_ => {
@@ -81,12 +107,10 @@ const process = (node, observer) => {
81107
return false;
82108
}
83109

84-
if (node.matches('#modalWrapMTubes')) {
110+
if (node.matches('#modalWrapMTubes button[data-label="over18_enter"]')) {
111+
console.log('detected', node);
85112
observer.disconnect();
86-
setTimeout(
87-
_ => node.querySelectorAll('div > div > button').forEach(i => i.click()),
88-
randomPause(100, 400)
89-
);
113+
simulateMouse(document, node);
90114
return false;
91115
}
92116

@@ -129,7 +153,7 @@ const subscribeOnChanges = (node, selector, f) => {
129153

130154
const observer = new MutationObserver(mutations => mutations.forEach(m => m.addedNodes.forEach(i => apply(i, observer))));
131155
observer.observe(node, { childList: true, subtree: true });
132-
apply(node, observer);
156+
node.querySelectorAll(selector).forEach(i => apply(i, observer)); // TODO: apply to other scripts?
133157
};
134158

135159
const err = (e, node) => {

improve-adult-experience.user.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// @name Improve Adult Experience
33
// @description Skip intros, set better default quality/duration filters, make unwanted video previews transparent, workaround load failures, make input more consistent across the websites. Supported websites: pornhub.com, xvideos.com, anysex.com, spankbang.com, porntrex.com, txxx.com, xnxx.com, xhamster.com, vxxx.com
44
// @icon https://external-content.duckduckgo.com/ip3/pornhub.com.ico
5-
// @version 0.42
5+
// @version 0.43
66
// @downloadURL https://userscripts.codonaft.com/improve-adult-experience.user.js
77
// ==/UserScript==
88

@@ -33,10 +33,12 @@ const INITIALIZED = '__initialized';
3333
let unmuted = false;
3434
let pageIsHidden = true;
3535

36+
const loc = window.location;
37+
3638
let redirectHref;
3739
const redirect = (href, force) => {
3840
if (force) {
39-
window.location.href = href;
41+
loc.href = href;
4042
return;
4143
}
4244

@@ -46,9 +48,9 @@ const redirect = (href, force) => {
4648
redirect(redirectHref, true);
4749
}
4850
};
49-
const refresh = force => redirect(window.location, force);
51+
const refresh = force => redirect(loc, force);
5052

51-
const origin = window.location.origin;
53+
const origin = loc.origin;
5254
const validLink = node => node?.tagName === 'A' && node?.href?.startsWith(origin);
5355

5456
const err = (e, node) => {
@@ -62,19 +64,6 @@ const pickRandom = xs => xs[random(0, xs.length - 1)];
6264

6365
const timeToSeconds = time => (time || '').trim().split(':').map(parseFloat).reduceRight((total, value, index, parts) => total + value * 60 ** (parts.length - 1 - index), 0);
6466

65-
const getTopNode = (document, node, x, y) => {
66-
if (!node) return;
67-
try {
68-
const rect = node.getBoundingClientRect();
69-
const clientX = rect.x + rect.width * x;
70-
const clientY = rect.y + rect.height * y;
71-
const target = document.elementFromPoint(clientX, clientY) || node;
72-
return { target, clientX, clientY };
73-
} catch (e) {
74-
err(e, node);
75-
}
76-
};
77-
7867
const focus = (node, scrollTo) => {
7968
if (!node) return;
8069
if (!node.hasAttribute('tabindex')) {
@@ -91,7 +80,6 @@ const focus = (node, scrollTo) => {
9180

9281
const simulateMouse = (document, node, events = ['mouseenter', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click']) => {
9382
if (!node) return;
94-
if (events.length === 0) return;
9583

9684
console.log('simulateMouse', node, events);
9785
try {
@@ -103,6 +91,19 @@ const simulateMouse = (document, node, events = ['mouseenter', 'mouseover', 'mou
10391
}
10492
};
10593

94+
const getTopNode = (document, node, x, y) => {
95+
if (!node) return;
96+
try {
97+
const rect = node.getBoundingClientRect();
98+
const clientX = rect.x + rect.width * x;
99+
const clientY = rect.y + rect.height * y;
100+
const target = document.elementFromPoint(clientX, clientY) || node;
101+
return { target, clientX, clientY };
102+
} catch (e) {
103+
err(e, node);
104+
}
105+
};
106+
106107
const updateUrl = (node, href) => {
107108
node.href = href;
108109
node.addEventListener('click', _ => {
@@ -283,9 +284,9 @@ const init = (args = {}) => {
283284
togglePlay(video);
284285
};
285286

286-
let lastHref = window.location.href;
287+
let lastHref = loc.href;
287288
subscribeOnChanges(body, nodeChangeSelector, (node, _observer) => {
288-
const newHref = window.location.href;
289+
const newHref = loc.href;
289290
if (newHref !== lastHref) {
290291
console.log('new page', newHref);
291292
lastHref = newHref;
@@ -336,7 +337,7 @@ const init = (args = {}) => {
336337
return true;
337338
}
338339

339-
const url = window.location;
340+
const url = loc;
340341
const videoPage = url.pathname !== '/' && (!isVideoUrl || isVideoUrl(url.href));
341342

342343
try {
@@ -484,7 +485,7 @@ const init = (args = {}) => {
484485
};
485486

486487
// TODO: consider redtube.com, tnaflix.com, hdzog.tube, pornxp.com, рус-порно.tv, xgroovy.com, pmvhaven.com, pornhits.com, manysex.com, inporn.com, hqporner.com, bingato.com, taboodude.com, mat6tube.com, hypnotube.com, incestporno.vip, tube8.com, drtuber.com
487-
const shortDomain = window.location.hostname.replace(/^www\./, '');
488+
const shortDomain = loc.hostname.split('.').slice(-2).join('.');
488489
if (IGNORE_HOSTS.includes(shortDomain)) {
489490
console.log(shortDomain, 'is a part of ignore list');
490491
return;
@@ -547,7 +548,7 @@ if (IGNORE_HOSTS.includes(shortDomain)) {
547548
const videoSelector = 'video.mgp_videoElement:not(.gifVideo)';
548549
const durationSelector = 'var.duration, span.duration';
549550

550-
const url = new URL(window.location.href);
551+
const url = new URL(loc.href);
551552
const params = url.searchParams;
552553
const p = url.pathname;
553554

0 commit comments

Comments
 (0)