MCPcopy Index your code
hub / github.com/MALSync/MALSync / cdn

Function cdn

test/headless/test.js:105–133  ·  view source on GitHub ↗
(page, type)

Source from the content-addressed store, hash-verified

103}
104
105async function cdn(page, type) {
106 return new Promise(async (resolve, reject) => {
107 if (type === 'captcha') reject('Captcha');
108 if (type === 'blocked') reject('Blocked');
109
110 let cdnTimeout = 7000;
111 const bVersion = await page.browser().version();
112 if (!bVersion.includes('Headless')) {
113 cdnTimeout = 50000;
114 }
115
116 const loadContent = await page.evaluate(() => document.body.innerHTML);
117 if (loadContent.indexOf('Access denied') !== -1) {
118 reject('Blocked');
119 }
120
121 setTimeout(async () => {
122 if (page.isClosed()) {
123 reject('Page closed');
124 return;
125 }
126 const content = await page.evaluate(() => document.body.innerHTML);
127 if (content.indexOf('Why do I have to complete a CAPTCHA?') !== -1) {
128 reject('Captcha');
129 }
130 resolve();
131 }, cdnTimeout);
132 });
133}
134
135async function onlineTest(url, page) {
136 const [response] = await Promise.all([await page.goto(url, { waitUntil: 'networkidle0' })]);

Callers 1

singleCaseFunction · 0.70

Calls 1

versionMethod · 0.80

Tested by

no test coverage detected