From f8470c1750ce92fefec304b3d6f6d855d836ebc3 Mon Sep 17 00:00:00 2001 From: Rafael Grigorian Date: Wed, 20 Jan 2021 21:18:37 -0600 Subject: [PATCH] Changes related to #22 --- README.md | 9 +++++---- package.json | 6 +++--- spec/ui.spec.js | 4 ++-- tools/create-marketing.js | 20 ++++++++++---------- utils/{Chrome.js => Browser.js} | 16 +++++++++++++++- yarn.lock | 8 ++++---- 6 files changed, 39 insertions(+), 24 deletions(-) rename utils/{Chrome.js => Browser.js} (89%) diff --git a/README.md b/README.md index 94d9383..a6dffcd 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ -# Chrome Extension - MILK +# MILK — Cookie Manager > Cookie's best friend! Modern cookie manager. ![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge&color=1A73E8) ![Version 2.3.0](https://img.shields.io/badge/Version-2.3.0-yellow.svg?style=for-the-badge&color=1A73E8) -![Users](https://img.shields.io/chrome-web-store/d/haipckejfdppjfblgondaakgckohcihp.svg?style=for-the-badge&color=1A73E8) -![Rating](https://img.shields.io/chrome-web-store/rating/haipckejfdppjfblgondaakgckohcihp.svg?style=for-the-badge&color=1A73E8) -![Reviews](https://img.shields.io/chrome-web-store/rating-count/haipckejfdppjfblgondaakgckohcihp.svg?style=for-the-badge&color=1A73E8) +![Chrome Users](https://img.shields.io/chrome-web-store/d/haipckejfdppjfblgondaakgckohcihp.svg?style=for-the-badge&color=1A73E8&label=chrome-users) +![Chrome Rating](https://img.shields.io/chrome-web-store/rating/haipckejfdppjfblgondaakgckohcihp.svg?style=for-the-badge&color=1A73E8&label=chrome-rating) + + ![screenshot](assets/images/github-banner.png) diff --git a/package.json b/package.json index 70d681e..7c57f43 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "milk-cookie-manager", "version": "2.3.0", - "description": "Chrome extension that manages your browser's cookies", + "description": "Cookie's best friend! Modern cookie manager.", "author": "Rafael Grigorian ", "license": "MIT", "scripts": { @@ -14,14 +14,14 @@ "publish:chrome": "echo not supported yet", "clean": "rm -rf dist .parcel-cache target", "nuke": "yarn clean && rm -rf node_modules", - "test": "yarn clean && yarn build && mocha spec", + "test:chrome": "yarn clean && yarn build && mocha spec", "marketing": "yarn clean && yarn build && node tools/create-marketing.js" }, "dependencies": { "@emotion/react": "^11.1.1", "@emotion/styled": "^11.0.0", "@material-ui/core": "^5.0.0-alpha.18", - "@material-ui/icons": "^5.0.0-alpha.14", + "@material-ui/icons": "^5.0.0-alpha.23", "bluebird": "^3.7.2", "copy-to-clipboard": "^3.3.1", "lodash": "^4.17.20", diff --git a/spec/ui.spec.js b/spec/ui.spec.js index 33b53b0..7f40511 100644 --- a/spec/ui.spec.js +++ b/spec/ui.spec.js @@ -1,7 +1,7 @@ "use strict" const Promise = require ("bluebird") -const Chrome = require ("../utils/Chrome") +const Browser = require ("../utils/Browser") const assert = require ("assert") describe ( "User Interface", function () { @@ -10,7 +10,7 @@ describe ( "User Interface", function () { describe ( "Search", function () { it ( "Can type in search box", function () { - return Chrome ( async chrome => await Promise.resolve () + return Browser ( async chrome => await Promise.resolve () .then ( () => chrome.goto ( "index.html" ) ) .then ( () => chrome.page.type ( "#search", "Hello World" ) ) .then ( () => chrome.page.$("#search") ) diff --git a/tools/create-marketing.js b/tools/create-marketing.js index edb8d1c..4f7d417 100644 --- a/tools/create-marketing.js +++ b/tools/create-marketing.js @@ -1,11 +1,11 @@ "use strict" const Promise = require ("bluebird") -const Chrome = require ("../utils/Chrome") +const Browser = require ("../utils/Browser") const cookies = require ("../data/marketing") const jimp = require ("jimp") -return Chrome ( async chrome => await Promise.resolve () +return Browser ( async chrome => await Promise.resolve () .then ( () => chrome.goto ("index.html") ) .then ( () => chrome.cookies.set ( cookies ) ) .then ( () => chrome.cookies.protect ([ cookies [ 0 ], cookies [ 3 ] ]) ) @@ -22,39 +22,39 @@ return Chrome ( async chrome => await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 550, height: 530 })) .then ( () => chrome.goto ("index.html") ) .then ( () => chrome.storage ({ regexp: false, dark: false }) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), dark_panel_list: await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 550, height: 530 })) .then ( () => chrome.goto ("index.html") ) .then ( () => chrome.storage ({ regexp: true, dark: true }) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), light_panel_list_highlight: await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 550, height: 530 })) .then ( () => chrome.goto ("index.html") ) .then ( () => chrome.storage ({ regexp: false, dark: false }) ) .then ( () => chrome.page.type ( "#search", "example.com" ) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), dark_panel_list_highlight: await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 550, height: 530 })) .then ( () => chrome.goto ("index.html") ) .then ( () => chrome.storage ({ regexp: true, dark: true }) ) .then ( () => chrome.page.type ( "#search", "^.?(example|blog)" ) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), dark_options_top: await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 1280, height: 800 })) .then ( () => chrome.goto ("options.html") ) .then ( () => chrome.storage ({ regexp: true, dark: true }) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), dark_options_bottom: await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 1280, height: 800 })) .then ( () => chrome.goto ("options.html#blocked-cookies") ) .then ( () => chrome.storage ({ regexp: true, dark: true }) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), light_panel_add: await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 550, height: 530 })) @@ -64,7 +64,7 @@ return Chrome ( async chrome => await Promise.resolve () .then ( () => chrome.page.type ( "input[name='domain']", "example.com" ) ) .then ( () => chrome.page.type ( "input[name='value']", "d29vdCwgeW91IGZpZ3VyZWQgaXQgb3V0IQ==" ) ) .then ( () => chrome.page.type ( "input[name='name']", "modern_cookie_manager" ) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), dark_panel_add: await Promise.resolve () .then ( () => chrome.page.setViewport ({ width: 550, height: 530 })) @@ -74,7 +74,7 @@ return Chrome ( async chrome => await Promise.resolve () .then ( () => chrome.page.type ( "input[name='domain']", "example.com" ) ) .then ( () => chrome.page.type ( "input[name='value']", "d29vdCwgeW91IGZpZ3VyZWQgaXQgb3V0IQ==" ) ) .then ( () => chrome.page.type ( "input[name='name']", "modern_cookie_manager" ) ) - .then ( () => chrome.page.screenshot ({ type: "png" }) ) + .then ( () => chrome.screenshot () ) .then ( image => jimp.read ( image ) ), })) .then ( ({ template, ...screenshot }) => { diff --git a/utils/Chrome.js b/utils/Browser.js similarity index 89% rename from utils/Chrome.js rename to utils/Browser.js index c7154f8..26af36c 100644 --- a/utils/Chrome.js +++ b/utils/Browser.js @@ -4,6 +4,12 @@ const Promise = require ("bluebird") const puppeteer = require ("puppeteer") const manifest = require ("../static/manifest.json") +function sleep ( ms ) { + return new Promise ( resolve => { + setTimeout ( resolve, ms ) + }) +} + async function launch () { const browser = await puppeteer.launch ({ headless: false, @@ -32,7 +38,7 @@ async function launch () { module.exports = async function ( callback ) { const { browser, page, template } = await launch () return callback ({ - browser, page, + browser, page, sleep, goto ( path ) { return page.goto (`${template}/${path}`) }, @@ -46,6 +52,14 @@ module.exports = async function ( callback ) { ) }, data ) }, + screenshot () { + return Promise.resolve () + .then ( () => page.evaluate ( () => { + document.title = "🔴Waiting For Screenshot" + })) + .then ( () => sleep ( 1000 ) ) + .then ( () => page.screenshot ({ type: "png" }) ) + }, cookies: { hash ( cookie ) { return `<${cookie.name}><${cookie.domain}><${cookie.path}>` diff --git a/yarn.lock b/yarn.lock index 6337bd2..0f2209d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1396,10 +1396,10 @@ react-is "^16.8.0 || ^17.0.0" react-transition-group "^4.4.0" -"@material-ui/icons@^5.0.0-alpha.14": - version "5.0.0-alpha.19" - resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-5.0.0-alpha.19.tgz#16a57cdb54aea3c57c0ba5601e9283bf28f3f90d" - integrity sha512-5FNUZ0Xw9BXBJhQVwTO5rV5yvR2N3C52IfFOWYSSVWVSot0WJ1ZP9qU+dY+qJWEcTlEcV+aG6nvG6b9eLoP7KA== +"@material-ui/icons@^5.0.0-alpha.23": + version "5.0.0-alpha.23" + resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-5.0.0-alpha.23.tgz#b7d5141cfaa1df4a9697c60e50df2e5f2c6a0047" + integrity sha512-paML0ghK4qN+Z0oAd66lDfX1+Vt1LBPkMA9uSUEBmGga2yY8aGpo9tAVGM3UR7kTx0BEWT5e/4u2aDvwbdGZPQ== dependencies: "@babel/runtime" "^7.4.4"