puppeteer-pro 1.7.6 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -73,6 +73,11 @@ const solver = PuppeteerPro.solveRecaptchas('WIT_AI_ACCESS_TOKEN');
73
73
  - Save and load cookies across sessions
74
74
  - Supports multiple profiles and switching between profiles
75
75
 
76
+ ### Manage Local Storage
77
+
78
+ - Save and load local storage across sessions
79
+ - Supports multiple profiles and switching between profiles
80
+
76
81
  ### Solve Recaptcha
77
82
 
78
83
  - Solve Google's reCAPTCHA v2
package/index.d.ts CHANGED
@@ -40,6 +40,8 @@ import { DisableDialogsPlugin } from './plugins/disable.dialogs';
40
40
  export declare function disableDialogs(logMessages?: boolean): DisableDialogsPlugin;
41
41
  import { ManageCookiesPlugin, ManageCookiesOption } from './plugins/manage.cookies';
42
42
  export declare function manageCookies(opts: ManageCookiesOption): ManageCookiesPlugin;
43
+ import { ManageLocalStoragePlugin, ManageLocalStorageOption } from './plugins/manage.localstorage';
44
+ export declare function manageLocalStorage(opts: ManageLocalStorageOption): ManageLocalStoragePlugin;
43
45
  import { SolveRecaptchaPlugin } from './plugins/solve.recaptcha';
44
46
  export declare function solveRecaptchas(accessToken: string): SolveRecaptchaPlugin;
