-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf95zone-skipper_ultra.user.js
89 lines (83 loc) · 3.81 KB
/
f95zone-skipper_ultra.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// ==UserScript==
// @name F95-Zone Skipper Ultra
// @namespace -
// @version 0.1.5
// @description Skips masked URLs on F95zone (F95Zone.to) automatically and seamlessly.
// @author Cat-Ling
// @homepageURL https://github.com/Cat-Ling
// @icon https://www.google.com/s2/favicons?sz=64&domain=f95zone.to
// @match https://f95zone.to/masked/*
// @exclude https://f95zone.to/masked/
// @license GPL-2.0
// @supportURL https://github.com/Cat-Ling/f95zone-skipper/issues
// @downloadURL https://raw.githubusercontent.com/Cat-Ling/f95zone-skipper/main/f95zone-skipper_ultra.user.js
// @updateURL https://raw.githubusercontent.com/Cat-Ling/f95zone-skipper/main/f95zone-skipper_ultra.user.js
// ==/UserScript==
(function() {
'use strict';
var $leaving = document.querySelector(".leaving");
var $loading = document.getElementById("loading");
var $captcha = document.getElementById("captcha");
var $error = document.getElementById("error");
function handleError(title, message, retry) {
$error.innerHTML = "<h2>" + title + "</h2><p>" + message + "</p>" + (retry ? '<p><a href="javascript:window.location.reload(true);">Retry</a></p>' : "");
$loading.style.display = "none";
$error.style.display = "block";
}
$leaving.style.width = $leaving.offsetWidth + "px";
document.querySelector(".leaving-text").style.display = "none";
$loading.style.display = "block";
var xhr = new XMLHttpRequest();
xhr.open("POST", document.location.pathname, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var response = JSON.parse(xhr.responseText);
switch (response.status) {
case "ok":
window.location.href = response.msg;
break;
case "error":
handleError("Error", response.msg, true);
break;
case "captcha":
$captcha.style.display = "block";
handleCaptcha(response);
break;
}
} else {
handleError("Server Error", "Please try again in a few moments", true);
}
}
};
xhr.send("xhr=1&download=1");
function handleCaptcha(response) {
grecaptcha.render("captcha", {
theme: "dark",
sitekey: "6LcwQ5kUAAAAAAI-_CXQtlnhdMjmFDt-MruZ2gov",
callback: function(captchaResponse) {
$captcha.style.display = "none";
$loading.style.display = "block";
var xhr = new XMLHttpRequest();
xhr.open("POST", document.location.pathname, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var response = JSON.parse(xhr.responseText);
if (response.status !== "ok") {
handleError("Captcha Error", response.msg, true);
} else {
window.location.href = response.msg;
}
} else {
handleError("Server Error", "Please try again in a few moments", true);
}
}
};
xhr.send("xhr=1&download=1&captcha=" + captchaResponse);
}
});
}
})();