Skip to content

Commit

Permalink
Add build infra
Browse files Browse the repository at this point in the history
* add package.json for project
* install Dexie as a dependency
* bundle background and content-script with rollup
* add commands to bundle, start, watch to ease development
* separate whotracksme data into a separate JSON file
  • Loading branch information
remusao committed Jun 20, 2019
1 parent cb1c31e commit 5185b39
Show file tree
Hide file tree
Showing 11 changed files with 14,428 additions and 4,498 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.{es,js,jsm,jsx,ts}]
[*.js]
indent_style = tab
indent_size = 1
tab_width = 2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
background.bundle.js
content-script.bundle.js
28 changes: 16 additions & 12 deletions background.js

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions database.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Dexie from 'dexie';

// Wrapper using Dexie.js to use IndexedDB.
const updateTime = 1 * 60 * 1000;

Expand Down Expand Up @@ -54,31 +56,31 @@ function load(obj, key) {
});
}

function saveInDB(ref, tp) {
export function saveInDB(ref, tp) {
db.reftp.add({ ref: ref, tp: tp });
}

function saveHTML(ref, html) {
export function saveHTML(ref, html) {
db.refhtml.add({ ref: ref, html: html });
}

function savetpList(tpurl) {
export function savetpList(tpurl) {
db.tpurl.add({ tpurl: tpurl });
}

function saveInputFields(value, sender, details) {
export function saveInputFields(value, sender, details) {
db.inputFields.add({ value: value, sender: sender, details: details });
}

function saveInputFieldsCache(value, summary) {
export function saveInputFieldsCache(value, summary) {
db.inputFieldsCache.add({ value: value, summary: summary });
}

function savetpURLFP(tpurl, details) {
export function savetpURLFP(tpurl, details) {
db.tpURLFP.add({ tpurl: tpurl, details: details });
}

function saveCookies(url, details) {
export function saveCookies(url, details) {
dbCookie.cookietable.add({ url: url, details: details });
}

Expand Down Expand Up @@ -139,11 +141,11 @@ function cleanCookieDB() {
});
}

function cleanStorage() {
export function cleanStorage() {

// Clean databases and then re-load the extension.

Promise.all([cleanLSDB(), cleanCookieDB()]).then(status => {
chrome.runtime.reload();
}).catch(console.log);
}
}
7 changes: 7 additions & 0 deletions globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const _chrome = chrome;
const _browser = typeof browser !== 'undefined' ? browser : _chrome;

export {
_browser as browser,
_chrome as chrome,
};
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
},
"permissions": [ "http://*/*", "https://*/*","tabs", "activeTab", "webRequest", "webRequestBlocking","unlimitedStorage", "webNavigation", "<all_urls>"],
"background": {
"scripts": ["static/js/dexie.js", "database.js", "background.js"]
"scripts": ["background.bundle.js"]
},
"content_scripts": [{
"matches" : ["http://*/*", "https://*/*"],
"match_about_blank": true,
"js": ["scripts/content-script.js"],
"js": ["content-script.bundle.js"],
"all_frames": true,
"run_at": "document_end"
}],
Expand Down
Loading

0 comments on commit 5185b39

Please sign in to comment.