45
47
  interface Dialog extends Puppeteer.Dialog {
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAIvC,wBAAsB,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAc5F;AAED,yIAAyI;AACzI,wBAAsB,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,4BAA4B,GAAG,SAAS,CAAC,qBAAqB,GAAG,OAAO,CA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,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB,CAIzE;AAED,UAAU,MAAO,SAAQ,SAAS,CAAC,MAAM;IACvC,OAAO,EAAE,OAAO,CAAC;CAClB"}
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.solveRecaptchas = exports.manageCookies = exports.disableDialogs = exports.blockResources = exports.avoidDetection = exports.anonymizeUserAgent = exports.clearPlugins = exports.addPlugin = exports.Plugin = exports.launch = exports.connect = void 0;
3
+ exports.solveRecaptchas = exports.manageLocalStorage = exports.manageCookies = exports.disableDialogs = exports.blockResources = exports.avoidDetection = exports.anonymizeUserAgent = exports.clearPlugins = exports.addPlugin = exports.Plugin = exports.launch = exports.connect = void 0;
4
4
  /* eslint-disable prefer-rest-params */
5
5
  const events = require("events");
6
6
  // Puppeteer Defaults
@@ -241,6 +241,13 @@ function manageCookies(opts) {
241
241
  return plugin;
242
242
  }
243
243
  exports.manageCookies = manageCookies;
244
+ const manage_localstorage_1 = require("./plugins/manage.localstorage");
245
+ function manageLocalStorage(opts) {
246
+ const plugin = new manage_localstorage_1.ManageLocalStoragePlugin(opts);
247
+ plugins.push(plugin);
248
+ return plugin;
249
+ }
250
+ exports.manageLocalStorage = manageLocalStorage;
244
251
  const solve_recaptcha_1 = require("./plugins/solve.recaptcha");
245
252
  function solveRecaptchas(accessToken) {
246
253
  const plugin = new solve_recaptcha_1.SolveRecaptchaPlugin(accessToken);
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,iCAAiC;AAEjC,qBAAqB;AACrB,uCAAuC;AAEvC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;AAEzC,KAAK,UAAU,OAAO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AAC;IACrD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,MAAM,CAAC;AAChB,CAAC;AAJD,0CAIC","sourcesContent":["/* eslint-disable prefer-rest-params */\nimport * as events from 'events';\n\n// Puppeteer Defaults\nimport * as Puppeteer from 'puppeteer';\n\nconst browserEvents = new events.EventEmitter();\n\nexport async function connect(options?: Puppeteer.ConnectOptions): Promise<Puppeteer.Browser> {\n const browser = await Puppeteer.connect(options || {});\n\n for (const plugin of plugins) {\n await plugin.init(browser);\n }\n\n const _close = browser.close;\n browser.close = async () => {\n await _close.apply(browser);\n browserEvents.emit('close');\n };\n\n return browser;\n}\n\n/** The method launches a browser instance with given arguments. The browser will be closed when the parent node.js process is closed. */\nexport async function launch(options?: Puppeteer.LaunchOptions & Puppeteer.BrowserLaunchArgumentOptions & Puppeteer.BrowserConnectOptions): Promise<Puppeteer.Browser> {\n if (!options) options = {};\n\n process.env.PUPPETEER_DISABLE_HEADLESS_WARNING = 'true';\n const browser = await Puppeteer.launch({ defaultViewport: undefined, ...options });\n\n for (const plugin of plugins) {\n await plugin.init(browser);\n }\n\n const _close = browser.close;\n browser.close = async () => {\n await _close.apply(browser);\n browserEvents.emit('close');\n };\n\n return browser;\n}\n\n// PuppeteerPro\nlet interceptions = 0;\nexport class Plugin {\n protected browser: Puppeteer.Browser | null = null;\n private initialized = false;\n private startCounter = 0;\n protected dependencies: Plugin[] = [];\n protected requiresInterception = false;\n\n get isInitialized() { return this.initialized; }\n get isStopped() { return this.startCounter === 0; }\n\n async addDependency(plugin: Plugin) {\n this.dependencies.push(plugin);\n }\n\n async init(browser: Puppeteer.Browser) {\n if (this.initialized) return;\n\n this.browser = browser;\n\n const offOnClose: (() => void)[] = [];\n browserEvents.once('close', async () => {\n offOnClose.forEach(fn => fn());\n\n this.browser = null;\n this.initialized = false;\n this.startCounter = 0;\n\n await this.onClose();\n });\n\n this.startCounter++;\n\n const thisOnTargetCreated = this.onTargetCreated.bind(this);\n browser.on('targetcreated', thisOnTargetCreated);\n offOnClose.push(() => browser.off('targetcreated', thisOnTargetCreated));\n\n this.initialized = true;\n\n this.dependencies.forEach(x => x.init(browser));\n\n return this.afterLaunch(browser);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async afterLaunch(_browser: Puppeteer.Browser) { null; }\n protected async onClose() { null; }\n\n protected async onTargetCreated(target: Puppeteer.Target) {\n if (this.isStopped) return;\n\n if (target.type() !== 'page') return;\n const page = await target.page() as Puppeteer.Page;\n if (page.isClosed()) return;\n\n const offOnClose: (() => void)[] = [];\n page.once('close', async () => {\n offOnClose.forEach(fn => fn());\n });\n\n const requestHandlers: ((request: any) => void)[] = [];\n page.on('request', request => {\n const _respond = request.respond;\n let responded = 0;\n let respondArgs: IArguments;\n\n const _abort = request.abort;\n let aborted = 0;\n let abortArgs: IArguments;\n\n const _continue = request.continue;\n let continued = 0;\n let continueArgs: IArguments;\n\n const handleRequest = async function () {\n const total = responded + aborted + continued;\n\n if (!(request as any)._interceptionHandled) {\n if (responded === 1) await _respond.apply(request, respondArgs);\n else if (responded === 0 && aborted >= 1 && total === requestHandlers.length) await _abort.apply(request, abortArgs);\n else if (continued === requestHandlers.length) await _continue.apply(request, continueArgs);\n }\n };\n\n request.respond = async function () { responded++; respondArgs = respondArgs || arguments; await handleRequest(); };\n request.abort = async function () { aborted++; abortArgs = abortArgs || arguments; await handleRequest(); };\n request.continue = async function () { continued++; continueArgs = continueArgs || arguments; await handleRequest(); };\n\n requestHandlers.forEach(handler => handler(request));\n });\n\n const _pageOn = page.on;\n page.on = function async(eventName, handler) {\n if (eventName === 'request') {\n requestHandlers.push(handler);\n\n return page;\n } else {\n return _pageOn.call(page, eventName, handler);\n }\n };\n\n if (this.requiresInterception) {\n await page.setRequestInterception(true);\n\n const thisOnRequest = this.onRequest.bind(this);\n page.on('request', thisOnRequest);\n offOnClose.push(() => page.off('request', thisOnRequest));\n }\n\n const thisOnDialog = this.onDialog.bind(this);\n page.on('dialog', thisOnDialog);\n offOnClose.push(() => page.off('dialog', thisOnDialog));\n\n await this.onPageCreated(page);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async onPageCreated(_page: Puppeteer.Page) { null; }\n\n protected async onRequest(request: Puppeteer.HTTPRequest) {\n const interceptionHandled = (request as any)._interceptionHandled;\n if (interceptionHandled) return;\n if (this.isStopped) return request.continue();\n\n await this.processRequest(request);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async processRequest(_request: Puppeteer.HTTPRequest) { null; }\n\n protected async onDialog(dialog: Dialog) {\n if (this.isStopped) return;\n\n const _dismiss = dialog.dismiss;\n dialog.dismiss = async () => {\n if (dialog.handled) return;\n\n dialog.handled = true;\n await _dismiss.apply(dialog);\n };\n\n await this.processDialog(dialog);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async processDialog(_dialog: Dialog) { null; }\n\n protected async beforeRestart() { null; }\n async restart() {\n await this.beforeRestart();\n\n this.startCounter++;\n if (this.requiresInterception) interceptions++;\n\n this.dependencies.forEach(x => x.restart());\n\n await this.afterRestart();\n }\n protected async afterRestart() { null; }\n\n protected async beforeStop() { null; }\n async stop() {\n await this.beforeStop();\n\n this.startCounter--;\n if (this.requiresInterception) interceptions--;\n\n if (interceptions === 0 && this.browser) {\n const pages = await this.browser.pages();\n\n pages.filter(x => !x.isClosed()).forEach(async (page: Puppeteer.Page) => {\n await page.setRequestInterception(false);\n });\n }\n\n this.dependencies.forEach(x => x.stop());\n\n await this.afterStop();\n }\n protected async afterStop() { null; }\n\n protected async getFirstPage() {\n if (!this.browser) return null;\n\n const pages = await this.browser.pages();\n const openPages = pages.filter(x => !x.isClosed());\n const activePages = pages.filter(x => x.url() !== 'about:blank');\n\n return activePages[0] || openPages[0];\n }\n}\n\nlet plugins: Plugin[] = [];\nexport function addPlugin(plugin: Plugin) { plugins.push(plugin); }\nexport async function clearPlugins() {\n plugins.forEach(async plugin => {\n await plugin.stop();\n });\n\n plugins = [];\n}\n\nimport { AnonymizeUserAgentPlugin } from './plugins/anonymize.user.agent/index';\nexport function anonymizeUserAgent(): AnonymizeUserAgentPlugin {\n const plugin = new AnonymizeUserAgentPlugin();\n plugins.push(plugin);\n return plugin;\n}\n\nimport { AvoidDetectionPlugin } from './plugins/avoid.detection';\nexport function avoidDetection(): AvoidDetectionPlugin {\n const plugin = new AvoidDetectionPlugin();\n plugins.push(plugin);\n return plugin;\n}\n\nimport { BlockResourcesPlugin, Resource } from './plugins/block.resources';\nexport function blockResources(...resources: Resource[]): BlockResourcesPlugin {\n const plugin = new BlockResourcesPlugin(resources);\n plugins.push(plugin);\n return plugin;\n}\n\nimport { DisableDialogsPlugin } from './plugins/disable.dialogs';\nexport function disableDialogs(logMessages = false): DisableDialogsPlugin {\n const plugin = new DisableDialogsPlugin(logMessages);\n plugins.push(plugin);\n return plugin;\n}\n\nimport { ManageCookiesPlugin, ManageCookiesOption } from './plugins/manage.cookies';\nexport function manageCookies(opts: ManageCookiesOption): ManageCookiesPlugin {\n const plugin = new ManageCookiesPlugin(opts);\n plugins.push(plugin);\n return plugin;\n}\n\nimport { SolveRecaptchaPlugin } from './plugins/solve.recaptcha';\nexport function solveRecaptchas(accessToken: string): SolveRecaptchaPlugin {\n const plugin = new SolveRecaptchaPlugin(accessToken);\n plugins.push(plugin);\n return plugin;\n}\n\ninterface Dialog extends Puppeteer.Dialog {\n handled: boolean;\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,iCAAiC;AAEjC,qBAAqB;AACrB,uCAAuC;AAEvC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;AAEzC,KAAK,UAAU,OAAO,CAAC,OAAkC;IAC9D,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAEvD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE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C,WAAmB;IACjD,MAAM,MAAM,GAAG,IAAI,sCAAoB,CAAC,WAAW,CAAC,CAAC;IACrD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,MAAM,CAAC;AAChB,CAAC;AAJD,0CAIC","sourcesContent":["/* eslint-disable prefer-rest-params */\nimport * as events from 'events';\n\n// Puppeteer Defaults\nimport * as Puppeteer from 'puppeteer';\n\nconst browserEvents = new events.EventEmitter();\n\nexport async function connect(options?: Puppeteer.ConnectOptions): Promise<Puppeteer.Browser> {\n const browser = await Puppeteer.connect(options || {});\n\n for (const plugin of plugins) {\n await plugin.init(browser);\n }\n\n const _close = browser.close;\n browser.close = async () => {\n await _close.apply(browser);\n browserEvents.emit('close');\n };\n\n return browser;\n}\n\n/** The method launches a browser instance with given arguments. The browser will be closed when the parent node.js process is closed. */\nexport async function launch(options?: Puppeteer.LaunchOptions & Puppeteer.BrowserLaunchArgumentOptions & Puppeteer.BrowserConnectOptions): Promise<Puppeteer.Browser> {\n if (!options) options = {};\n\n process.env.PUPPETEER_DISABLE_HEADLESS_WARNING = 'true';\n const browser = await Puppeteer.launch({ defaultViewport: undefined, ...options });\n\n for (const plugin of plugins) {\n await plugin.init(browser);\n }\n\n const _close = browser.close;\n browser.close = async () => {\n await _close.apply(browser);\n browserEvents.emit('close');\n };\n\n return browser;\n}\n\n// PuppeteerPro\nlet interceptions = 0;\nexport class Plugin {\n protected browser: Puppeteer.Browser | null = null;\n private initialized = false;\n private startCounter = 0;\n protected dependencies: Plugin[] = [];\n protected requiresInterception = false;\n\n get isInitialized() { return this.initialized; }\n get isStopped() { return this.startCounter === 0; }\n\n async addDependency(plugin: Plugin) {\n this.dependencies.push(plugin);\n }\n\n async init(browser: Puppeteer.Browser) {\n if (this.initialized) return;\n\n this.browser = browser;\n\n const offOnClose: (() => void)[] = [];\n browserEvents.once('close', async () => {\n offOnClose.forEach(fn => fn());\n\n this.browser = null;\n this.initialized = false;\n this.startCounter = 0;\n\n await this.onClose();\n });\n\n this.startCounter++;\n\n const thisOnTargetCreated = this.onTargetCreated.bind(this);\n browser.on('targetcreated', thisOnTargetCreated);\n offOnClose.push(() => browser.off('targetcreated', thisOnTargetCreated));\n\n this.initialized = true;\n\n this.dependencies.forEach(x => x.init(browser));\n\n return this.afterLaunch(browser);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async afterLaunch(_browser: Puppeteer.Browser) { null; }\n protected async onClose() { null; }\n\n protected async onTargetCreated(target: Puppeteer.Target) {\n if (this.isStopped) return;\n\n if (target.type() !== 'page') return;\n const page = await target.page() as Puppeteer.Page;\n if (page.isClosed()) return;\n\n const offOnClose: (() => void)[] = [];\n page.once('close', async () => {\n offOnClose.forEach(fn => fn());\n });\n\n const requestHandlers: ((request: any) => void)[] = [];\n page.on('request', request => {\n const _respond = request.respond;\n let responded = 0;\n let respondArgs: IArguments;\n\n const _abort = request.abort;\n let aborted = 0;\n let abortArgs: IArguments;\n\n const _continue = request.continue;\n let continued = 0;\n let continueArgs: IArguments;\n\n const handleRequest = async function () {\n const total = responded + aborted + continued;\n\n if (!(request as any)._interceptionHandled) {\n if (responded === 1) await _respond.apply(request, respondArgs);\n else if (responded === 0 && aborted >= 1 && total === requestHandlers.length) await _abort.apply(request, abortArgs);\n else if (continued === requestHandlers.length) await _continue.apply(request, continueArgs);\n }\n };\n\n request.respond = async function () { responded++; respondArgs = respondArgs || arguments; await handleRequest(); };\n request.abort = async function () { aborted++; abortArgs = abortArgs || arguments; await handleRequest(); };\n request.continue = async function () { continued++; continueArgs = continueArgs || arguments; await handleRequest(); };\n\n requestHandlers.forEach(handler => handler(request));\n });\n\n const _pageOn = page.on;\n page.on = function async(eventName, handler) {\n if (eventName === 'request') {\n requestHandlers.push(handler);\n\n return page;\n } else {\n return _pageOn.call(page, eventName, handler);\n }\n };\n\n if (this.requiresInterception) {\n await page.setRequestInterception(true);\n\n const thisOnRequest = this.onRequest.bind(this);\n page.on('request', thisOnRequest);\n offOnClose.push(() => page.off('request', thisOnRequest));\n }\n\n const thisOnDialog = this.onDialog.bind(this);\n page.on('dialog', thisOnDialog);\n offOnClose.push(() => page.off('dialog', thisOnDialog));\n\n await this.onPageCreated(page);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async onPageCreated(_page: Puppeteer.Page) { null; }\n\n protected async onRequest(request: Puppeteer.HTTPRequest) {\n const interceptionHandled = (request as any)._interceptionHandled;\n if (interceptionHandled) return;\n if (this.isStopped) return request.continue();\n\n await this.processRequest(request);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async processRequest(_request: Puppeteer.HTTPRequest) { null; }\n\n protected async onDialog(dialog: Dialog) {\n if (this.isStopped) return;\n\n const _dismiss = dialog.dismiss;\n dialog.dismiss = async () => {\n if (dialog.handled) return;\n\n dialog.handled = true;\n await _dismiss.apply(dialog);\n };\n\n await this.processDialog(dialog);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected async processDialog(_dialog: Dialog) { null; }\n\n protected async beforeRestart() { null; }\n async restart() {\n await this.beforeRestart();\n\n this.startCounter++;\n if (this.requiresInterception) interceptions++;\n\n this.dependencies.forEach(x => x.restart());\n\n await this.afterRestart();\n }\n protected async afterRestart() { null; }\n\n protected async beforeStop() { null; }\n async stop() {\n await this.beforeStop();\n\n this.startCounter--;\n if (this.requiresInterception) interceptions--;\n\n if (interceptions === 0 && this.browser) {\n const pages = await this.browser.pages();\n\n pages.filter(x => !x.isClosed()).forEach(async (page: Puppeteer.Page) => {\n await page.setRequestInterception(false);\n });\n }\n\n this.dependencies.forEach(x => x.stop());\n\n await this.afterStop();\n }\n protected async afterStop() { null; }\n\n protected async getFirstPage() {\n if (!this.browser) return null;\n\n const pages = await this.browser.pages();\n const openPages = pages.filter(x => !x.isClosed());\n const activePages = pages.filter(x => x.url() !== 'about:blank');\n\n return activePages[0] || openPages[0];\n }\n}\n\nlet plugins: Plugin[] = [];\nexport function addPlugin(plugin: Plugin) { plugins.push(plugin); }\nexport async function clearPlugins() {\n plugins.forEach(async plugin => {\n await plugin.stop();\n });\n\n plugins = [];\n}\n\nimport { AnonymizeUserAgentPlugin } from './plugins/anonymize.user.agent/index';\nexport function anonymizeUserAgent(): AnonymizeUserAgentPlugin {\n const plugin = new AnonymizeUserAgentPlugin();\n plugins.push(plugin);\n return plugin;\n}\n\nimport { AvoidDetectionPlugin } from './plugins/avoid.detection';\nexport function avoidDetection(): AvoidDetectionPlugin {\n const plugin = new AvoidDetectionPlugin();\n plugins.push(plugin);\n return plugin;\n}\n\nimport { BlockResourcesPlugin, Resource } from './plugins/block.resources';\nexport function blockResources(...resources: Resource[]): BlockResourcesPlugin {\n const plugin = new BlockResourcesPlugin(resources);\n plugins.push(plugin);\n return plugin;\n}\n\nimport { DisableDialogsPlugin } from './plugins/disable.dialogs';\nexport function disableDialogs(logMessages = false): DisableDialogsPlugin {\n const plugin = new DisableDialogsPlugin(logMessages);\n plugins.push(plugin);\n return plugin;\n}\n\nimport { ManageCookiesPlugin, ManageCookiesOption } from './plugins/manage.cookies';\nexport function manageCookies(opts: ManageCookiesOption): ManageCookiesPlugin {\n const plugin = new ManageCookiesPlugin(opts);\n plugins.push(plugin);\n return plugin;\n}\n\nimport { ManageLocalStoragePlugin, ManageLocalStorageOption } from './plugins/manage.localstorage';\nexport function manageLocalStorage(opts: ManageLocalStorageOption): ManageLocalStoragePlugin {\n const plugin = new ManageLocalStoragePlugin(opts);\n plugins.push(plugin);\n return plugin;\n}\n\nimport { SolveRecaptchaPlugin } from './plugins/solve.recaptcha';\nexport function solveRecaptchas(accessToken: string): SolveRecaptchaPlugin {\n const plugin = new SolveRecaptchaPlugin(accessToken);\n plugins.push(plugin);\n return plugin;\n}\n\ninterface Dialog extends Puppeteer.Dialog {\n handled: boolean;\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puppeteer-pro",
3
- "version": "1.7.6",
3
+ "version": "1.8.0",
4
4
  "description": "A simple puppeteer wrapper to enable useful plugins with ease",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,8 @@
11
11
  "postbuild": "npm run copy:injections && npm run copy:files",
12
12
  "copy:injections": "copyfiles -u 1 src/plugins/*/injections/* dist",
13
13
  "copy:files": "copyfiles package.json README.md LICENSE dist",
14
- "test": "jest"
14
+ "test": "jest",
15
+ "test-watch": "jest --watch"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
@@ -41,17 +42,17 @@
41
42
  "user-agents": "^1.0.1444"
42
43
  },
43
44
  "devDependencies": {
44
- "@types/jest": "^29.5.4",
45
- "@types/node": "^20.5.7",
45
+ "@types/jest": "^29.5.5",
46
+ "@types/node": "^20.6.5",
46
47
  "@types/user-agents": "^1.0.2",
47
- "@typescript-eslint/eslint-plugin": "^6.4.1",
48
- "@typescript-eslint/parser": "^6.4.1",
48
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
49
+ "@typescript-eslint/parser": "^6.7.2",
49
50
  "copyfiles": "^2.4.1",
50
51
  "dotenv-safe": "^8.2.0",
51
- "eslint": "^8.48.0",
52
- "eslint-plugin-deprecation": "^1.5.0",
53
- "jest": "^29.6.4",
54
- "puppeteer": "^21.1.0",
52
+ "eslint": "^8.50.0",
53
+ "eslint-plugin-deprecation": "^2.0.0",
54
+ "jest": "^29.7.0",
55
+ "puppeteer": "^21.3.4",
55
56
  "rimraf": "^5.0.1",
56
57
  "ts-jest": "^29.1.1",
57
58
  "ts-node": "^10.9.1",
@@ -0,0 +1,34 @@
1
+ import { Plugin } from '../../index';
2
+ export interface ManageLocalStorageOption {
3
+ saveLocation: string;
4
+ mode: 'manual' | 'monitor';
5
+ stringify?: (localStorage: Record<string, LocalStorage>) => string;
6
+ parse?: (localStorage: string) => Record<string, LocalStorage>;
7
+ disableWarning?: boolean;
8
+ profile?: 'string';
9
+ }
10
+ export declare class ManageLocalStoragePlugin extends Plugin {
11
+ private saveLocation;
12
+ private mode;
13
+ private stringify;
14
+ private parse;
15
+ private disableWarning;
16
+ private profile;
17
+ private allLocalStorage;
18
+ constructor(opts: ManageLocalStorageOption);
19
+ protected afterLaunch(): Promise<void>;
20
+ protected afterRestart(): Promise<void>;
21
+ switchToProfile(profile: string): Promise<void>;
22
+ save(): Promise<void>;
23
+ load(): Promise<void>;
24
+ clear(): Promise<void>;
25
+ private watchLocalStorage;
26
+ private saveProfileLocalStorage;
27
+ private loadProfileLocalStorage;
28
+ private clearProfileLocalStorage;
29
+ private setLocalStorage;
30
+ private getLocalStorage;
31
+ }
32
+ type LocalStorage = Record<string, Record<string, string>>;
33
+ export {};
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/manage.localstorage/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK,MAAM,CAAC;IACnE,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED,qBAAa,wBAAyB,SAAQ,MAAM;IAClD,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,SAAS,CAAgF;IACjG,OAAO,CAAC,KAAK,CAAsD;IACnE,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,OAAO,CAAa;IAE5B,OAAO,CAAC,eAAe,CAAoC;gBAE/C,IAAI,EAAE,wBAAwB;cAgB1B,WAAW;cAQX,YAAY;IAItB,eAAe,CAAC,OAAO,EAAE,MAAM;IAQ/B,IAAI;IAOJ,IAAI;IAOJ,KAAK;YAMG,iBAAiB;YAyBjB,uBAAuB;YAOvB,uBAAuB;YAIvB,wBAAwB;YAOxB,eAAe;YAoBf,eAAe;CAgB9B;AAED,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ // https://gist.github.com/jeroenvisser101/636030fe66ea929b63a33f5cb3a711ad
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ManageLocalStoragePlugin = void 0;
5
+ const crypto = require("crypto");
6
+ const fs = require("fs");
7
+ const index_1 = require("../../index");
8
+ const sleep = (time) => { return new Promise(resolve => { setTimeout(resolve, time); }); };
9
+ class ManageLocalStoragePlugin extends index_1.Plugin {
10
+ constructor(opts) {
11
+ super();
12
+ this.saveLocation = '';
13
+ this.mode = '';
14
+ this.stringify = (localStorage) => JSON.stringify(localStorage);
15
+ this.parse = (localStorage) => JSON.parse(localStorage);
16
+ this.disableWarning = false;
17
+ this.profile = 'default';
18
+ this.allLocalStorage = {};
19
+ // Need to find a better typescript way of doing this
20
+ this.saveLocation = opts.saveLocation || this.saveLocation;
21
+ this.mode = opts.mode || this.mode;
22
+ this.stringify = opts.stringify || this.stringify;
23
+ this.parse = opts.parse || this.parse;
24
+ this.disableWarning = opts.disableWarning || this.disableWarning;
25
+ this.profile = opts.profile || this.profile;
26
+ if (this.disableWarning !== true) {
27
+ console.warn('Warning: Exposing local storage in an unprotected manner can compromise your security. Add the `disableWarning` flag to remove this message.');
28
+ }
29
+ }
30
+ async afterLaunch() {
31
+ if (fs.existsSync(this.saveLocation)) {
32
+ this.allLocalStorage = this.parse(fs.readFileSync(this.saveLocation).toString() || '{}');
33
+ }
34
+ void this.watchLocalStorage();
35
+ }
36
+ async afterRestart() {
37
+ void this.watchLocalStorage();
38
+ }
39
+ async switchToProfile(profile) {
40
+ if (this.isStopped)
41
+ return;
42
+ this.profile = profile;
43
+ await this.loadProfileLocalStorage();
44
+ }
45
+ async save() {
46
+ if (this.isStopped)
47
+ return;
48
+ if (this.mode !== 'manual')
49
+ return;
50
+ await this.saveProfileLocalStorage();
51
+ }
52
+ async load() {
53
+ if (this.isStopped)
54
+ return;
55
+ if (this.mode !== 'manual')
56
+ return;
57
+ await this.loadProfileLocalStorage();
58
+ }
59
+ async clear() {
60
+ if (this.isStopped)
61
+ return;
62
+ await this.clearProfileLocalStorage();
63
+ }
64
+ async watchLocalStorage() {
65
+ if (this.isStopped)
66
+ return;
67
+ if (this.mode !== 'monitor')
68
+ return;
69
+ const hash = (x) => crypto.createHash('md5').update(x).digest('hex');
70
+ let oldProfile = '';
71
+ let oldHash = '';
72
+ while (!this.isStopped) {
73
+ const localStorage = { [this.profile]: await this.getLocalStorage() };
74
+ const localStorageString = this.stringify(localStorage);
75
+ const newHash = hash(localStorageString);
76
+ if (oldProfile !== this.profile) {
77
+ oldProfile = this.profile;
78
+ }
79
+ else if (oldHash !== newHash) {
80
+ oldHash = newHash;
81
+ await this.saveProfileLocalStorage();
82
+ }
83
+ else {
84
+ await sleep(300);
85
+ }
86
+ }
87
+ }
88
+ async saveProfileLocalStorage() {
89
+ this.allLocalStorage[this.profile] = await this.getLocalStorage();
90
+ const localStorageString = this.stringify(this.allLocalStorage);
91
+ fs.writeFileSync(this.saveLocation, localStorageString);
92
+ }
93
+ async loadProfileLocalStorage() {
94
+ await this.setLocalStorage(this.allLocalStorage[this.profile] || {});
95
+ }
96
+ async clearProfileLocalStorage() {
97
+ delete this.allLocalStorage[this.profile];
98
+ const localStorageString = this.stringify(this.allLocalStorage);
99
+ fs.writeFileSync(this.saveLocation, localStorageString);
100
+ }
101
+ async setLocalStorage(allLocalStorage) {
102
+ if (!this.browser)
103
+ return;
104
+ const pages = await this.browser.pages();
105
+ const activePages = pages.filter(x => x.url() !== 'about:blank');
106
+ for (const page of activePages) {
107
+ const origin = await page.evaluate(() => window.origin);
108
+ await page.evaluate(originLocalStorage => {
109
+ const keys = Object.keys(originLocalStorage);
110
+ localStorage.clear();
111
+ for (let i = 0; i < Object.keys(localStorage).length; i++) {
112
+ localStorage.setItem(keys[i], originLocalStorage[keys[i]]);
113
+ }
114
+ }, allLocalStorage[origin] || {});
115
+ }
116
+ }
117
+ async getLocalStorage() {
118
+ if (!this.browser)
119
+ return {};
120
+ const allLocalStorage = {};
121
+ const pages = await this.browser.pages();
122
+ const activePages = pages.filter(x => x.url() !== 'about:blank');
123
+ for (const page of activePages) {
124
+ const originLocalStorage = await page.evaluate(() => ({ [window.origin]: { ...localStorage } }));
125
+ Object.assign(allLocalStorage, originLocalStorage);
126
+ }
127
+ return allLocalStorage;
128
+ }
129
+ }
130
+ exports.ManageLocalStoragePlugin = ManageLocalStoragePlugin;
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/manage.localstorage/index.ts"],"names":[],"mappings":";AAAA,2EAA2E;;;AAE3E,iCAAiC;AACjC,yBAAyB;AAEzB,uCAAqC;AAErC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,GAAG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAWnG,MAAa,wBAAyB,SAAQ,cAAM;IAUlD,YAAY,IAA8B;QACxC,KAAK,EAAE,CAAC;QAVF,iBAAY,GAAG,EAAE,CAAC;QAClB,SAAI,GAAG,EAAE,CAAC;QACV,cAAS,GAAG,CAAC,YAA0C,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACzF,UAAK,GAAG,CAAC,YAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC3D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AAjJD,4DAiJC","sourcesContent":["// https://gist.github.com/jeroenvisser101/636030fe66ea929b63a33f5cb3a711ad\n\nimport * as crypto from 'crypto';\nimport * as fs from 'fs';\n\nimport { Plugin } from '../../index';\n\nconst sleep = (time: number) => { return new Promise(resolve => { setTimeout(resolve, time); }); };\n\nexport interface ManageLocalStorageOption {\n saveLocation: string;\n mode: 'manual' | 'monitor';\n stringify?: (localStorage: Record<string, LocalStorage>) => string;\n parse?: (localStorage: string) => Record<string, LocalStorage>;\n disableWarning?: boolean;\n profile?: 'string';\n}\n\nexport class ManageLocalStoragePlugin extends Plugin {\n private saveLocation = '';\n private mode = '';\n private stringify = (localStorage: Record<string, LocalStorage>) => JSON.stringify(localStorage);\n private parse = (localStorage: string) => JSON.parse(localStorage);\n private disableWarning = false;\n private profile = 'default';\n\n private allLocalStorage: Record<string, LocalStorage> = {};\n\n constructor(opts: ManageLocalStorageOption) {\n super();\n\n // Need to find a better typescript way of doing this\n this.saveLocation = opts.saveLocation || this.saveLocation;\n this.mode = opts.mode || this.mode;\n this.stringify = opts.stringify || this.stringify;\n this.parse = opts.parse || this.parse;\n this.disableWarning = opts.disableWarning || this.disableWarning;\n this.profile = opts.profile || this.profile;\n\n if (this.disableWarning !== true) {\n console.warn('Warning: Exposing local storage in an unprotected manner can compromise your security. Add the `disableWarning` flag to remove this message.');\n }\n }\n\n protected async afterLaunch() {\n if (fs.existsSync(this.saveLocation)) {\n this.allLocalStorage = this.parse(fs.readFileSync(this.saveLocation).toString() || '{}');\n }\n\n void this.watchLocalStorage();\n }\n\n protected async afterRestart() {\n void this.watchLocalStorage();\n }\n\n async switchToProfile(profile: string) {\n if (this.isStopped) return;\n\n this.profile = profile;\n\n await this.loadProfileLocalStorage();\n }\n\n async save() {\n if (this.isStopped) return;\n if (this.mode !== 'manual') return;\n\n await this.saveProfileLocalStorage();\n }\n\n async load() {\n if (this.isStopped) return;\n if (this.mode !== 'manual') return;\n\n await this.loadProfileLocalStorage();\n }\n\n async clear() {\n if (this.isStopped) return;\n\n await this.clearProfileLocalStorage();\n }\n\n private async watchLocalStorage() {\n if (this.isStopped) return;\n if (this.mode !== 'monitor') return;\n\n const hash = (x: string) => crypto.createHash('md5').update(x).digest('hex');\n\n let oldProfile = '';\n let oldHash = '';\n\n while (!this.isStopped) {\n const localStorage = { [this.profile]: await this.getLocalStorage() };\n const localStorageString = this.stringify(localStorage);\n const newHash = hash(localStorageString);\n\n if (oldProfile !== this.profile) {\n oldProfile = this.profile;\n } else if (oldHash !== newHash) {\n oldHash = newHash;\n await this.saveProfileLocalStorage();\n } else {\n await sleep(300);\n }\n }\n }\n\n private async saveProfileLocalStorage() {\n this.allLocalStorage[this.profile] = await this.getLocalStorage();\n\n const localStorageString = this.stringify(this.allLocalStorage);\n fs.writeFileSync(this.saveLocation, localStorageString);\n }\n\n private async loadProfileLocalStorage() {\n await this.setLocalStorage(this.allLocalStorage[this.profile] || {});\n }\n\n private async clearProfileLocalStorage() {\n delete this.allLocalStorage[this.profile];\n\n const localStorageString = this.stringify(this.allLocalStorage);\n fs.writeFileSync(this.saveLocation, localStorageString);\n }\n\n private async setLocalStorage(allLocalStorage: LocalStorage) {\n if (!this.browser) return;\n\n const pages = await this.browser.pages();\n const activePages = pages.filter(x => x.url() !== 'about:blank');\n\n for (const page of activePages) {\n const origin = await page.evaluate(() => window.origin);\n\n await page.evaluate(originLocalStorage => {\n const keys = Object.keys(originLocalStorage);\n localStorage.clear();\n\n for (let i = 0; i < Object.keys(localStorage).length; i++) {\n localStorage.setItem(keys[i], originLocalStorage[keys[i]]);\n }\n }, allLocalStorage[origin] || {});\n }\n }\n\n private async getLocalStorage() {\n if (!this.browser) return {};\n\n const allLocalStorage: LocalStorage = {};\n\n const pages = await this.browser.pages();\n const activePages = pages.filter(x => x.url() !== 'about:blank');\n\n for (const page of activePages) {\n const originLocalStorage = await page.evaluate(() => ({ [window.origin]: { ...localStorage } })) as LocalStorage;\n\n Object.assign(allLocalStorage, originLocalStorage);\n }\n\n return allLocalStorage;\n }\n}\n\ntype LocalStorage = Record<string, Record<string, string>>;"]}