Skip to content

Commit 8bd4973

Browse files
committed
Debug
1 parent 2b6ce36 commit 8bd4973

2 files changed

Lines changed: 43 additions & 25 deletions

File tree

remove-various-popups.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name Remove Various Popups
3-
// @version 0.2
3+
// @version 0.3
44
// @downloadURL https://userscripts.codonaft.com/remove-various-popups.js
55
// @match https://*.archive.org/*
66
// @match https://chat.qwen.ai/*
@@ -12,15 +12,16 @@
1212
(() => {
1313
'use strict';
1414

15-
function randomPause() {
16-
const min = 1000;
17-
const max = 1500;
18-
return Math.floor(Math.random() * (max - min + 1)) + min;
19-
}
15+
const randomPause = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
2016

2117
const process = (node, observer) => {
2218
if (node.nodeType !== 1) return;
2319

20+
if (['A', 'BUTTON'].includes(node.tagName) && node.innerText.includes('Stay logged out')) {
21+
setTimeout(() => node.click(), randomPause(1000, 1500));
22+
return;
23+
}
24+
2425
if (node.matches?.('div[role=dialog]')) {
2526
setTimeout(() => {
2627
node.querySelectorAll('button[aria-label="close"]').forEach(i => i.click());
@@ -29,17 +30,18 @@
2930
i.click();
3031
}
3132
});
32-
}, randomPause());
33+
}, randomPause(1000, 1500));
3334
observer.disconnect();
3435
return;
35-
} else if (['A', 'BUTTON'].includes(node.tagName) && node.innerText.includes('Stay logged out')) {
36-
node.click();
37-
return;
38-
} else if (node.tagName === 'SPAN' && node.parentElement?.tagName === 'BUTTON' && node.textContent.includes('Continue without disabling')) {
36+
}
37+
38+
if (node.tagName === 'SPAN' && node.parentElement?.tagName === 'BUTTON' && node.textContent.includes('Continue without disabling')) {
3939
observer.disconnect();
4040
node.parentElement.click();
4141
return;
42-
} else if (node.matches?.('#cookieconsentwarningcontainer, #donate_banner')) {
42+
}
43+
44+
if (node.matches?.('#cookieconsentwarningcontainer, #donate_banner')) {
4345
observer.disconnect();
4446
node.parentNode?.removeChild(node);
4547
return;

skip-video-intros.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
// ==UserScript==
22
// @name Skip Video Intros
3-
// @version 0.2
3+
// @version 0.3
44
// @downloadURL https://userscripts.codonaft.com/skip-video-intros.js
55
// @match https://www.pornhub.com/view_video.php*
66
// ==/UserScript==
77

88
(() => {
99
'use strict';
1010

11-
function random() {
12-
const min = 240;
13-
const max = 400;
14-
return Math.floor(Math.random() * (max - min + 1)) + min;
15-
}
11+
const url = new URL(window.location.href);
12+
const params = url.searchParams;
1613

17-
const url = new URL(window.location.href);
18-
const params = url.searchParams;
19-
if (!params.has('t')) {
20-
window.stop();
21-
params.set('t', random());
22-
window.location.href = url.toString();
23-
}
14+
const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
15+
16+
const timeToSeconds = time => time?.split(':').map(Number).reduceRight((total, value, index, parts) => total + value * 60 ** (parts.length - 1 - index), 0);
17+
18+
const redirect = (min, max) => {
19+
window.stop();
20+
params.set('t', random(Math.floor(min), Math.floor(max)));
21+
window.location.href = url.toString();
22+
};
23+
24+
if (params.has('t')) {
25+
setTimeout(
26+
() => {
27+
const duration = timeToSeconds(document.querySelector('span.mgp_total')?.innerText);
28+
if (duration) {
29+
if (Number(params.get('t')) >= duration) {
30+
redirect(duration / 4, duration / 2);
31+
}
32+
} else {
33+
window.location.href = url.toString();
34+
}
35+
},
36+
random(2500, 3000))
37+
} else {
38+
redirect(120, 200);
39+
}
2440
})()

0 commit comments

Comments
 (0)