Skip to content

Commit f7cc2d6

Browse files
committed
clipper(web): add web clipper browser extension
1 parent ad91da9 commit f7cc2d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+39005
-1
lines changed

extensions/web-clipper/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build.pem
7.22 KB
Loading
520 Bytes
Loading
917 Bytes
Loading
19 KB
Loading
1.23 KB
Loading
2.07 KB
Loading
2.89 KB
Loading
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Do this as the first thing so that any code reading it knows the right env.
2+
process.env.BABEL_ENV = "production";
3+
process.env.NODE_ENV = "production";
4+
process.env.ASSET_PATH = "/";
5+
6+
var webpack = require("webpack"),
7+
config = require("../webpack.config");
8+
9+
delete config.chromeExtensionBoilerplate;
10+
11+
config.mode = "production";
12+
13+
webpack(config, function (err) {
14+
if (err) throw err;
15+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Do this as the first thing so that any code reading it knows the right env.
2+
process.env.BABEL_ENV = "development";
3+
process.env.NODE_ENV = "development";
4+
process.env.ASSET_PATH = "/";
5+
6+
var WebpackDevServer = require("webpack-dev-server"),
7+
webpack = require("webpack"),
8+
config = require("../webpack.config"),
9+
env = require("./env"),
10+
path = require("path");
11+
12+
var options = config.chromeExtensionBoilerplate || {};
13+
var excludeEntriesToHotReload = options.notHotReload || [];
14+
15+
for (var entryName in config.entry) {
16+
if (excludeEntriesToHotReload.indexOf(entryName) === -1) {
17+
config.entry[entryName] = [
18+
"webpack/hot/dev-server",
19+
`webpack-dev-server/client?hot=true&hostname=localhost&port=${env.PORT}`,
20+
].concat(config.entry[entryName]);
21+
}
22+
}
23+
24+
config.plugins = [new webpack.HotModuleReplacementPlugin()].concat(
25+
config.plugins || []
26+
);
27+
28+
delete config.chromeExtensionBoilerplate;
29+
30+
var compiler = webpack(config);
31+
32+
var server = new WebpackDevServer(
33+
{
34+
https: false,
35+
hot: false,
36+
client: false,
37+
host: "localhost",
38+
port: env.PORT,
39+
static: {
40+
directory: path.join(__dirname, "../build"),
41+
},
42+
devMiddleware: {
43+
publicPath: `http://localhost:${env.PORT}/`,
44+
writeToDisk: true,
45+
},
46+
headers: {
47+
"Access-Control-Allow-Origin": "*",
48+
},
49+
allowedHosts: "all",
50+
},
51+
compiler
52+
);
53+
54+
if (process.env.NODE_ENV === "development" && module.hot) {
55+
module.hot.accept();
56+
}
57+
58+
(async () => {
59+
await server.start();
60+
})();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// tiny wrapper with default env vars
2+
module.exports = {
3+
NODE_ENV: process.env.NODE_ENV || "development",
4+
PORT: process.env.PORT || 3000,
5+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const ICONS = {
2+
16: "16x16.png",
3+
32: "32x32.png",
4+
48: "48x48.png",
5+
64: "64x64.png",
6+
128: "128x128.png",
7+
256: "256x256.png"
8+
};
9+
const BACKGROUND_SCRIPT = "background.bundle.js";
10+
const ACTION = {
11+
default_icon: ICONS,
12+
default_title: "Notesnook Web Clipper",
13+
default_popup: "popup.html"
14+
};
15+
16+
const common = {
17+
name: "Notesnook Web Clipper",
18+
version: "1.0",
19+
description: "Clip web pages.",
20+
permissions: [
21+
"activeTab",
22+
"tabs",
23+
"storage",
24+
"contextMenus",
25+
"notifications"
26+
],
27+
key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmXQb9xwsSWbvAbBVnWa+DwsXLtRLbjfLyWRZtT5KF8bjCrEg3InvntWlk1PrNo73lsTov1m8Y5K9fJcCVKuYZkTCmNf4iGsHqOafi9ny5MX53oQ53+/s7gao2ZicHtTylnCIqn8f/l+RkV3tHO8BwANDLX2TTe7zCYLzFH19jiKAI+7qmUDZvyCH/OMVohluUCQO94s7sghslalwPbAcQQLpAKxYdd5GJDn4FryitsCMTYX962X+O6Tivq2QPML/Gm7BrZqJsU1enFRH1ss0UK0b9COpEYqqPhZ+GJP5K6WOL46NX+CvZnQmux1ehTZgIhw64IQJ57TvG2kIQTA8ZQIDAQAB",
28+
content_scripts: [
29+
{
30+
js: ["nnContentScript.bundle.js"],
31+
matches: ["*://app.notesnook.com/*", "*://localhost/*"]
32+
},
33+
{
34+
js: ["contentScript.bundle.js"],
35+
matches: ["http://*/*", "https://*/*"],
36+
exclude_matches: ["*://app.notesnook.com/*", "*://localhost/*"]
37+
},
38+
],
39+
browser_specific_settings: {
40+
gecko: {
41+
strict_min_version: "105.0"
42+
}
43+
},
44+
icons: ICONS,
45+
};
46+
47+
const v2 = {
48+
...common,
49+
manifest_version: 2,
50+
background: {
51+
scripts: [BACKGROUND_SCRIPT]
52+
},
53+
browser_action: ACTION
54+
};
55+
56+
const v3 = {
57+
...common,
58+
manifest_version: 3,
59+
background: {
60+
service_worker: BACKGROUND_SCRIPT
61+
},
62+
action: ACTION
63+
};
64+
65+
module.exports = {
66+
v2,
67+
v3
68+
};

extensions/web-clipper/global.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module "*.svg" {
2+
import React = require("react");
3+
export const ReactComponent: React.SFC<React.SVGProps<SVGSVGElement>>;
4+
const src: string;
5+
export default src;
6+
}

0 commit comments

Comments
 (0)