Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better 403 handling #1420

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugin/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,18 @@
"description": "Internal message for developer."
},
"warning403ErrorResponse": {
"message": "WARNING: Site '$host$' has sent an Access Denied (403) error. You may need to logon to site, or browse site normally until you get a Cloudflare \"Are you a human\" page or satisfy some other CAPTCHA before WebToEpub can continue.",
"message": "WARNING: Site '$host$' has sent an Access Denied (403) error. You may need to logon to site, or browse site normally until you get a Cloudflare \"Are you a human\" page or satisfy some other CAPTCHA before WebToEpub can continue. Open Page?",
"description": "Warning message for user when site sends a 403 response.",
"placeholders": {
"host": {
"content": "$1"
}
}
},
"wait403ErrorResponse": {
"message": "Wait until you cleared cloudflare or login.",
"description": "Wait message for user when site sends a 403 response."
},
"warning429ErrorResponse": {
"message": "WARNING: Site '$host$' has requested WebToEpub to slow down rate of chapter requests. WebToEpub will wait until site allows requesting chapters again. However, if this does not work, you may need to adjust manually. Under 'Advanced Options' -> lower 'Max web pages to fetch simultaneously' and/or increase 'Manual Throttle|Delay per chapter'",
"description": "Warning message for user when site sends a 429 response.",
Expand Down
8 changes: 7 additions & 1 deletion plugin/js/HttpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ class FetchErrorHandler {
let retryDelay = [120, 60, 30, 15];
switch(response.status) {
case 403:
alert(chrome.i18n.getMessage("warning403ErrorResponse", new URL(response.url).hostname));
if (confirm(chrome.i18n.getMessage("warning403ErrorResponse", new URL(response.url).hostname))) {
// Open site
window.open(new URL(response.url), "_blank").focus();
alert(chrome.i18n.getMessage("wait403ErrorResponse", new URL(response.url).hostname));
} else {
// Do nothing!
}
return {retryDelay: [1], promptUser: true};
case 429:
FetchErrorHandler.show429Error(response);
Expand Down
Loading