mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-05 03:44:36 -05:00
WebView based cloudflare interceptor (#456)
* WebView based cloudflare interceptor ported https://github.com/vvanglro/cf-clearance to kotlin * code clean up * Forgot to commit these * Get ResolveWithWebView working 1. Make sure to .use all closeable resources 2. Use 10 seconds instead of 1 second for waiting for cloudflare(this was the most probable issue) 3. Use Extension UA when possible 4. Minor cleanup of logging * rewrite and refactor Co-authored-by: Syer10 <syer10@users.noreply.github.com>
This commit is contained in:
203
server/src/main/resources/cloudflare-js/chrome.plugin.js
Normal file
203
server/src/main/resources/cloudflare-js/chrome.plugin.js
Normal file
@@ -0,0 +1,203 @@
|
||||
(function () {
|
||||
const plugin0 = Object.create(Plugin.prototype);
|
||||
|
||||
const mimeType0 = Object.create(MimeType.prototype);
|
||||
const mimeType1 = Object.create(MimeType.prototype);
|
||||
Object.defineProperties(mimeType0, {
|
||||
type: {
|
||||
get: () => 'application/pdf',
|
||||
},
|
||||
suffixes: {
|
||||
get: () => 'pdf',
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperties(mimeType1, {
|
||||
type: {
|
||||
get: () => 'text/pdf',
|
||||
},
|
||||
suffixes: {
|
||||
get: () => 'pdf',
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperties(plugin0, {
|
||||
name: {
|
||||
get: () => 'Chrome PDF Viewer',
|
||||
},
|
||||
description: {
|
||||
get: () => 'Portable Document Format',
|
||||
},
|
||||
0: {
|
||||
get: () => {
|
||||
return mimeType0;
|
||||
},
|
||||
},
|
||||
1: {
|
||||
get: () => {
|
||||
return mimeType1;
|
||||
},
|
||||
},
|
||||
length: {
|
||||
get: () => 2,
|
||||
},
|
||||
filename: {
|
||||
get: () => 'internal-pdf-viewer',
|
||||
},
|
||||
});
|
||||
|
||||
const plugin1 = Object.create(Plugin.prototype);
|
||||
Object.defineProperties(plugin1, {
|
||||
name: {
|
||||
get: () => 'Chromium PDF Viewer',
|
||||
},
|
||||
description: {
|
||||
get: () => 'Portable Document Format',
|
||||
},
|
||||
0: {
|
||||
get: () => {
|
||||
return mimeType0;
|
||||
},
|
||||
},
|
||||
1: {
|
||||
get: () => {
|
||||
return mimeType1;
|
||||
},
|
||||
},
|
||||
length: {
|
||||
get: () => 2,
|
||||
},
|
||||
filename: {
|
||||
get: () => 'internal-pdf-viewer',
|
||||
},
|
||||
});
|
||||
|
||||
const plugin2 = Object.create(Plugin.prototype);
|
||||
Object.defineProperties(plugin2, {
|
||||
name: {
|
||||
get: () => 'Microsoft Edge PDF Viewer',
|
||||
},
|
||||
description: {
|
||||
get: () => 'Portable Document Format',
|
||||
},
|
||||
0: {
|
||||
get: () => {
|
||||
return mimeType0;
|
||||
},
|
||||
},
|
||||
1: {
|
||||
get: () => {
|
||||
return mimeType1;
|
||||
},
|
||||
},
|
||||
length: {
|
||||
get: () => 2,
|
||||
},
|
||||
filename: {
|
||||
get: () => 'internal-pdf-viewer',
|
||||
},
|
||||
});
|
||||
|
||||
const plugin3 = Object.create(Plugin.prototype);
|
||||
Object.defineProperties(plugin3, {
|
||||
name: {
|
||||
get: () => 'PDF Viewer',
|
||||
},
|
||||
description: {
|
||||
get: () => 'Portable Document Format',
|
||||
},
|
||||
0: {
|
||||
get: () => {
|
||||
return mimeType0;
|
||||
},
|
||||
},
|
||||
1: {
|
||||
get: () => {
|
||||
return mimeType1;
|
||||
},
|
||||
},
|
||||
length: {
|
||||
get: () => 2,
|
||||
},
|
||||
filename: {
|
||||
get: () => 'internal-pdf-viewer',
|
||||
},
|
||||
});
|
||||
|
||||
const plugin4 = Object.create(Plugin.prototype);
|
||||
Object.defineProperties(plugin4, {
|
||||
name: {
|
||||
get: () => 'WebKit built-in PDF',
|
||||
},
|
||||
description: {
|
||||
get: () => 'Portable Document Format',
|
||||
},
|
||||
0: {
|
||||
get: () => {
|
||||
return mimeType0;
|
||||
},
|
||||
},
|
||||
1: {
|
||||
get: () => {
|
||||
return mimeType1;
|
||||
},
|
||||
},
|
||||
length: {
|
||||
get: () => 2,
|
||||
},
|
||||
filename: {
|
||||
get: () => 'internal-pdf-viewer',
|
||||
},
|
||||
});
|
||||
|
||||
const pluginArray = Object.create(PluginArray.prototype);
|
||||
|
||||
pluginArray['0'] = plugin0;
|
||||
pluginArray['1'] = plugin1;
|
||||
pluginArray['2'] = plugin2;
|
||||
pluginArray['3'] = plugin3;
|
||||
pluginArray['4'] = plugin4;
|
||||
|
||||
let refreshValue;
|
||||
|
||||
Object.defineProperties(pluginArray, {
|
||||
length: {
|
||||
get: () => 5,
|
||||
},
|
||||
item: {
|
||||
value: (index) => {
|
||||
if (index > 4294967295) {
|
||||
index = index % 4294967296;
|
||||
}
|
||||
switch (index) {
|
||||
case 0:
|
||||
return plugin3;
|
||||
case 1:
|
||||
return plugin0;
|
||||
case 2:
|
||||
return plugin1;
|
||||
case 3:
|
||||
return plugin2;
|
||||
case 4:
|
||||
return plugin4;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
},
|
||||
refresh: {
|
||||
get: () => {
|
||||
return refreshValue;
|
||||
},
|
||||
set: (value) => {
|
||||
refreshValue = value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(Object.getPrototypeOf(navigator), 'plugins', {
|
||||
get: () => {
|
||||
return pluginArray;
|
||||
},
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user