Skip to content
This repository was archived by the owner on Feb 25, 2022. It is now read-only.

Commit af1f2aa

Browse files
committed
Change logo; Minor enhancements to improve bundle size and performance
1 parent 1d6c1da commit af1f2aa

17 files changed

+196
-132
lines changed

LICENSE.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 28 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
1-
# Chrome Extension Webpack Boilerplate
1+
# Minimal Web Clipper
22

3-
A basic foundation boilerplate for rich Chrome Extensions using [Webpack](https://webpack.github.io/) to help you write modular and modern Javascript code, load CSS easily and [automatic reload the browser on code changes](https://webpack.github.io/docs/webpack-dev-server.html#automatic-refresh).
3+
A dead simple chrome extension for clipping selections from web pages.
44

5-
## Developing a new extension
6-
_I'll assume that you already read the [Webpack docs](https://webpack.github.io/docs) and the [Chrome Extension](https://developer.chrome.com/extensions/getstarted) docs._
5+
It allows selection of parts of a webpage and downloads the clipped content as a standalone HTML file preserving the original look and feel as closely as possible. This file can be opened and previewed in any standard web browser.
6+
7+
## TODO
8+
9+
[ ] Support for shadow dom.
10+
[ ] Support for downloading fonts.
11+
[ ] Support for frames and iframes.
12+
[ ] Annotating clips before download
13+
[ ] Editing and previewing clips
14+
15+
## Non-goals
16+
17+
- Synchronization support
18+
- Dependency on proprietary web services
19+
20+
## About Fluid Notion
21+
22+
[Fluid Notion](https://github.com/fluid-notion) is a suite of minimal open-source productivity tools.
23+
24+
## Development
25+
26+
This plugin was based on [Samuel Simões](https://twitter.com/samuelsimoes)'s [Chrome extension boilerplate](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate).
27+
28+
## Local installation during development
729

830
1. Clone the repository.
931
2. Install [yarn](https://yarnpkg.com): `npm install -g yarn`.
@@ -18,86 +40,11 @@ _I'll assume that you already read the [Webpack docs](https://webpack.github.io/
1840
4. Select the `build` folder.
1941
8. Have fun.
2042

21-
## Structure
22-
All your extension's development code must be placed in `src` folder, including the extension manifest.
23-
24-
The boilerplate is already prepared to have a popup, a options page and a background page. You can easily customize this.
25-
26-
Each page has its own [assets package defined](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/blob/master/webpack.config.js#L16-L20). So, to code on popup you must start your code on `src/js/popup.js`, for example.
27-
28-
You must use the [ES6 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) to a better code organization. The boilerplate is already prepared to that and [here you have a little example](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/blob/master/src/js/popup.js#L2-L4).
29-
30-
## Webpack auto-reload and HRM
31-
To make your workflow much more efficient this boilerplate uses the [webpack server](https://webpack.github.io/docs/webpack-dev-server.html) to development (started with `npm run server`) with auto reload feature that reloads the browser automatically every time that you save some file o your editor.
32-
33-
You can run the dev mode on other port if you want. Just specify the env var `port` like this:
34-
35-
```
36-
$ PORT=6002 npm run start
37-
```
38-
39-
## Content Scripts
40-
41-
Although this boilerplate uses the webpack dev server, it's also prepared to write all your bundles files on the disk at every code change, so you can point, on your extension manifest, to your bundles that you want to use as [content scripts](https://developer.chrome.com/extensions/content_scripts), but you need to exclude these entry points from hot reloading [(why?)](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/issues/4#issuecomment-261788690). To do so you need to expose which entry points are content scripts on the `webpack.config.js` using the `chromeExtensionBoilerplate -> notHotReload` config. Look the example below.
42-
43-
Let's say that you want use the `myContentScript` entry point as content script, so on your `webpack.config.js` you will configure the entry point and exclude it from hot reloading, like this:
44-
45-
```js
46-
{
47-
48-
entry: {
49-
myContentScript: "./src/js/myContentScript.js"
50-
},
51-
chromeExtensionBoilerplate: {
52-
notHotReload: ["myContentScript"]
53-
}
54-
55-
}
56-
```
57-
58-
and on your `src/manifest.json`:
59-
60-
```json
61-
{
62-
"content_scripts": [
63-
{
64-
"matches": ["https://www.google.com/*"],
65-
"js": ["myContentScript.bundle.js"]
66-
}
67-
]
68-
}
69-
70-
```
71-
7243
## Packing
44+
7345
After the development of your extension run the command
7446

7547
```
7648
$ NODE_ENV=production npm run build
7749
```
78-
Now, the content of `build` folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the [official guide](https://developer.chrome.com/webstore/publish) to more infos about publishing.
79-
80-
## Secrets
81-
If you are developing an extension that talks with some API you probably are using different keys for testing and production. Is a good practice you not commit your secret keys and expose to anyone that have access to the repository.
82-
83-
To this task this boilerplate import the file `./secrets.<THE-NODE_ENV>.js` on your modules through the module named as `secrets`, so you can do things like this:
84-
85-
_./secrets.development.js_
86-
87-
```js
88-
export default { key: "123" };
89-
```
90-
91-
_./src/popup.js_
92-
93-
```js
94-
import secrets from "secrets";
95-
ApiCall({ key: secrets.key });
96-
```
97-
:point_right: The files with name `secrets.*.js` already are ignored on the repository.
98-
99-
## With React.js
100-
:bulb: If you want use [React.js](https://facebook.github.io/react/) with this boilerplate, check the **[react branch](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/tree/react)**.
101-
102-
-------------
103-
Samuel Simões ~ [@samuelsimoes](https://twitter.com/samuelsimoes) ~ [Blog](http://blog.samuelsimoes.com/)
50+
Now, the content of `build` folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the [official guide](https://developer.chrome.com/webstore/publish) to more information.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"name": "minimal-web-clipper",
3-
"version": "0.0.1",
3+
"version": "0.0.3",
4+
"keywords": [
5+
"productivity",
6+
"clipper",
7+
"web-clipper"
8+
],
49
"description": "A minimal web clipper",
510
"scripts": {
611
"clean": "rm -rf build/*",
@@ -27,6 +32,7 @@
2732
"dependencies": {
2833
"debug": "^3.1.0",
2934
"image-to-data-uri": "^1.1.0",
35+
"imports-loader": "^0.7.1",
3036
"ios-overlay": "^0.0.3",
3137
"keycode": "^2.1.9",
3238
"lodash.debounce": "^4.0.8",
@@ -35,6 +41,7 @@
3541
"selector-query": "^1.0.1",
3642
"spin.js": "^3.1.0",
3743
"styletron": "^3.0.2",
44+
"velocity-animate": "^1.5.1",
3845
"zepto": "^1.2.0"
3946
}
4047
}

src/img/icon-128.png

-1.07 KB
Loading

src/img/icon-34.png

355 Bytes
Loading

src/img/icon.gvdesign

-3.23 KB
Binary file not shown.

src/img/logo.svg

Lines changed: 82 additions & 0 deletions
Loading

src/img/scissor-icon.gvdesign

-2.9 KB
Binary file not shown.

src/img/scissor.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/js/Clipper.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const IGNORED_TAG_TYPES = [
2121
];
2222

2323
export const Clipper = {
24+
2425
async clip(target) {
2526
if (target.length === 0) {
2627
return;
@@ -30,6 +31,7 @@ export const Clipper = {
3031
const clone = await this.visitNode(target);
3132
await downloadAsFile(this.buildFinalHTML(clone, selector));
3233
},
34+
3335
buildFinalHTML(clone, selector) {
3436
return `
3537
<html>
@@ -40,19 +42,23 @@ export const Clipper = {
4042
</head>
4143
<body>
4244
${clone.html()}
43-
<hr/>
44-
<div>Captured from <strong><a href="${location.href}">${location.href}</a></strong> at <strong>${new Date()}</strong> using <strong style="color: rgb(144, 67, 153)">Minimal Web Clipper</strong></div>
45+
<div style="color: silver; border-top: 1px solid silver; padding: 10px 0; clear: both; margin-top: 10px; font-size: 12px; font-family: arial;">
46+
Captured from <strong><a href="${location.href}">${location.href}</a></strong> at <strong>${new Date()}</strong> using
47+
<a href="https://chrome.google.com/webstore/detail/minimal-web-clipper/dbhjdoppiocfognmfiaoeipkpdljefni"><strong style="color: rgb(144, 67, 153)">Minimal Web Clipper</strong></a>
48+
</div>
4549
<!-- [MWC:Meta]
4650
Selector: ${selector}
4751
-->
4852
</body>
4953
</html>
5054
`;
5155
},
56+
5257
injectCSSDeclaration(prop, val) {
5358
const styClass = this.styles.injectDeclaration({ prop, val });
5459
return `mwc-${styClass}`;
5560
},
61+
5662
buildFinalCSS() {
5763
debug('Consolidating styles');
5864
let cssText = '';
@@ -66,6 +72,7 @@ Selector: ${selector}
6672
}
6773
return cssText;
6874
},
75+
6976
async visitNode($el) {
7077
if ($el.length === 0) return;
7178
if ($el.hasClass('ios-overlay')) return;
@@ -124,7 +131,9 @@ Selector: ${selector}
124131
const children = $el.contents();
125132
for (let idx = 0 ; idx < children.length ; idx++) {
126133
// Keep the browser responsive
127-
await timeout(100);
134+
if (idx % 10 === 0) {
135+
await timeout(0);
136+
}
128137
const el = children[idx];
129138
if (el.nodeType !== 1) {
130139
$clone.append($(el).clone());

0 commit comments

Comments
 (0)