mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-12 11:30:01 -04:00
More commenting; fix some theoretical issues with proxyServiceValidator.js.
This commit is contained in:
parent
cb33731bc9
commit
09ff7da557
2 changed files with 81 additions and 34 deletions
|
@ -132,30 +132,46 @@ const testCommonJSOnPage = async () => {
|
||||||
// a proxy URL and leave it as the input value in response.
|
// a proxy URL and leave it as the input value in response.
|
||||||
const urlPath = 'example.com';
|
const urlPath = 'example.com';
|
||||||
omnibox.value = urlPath;
|
omnibox.value = urlPath;
|
||||||
await omnibox.dispatchEvent(
|
const generateInput = async () => {
|
||||||
new KeyboardEvent('keydown', { code: 'Validator Test' })
|
await omnibox.dispatchEvent(
|
||||||
);
|
new KeyboardEvent('keydown', { code: 'Validator Test' })
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* Keep trying to send a signal every 5 seconds until it works.
|
||||||
|
* Implemented to account for a condition where the document has
|
||||||
|
* finished loading, but the event handler for DOMContentLoaded has
|
||||||
|
* not finished executing its script to listen for artificial inputs.
|
||||||
|
*/
|
||||||
|
await generateInput();
|
||||||
|
const inputInterval = setInterval(generateInput, 5000);
|
||||||
|
|
||||||
// Wait up to 5 seconds for the omnibox to finish updating.
|
// Wait up to 40 seconds for the omnibox to finish updating.
|
||||||
const loadUrl = new Promise((resolve) => {
|
const loadUrl = new Promise((resolve) => {
|
||||||
if (omnibox.value !== urlPath) resolve(omnibox.value);
|
if (omnibox.value !== urlPath) {
|
||||||
else
|
clearInterval(inputInterval);
|
||||||
omnibox.addEventListener('change', () =>
|
resolve(omnibox.value);
|
||||||
resolve(omnibox.value)
|
} else
|
||||||
);
|
omnibox.addEventListener('change', () => {
|
||||||
|
clearInterval(inputInterval);
|
||||||
|
resolve(omnibox.value);
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
timeout = new Promise((resolve) => {
|
timeout = new Promise((resolve) => {
|
||||||
setTimeout(() => resolve(omnibox.value), 40000);
|
setTimeout(() => {
|
||||||
|
clearInterval(inputInterval);
|
||||||
|
resolve(omnibox.value);
|
||||||
|
}, 40000);
|
||||||
}),
|
}),
|
||||||
// Record the proxy URL that the omnibox left here.
|
// Record the proxy URL that the omnibox left here.
|
||||||
rammerheadUrl = await Promise.race([loadUrl, timeout]);
|
generatedUrl = await Promise.race([loadUrl, timeout]);
|
||||||
console.log('Generated Rammerhead URL:', rammerheadUrl);
|
console.log('Generated Rammerhead URL:', generatedUrl);
|
||||||
results.rammerhead = rammerheadUrl ? rammerheadUrl : 'failure';
|
results.rammerhead =
|
||||||
|
generatedUrl !== urlPath ? generatedUrl : 'failure';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
results.rammerhead = 'failure: ' + e.message;
|
results.rammerhead = 'failure: ' + e.message;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
results.goProx = 'not defined';
|
results.omnibox = 'not defined';
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
@ -252,46 +268,77 @@ xx xx
|
||||||
// Send an artificial input to the omnibox. The omnibox will create
|
// Send an artificial input to the omnibox. The omnibox will create
|
||||||
// a proxy URL and leave it as the input value in response.
|
// a proxy URL and leave it as the input value in response.
|
||||||
omnibox.value = website.path;
|
omnibox.value = website.path;
|
||||||
await omnibox.dispatchEvent(
|
const generateInput = async () => {
|
||||||
new KeyboardEvent('keydown', { code: 'Validator Test' })
|
await omnibox.dispatchEvent(
|
||||||
);
|
new KeyboardEvent('keydown', { code: 'Validator Test' })
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* Keep trying to send a signal every 5 seconds until it works.
|
||||||
|
* Implemented to account for a condition where the document has
|
||||||
|
* finished loading, but the event handler for DOMContentLoaded has
|
||||||
|
* not finished executing its script to listen for artificial inputs.
|
||||||
|
*/
|
||||||
|
await generateInput();
|
||||||
|
const inputInterval = setInterval(generateInput, 5000);
|
||||||
|
|
||||||
// Record the proxy URL that the omnibox left here.
|
// Wait up to 40 seconds for the omnibox to finish updating.
|
||||||
const generatedUrl = omnibox.value;
|
const loadUrl = new Promise((resolve) => {
|
||||||
|
if (omnibox.value !== website.path) {
|
||||||
|
clearInterval(inputInterval);
|
||||||
|
resolve(omnibox.value);
|
||||||
|
} else
|
||||||
|
omnibox.addEventListener('change', () => {
|
||||||
|
clearInterval(inputInterval);
|
||||||
|
resolve(omnibox.value);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
timeout = new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
clearInterval(inputInterval);
|
||||||
|
resolve(omnibox.value);
|
||||||
|
}, 40000);
|
||||||
|
}),
|
||||||
|
// Record the proxy URL that the omnibox left here.
|
||||||
|
generatedUrl = await Promise.race([loadUrl, timeout]);
|
||||||
console.log('Generated Ultraviolet URL:', generatedUrl);
|
console.log('Generated Ultraviolet URL:', generatedUrl);
|
||||||
results[0].ultraviolet = generatedUrl ? generatedUrl : 'failure';
|
results[0].ultraviolet =
|
||||||
|
generatedUrl !== website.path ? generatedUrl : 'failure';
|
||||||
|
|
||||||
// Test to see if the document title for example.com has loaded,
|
// Test to see if the document title for example.com has loaded,
|
||||||
// by appending an IFrame to the document and grabbing its content.
|
// by appending an IFrame to the document and grabbing its content.
|
||||||
const testGeneratedUrlHacky = async (url) => {
|
const testGeneratedUrlHacky = async (url) => {
|
||||||
let result = false;
|
|
||||||
const exampleIFrame = document.createElement('iframe');
|
const exampleIFrame = document.createElement('iframe');
|
||||||
const waitForDocument = new Promise((resolve) => {
|
const waitForDocument = new Promise((resolve) => {
|
||||||
document.documentElement.appendChild(exampleIFrame);
|
document.documentElement.appendChild(exampleIFrame);
|
||||||
exampleIFrame.addEventListener('load', () => {
|
exampleIFrame.addEventListener('load', () => {
|
||||||
result =
|
resolve(
|
||||||
exampleIFrame.contentWindow.document.title ===
|
exampleIFrame.contentWindow.document.title === website.title
|
||||||
website.title;
|
);
|
||||||
resolve();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Give 10 seconds for the IFrame to load before manually checking.
|
||||||
const timeout = new Promise((resolve) => {
|
const timeout = new Promise((resolve) => {
|
||||||
setTimeout(resolve, 10000, false);
|
setTimeout(() => {
|
||||||
|
resolve(
|
||||||
|
exampleIFrame.contentWindow.document.title === website.title
|
||||||
|
);
|
||||||
|
}, 10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
exampleIFrame.src = url;
|
exampleIFrame.src = url;
|
||||||
exampleIFrame.style.display = 'none';
|
exampleIFrame.style.display = 'none';
|
||||||
await Promise.race([waitForDocument, timeout]);
|
return await Promise.race([waitForDocument, timeout]);
|
||||||
return result;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
results[1].uvTestPassed = await testGeneratedUrlHacky(
|
results[1].uvTestPassed =
|
||||||
results[0].ultraviolet
|
results[0].ultraviolet !== 'failure' &&
|
||||||
);
|
(await testGeneratedUrlHacky(results[0].ultraviolet));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
results[0].ultraviolet = 'failure: ' + e.message;
|
results[0].ultraviolet = 'failure: ' + e.message;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
results[0].goProx = 'not defined';
|
results[0].omnibox = 'not defined';
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
|
@ -179,8 +179,8 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
});
|
});
|
||||||
tempServer.stdout.on('data', () => {
|
tempServer.stdout.on('data', () => {
|
||||||
// Kill the server and start a new one if there were no startup errors.
|
// There are no startup errors by this point, so kill the server and start
|
||||||
// Restarting is necessary to prevent the workflow check from hanging.
|
// over. The restart alters stdio to prevent the workflow check from hanging.
|
||||||
tempServer.kill();
|
tempServer.kill();
|
||||||
const server = fork(
|
const server = fork(
|
||||||
fileURLToPath(new URL('./backend.js', import.meta.url)),
|
fileURLToPath(new URL('./backend.js', import.meta.url)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue