Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const devtools_1 = __importDefault(require("../../utils/interception/devtools"));
  7. const webdriver_1 = __importDefault(require("../../utils/interception/webdriver"));
  8. const utils_1 = require("../../utils");
  9. const SESSION_MOCKS = {};
  10. async function mock(url, filterOptions) {
  11. const NetworkInterception = this.isSauce ? webdriver_1.default : devtools_1.default;
  12. if (!this.isSauce) {
  13. await this.getPuppeteer();
  14. }
  15. const browser = utils_1.getBrowserObject(this);
  16. const handle = await browser.getWindowHandle();
  17. if (!SESSION_MOCKS[handle]) {
  18. SESSION_MOCKS[handle] = new Set();
  19. }
  20. if (SESSION_MOCKS[handle].size === 0 && !this.isSauce) {
  21. const pages = await this.puppeteer.pages();
  22. let page;
  23. for (let i = 0; i < pages.length && !page; i++) {
  24. const isHidden = await pages[i].evaluate(() => document.hidden);
  25. if (!isHidden) {
  26. page = pages[i];
  27. }
  28. }
  29. if (!page) {
  30. page = pages[0];
  31. }
  32. const client = await page.target().createCDPSession();
  33. await client.send('Fetch.enable', {
  34. patterns: [{ requestStage: 'Request' }, { requestStage: 'Response' }]
  35. });
  36. client.on('Fetch.requestPaused', NetworkInterception
  37. .handleRequestInterception(client, SESSION_MOCKS[handle]));
  38. }
  39. const networkInterception = new NetworkInterception(url, filterOptions, browser);
  40. SESSION_MOCKS[handle].add(networkInterception);
  41. if (this.isSauce) {
  42. await networkInterception.init();
  43. }
  44. return networkInterception;
  45. }
  46. exports.default = mock;