0.4.1 Release! (#70)
* optimization: don't intercept requests if no blockRules set
* page load: set waitUntil to use networkidle2 instead of networkidle0 as reasonable default for most pages
* add --behaviorTimeout to set max running time for behaviors (defaults to 90 seconds)
* refactor profile loadProfile/saveProfile to util/browser.js
- support augmenting existing profile when creating a new profile
* screencasting: convert newContext to window instead of page by default, instead of just warning about it
* shared multiplatform image support:
- determine browser exe from list of options, getBrowserExe() returns current exe
- supports running with 'google-chrome' under amd64, and 'chromium-browser' under arm64
- update to multiplatform oldwebtoday/chrome:91 as browser image
- enable multiplatform build with latest build-push-action@v2
* seeds: add trim() to seed URLs
* logging: reduce initial debug logging, enable only if '--logging debug' is set. log if profile, text-extraction enabled, and post-processing stages automatically
* profile creation: add --windowSize flag, set default to 1600x900, default to loading Application tab, tweak UI styles
* extractLinks: support passing in custom property to get link, and also loading as an attribute via getAttribute. Fixes #25
* update CHANGES and README with new features
* bump version to 0.4.1
2021-07-22 14:24:51 -07:00
|
|
|
const child_process = require("child_process");
|
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
|
|
|
const os = require("os");
|
|
|
|
|
|
|
|
const profileDir = fs.mkdtempSync(path.join(os.tmpdir(), "profile-"));
|
|
|
|
|
|
|
|
module.exports.loadProfile = function(profileFilename) {
|
|
|
|
if (profileFilename) {
|
|
|
|
child_process.execSync("tar xvfz " + profileFilename, {cwd: profileDir});
|
|
|
|
}
|
|
|
|
|
|
|
|
return profileDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.saveProfile = function(profileFilename) {
|
|
|
|
child_process.execFileSync("tar", ["cvfz", profileFilename, "./"], {cwd: profileDir});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.getBrowserExe = function() {
|
|
|
|
const files = [process.env.BROWSER_BIN, "/usr/bin/google-chrome", "/usr/bin/chromium-browser"];
|
|
|
|
for (const file of files) {
|
|
|
|
if (file && fs.existsSync(file)) {
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-02-20 22:22:19 -08:00
|
|
|
module.exports.evaluateWithCLI = async (frame, funcString) => {
|
|
|
|
const context = await frame.executionContext();
|
|
|
|
|
|
|
|
// from puppeteer _evaluateInternal() but with includeCommandLineAPI: true
|
|
|
|
const contextId = context._contextId;
|
|
|
|
const expression = funcString + "\n//# sourceURL=__puppeteer_evaluation_script__";
|
|
|
|
|
|
|
|
const { exceptionDetails, result: remoteObject } = await context._client
|
|
|
|
.send("Runtime.evaluate", {
|
|
|
|
expression,
|
|
|
|
contextId,
|
|
|
|
returnByValue: true,
|
|
|
|
awaitPromise: true,
|
|
|
|
userGesture: true,
|
|
|
|
includeCommandLineAPI: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (exceptionDetails) {
|
|
|
|
throw new Error(
|
|
|
|
"Behavior Evaluation Failed" + exceptionDetails.text
|
|
|
|
);
|
|
|
|
}
|
0.4.1 Release! (#70)
* optimization: don't intercept requests if no blockRules set
* page load: set waitUntil to use networkidle2 instead of networkidle0 as reasonable default for most pages
* add --behaviorTimeout to set max running time for behaviors (defaults to 90 seconds)
* refactor profile loadProfile/saveProfile to util/browser.js
- support augmenting existing profile when creating a new profile
* screencasting: convert newContext to window instead of page by default, instead of just warning about it
* shared multiplatform image support:
- determine browser exe from list of options, getBrowserExe() returns current exe
- supports running with 'google-chrome' under amd64, and 'chromium-browser' under arm64
- update to multiplatform oldwebtoday/chrome:91 as browser image
- enable multiplatform build with latest build-push-action@v2
* seeds: add trim() to seed URLs
* logging: reduce initial debug logging, enable only if '--logging debug' is set. log if profile, text-extraction enabled, and post-processing stages automatically
* profile creation: add --windowSize flag, set default to 1600x900, default to loading Application tab, tweak UI styles
* extractLinks: support passing in custom property to get link, and also loading as an attribute via getAttribute. Fixes #25
* update CHANGES and README with new features
* bump version to 0.4.1
2021-07-22 14:24:51 -07:00
|
|
|
|
2022-02-20 22:22:19 -08:00
|
|
|
return remoteObject.value;
|
|
|
|
};
|
0.4.1 Release! (#70)
* optimization: don't intercept requests if no blockRules set
* page load: set waitUntil to use networkidle2 instead of networkidle0 as reasonable default for most pages
* add --behaviorTimeout to set max running time for behaviors (defaults to 90 seconds)
* refactor profile loadProfile/saveProfile to util/browser.js
- support augmenting existing profile when creating a new profile
* screencasting: convert newContext to window instead of page by default, instead of just warning about it
* shared multiplatform image support:
- determine browser exe from list of options, getBrowserExe() returns current exe
- supports running with 'google-chrome' under amd64, and 'chromium-browser' under arm64
- update to multiplatform oldwebtoday/chrome:91 as browser image
- enable multiplatform build with latest build-push-action@v2
* seeds: add trim() to seed URLs
* logging: reduce initial debug logging, enable only if '--logging debug' is set. log if profile, text-extraction enabled, and post-processing stages automatically
* profile creation: add --windowSize flag, set default to 1600x900, default to loading Application tab, tweak UI styles
* extractLinks: support passing in custom property to get link, and also loading as an attribute via getAttribute. Fixes #25
* update CHANGES and README with new features
* bump version to 0.4.1
2021-07-22 14:24:51 -07:00
|
|
|
|