Compare commits

...

11 Commits

Author SHA1 Message Date
856a715130 ✏️ Add Opera doc
For #8
2020-07-21 10:06:10 +02:00
b8717bd08f ✏️ Rename the project
For #6
2020-07-21 09:54:09 +02:00
a0af8e31a5 πŸ› Delete trailing slash
Fix #10
2020-07-21 09:53:32 +02:00
78680fac49 πŸ“ Add the privacy policy draft
Fix #7
2020-07-07 14:54:24 +02:00
bedb5a22b6 🚚 Rename the project
For #6
2020-07-07 11:35:17 +02:00
b571af29c5 πŸ”– Update manifest.json for plugin update on stores 2020-07-03 17:32:17 +02:00
c5cadb1557 πŸ“ Rerender the readme file with instructions
For firefox in #8
2020-07-03 17:30:43 +02:00
45cf59be52 Merge pull request '✨ Allows to add the page content into the email, server-side' (#5) from feature/extract/1 into master
Fix #4

Reviewed-on: #5
2020-07-02 16:58:52 +02:00
19aa864579 ✨ Allows to add the page content into the email, server-side
Fix #4
2020-07-02 16:55:40 +02:00
8723154371 🚨 Add prettier
Fix #2
2019-05-06 17:01:54 +02:00
25fe0c5849 πŸ‘Œ Remove all innerHTML 2018-12-12 08:06:04 +01:00
16 changed files with 6554 additions and 293 deletions

127
README.md
View File

@ -1,28 +1,67 @@
<div align="center">
<h1>
Extension Boilerplate
</h1>
# ReadLater WebExtension ![language](https://img.shields.io/badge/language-webextension-blue.svg)
<p>
<strong>A foundation for creating browser extensions for Chrome, Opera & Firefox.</strong>
</p>
</div>
> ReadLaterByEmail webextension generator
Now that Firefox supports WebExtensions, it has become a lot easier to build browser extensions/addons for multiple browsers without duplicating the codebase. This project serves as a sensible starting point to help you get started.
## :books: Table of Contents
<div align="center">
<a href="https://www.emailthis.me/open-source/extension-boilerplate">
<img src="./resources/chrome-promo/large.png" alt="Extension Boilerplate">
</a>
</div>
- [Installation](#package-installation)
- [Usage](#rocket-usage)
- [Features](#sparkles-features)
- [Support](#hammer_and_wrench-support)
- [Contributing](#memo-contributing)
- [License](#scroll-license)
I have extracted this from the browser extensions that I built for my side-project, [Email This](https://www.emailthis.me).
## :package: Installation
> Side note: Do check out [**Email This**](https://www.emailthis.me). It is a simpler alternative to bookmarking tools like Pocket, Readability & Instapaper. Email This will remove ads & distractions from an article and send you a nice email with just the text/images. No need to install any additional applications or login to another app just to access your bookmarks.
The Chrome Extensions is available [on the Chrome Web Store](https://chrome.google.com/webstore/detail/email-this/lgblkllcjgihfnlefhnnpppndbbjallh).
### First check if you have composer installed
Before installing this, you need to check if you have `NPM` installed on your computer.
## Features
### Then install this script
```sh
git clone ssh://gogs@git.shikiryu.com:2200/ReadLaterByEmail/webextensions.git
cd webextensions
npm install
npm run build
```
## :rocket: Usage
### Load the extension in Chrome & Opera
1. Open Chrome/Opera browser and navigate to chrome://extensions
2. Select "Developer Mode" and then click "Load unpacked extension..."
3. From the file browser, choose to `extension-boilerplate/build/chrome` or (`extension-boilerplate/build/opera`)
### Load the extension in Firefox
1. Open Firefox browser and navigate to about:debugging
2. Click "Load Temporary Add-on" and from the file browser, choose `extension-boilerplate/build/firefox`
### Developing
The following tasks can be used when you want to start developing the extension and want to enable live reload -
- `npm run chrome-watch`
- `npm run opera-watch`
- `npm run firefox-watch`
### Packaging
Run `npm run dist` to create a zipped, production-ready extension for each browser. You can then upload that to the appstore.
#### Firefox
Run `npm run sourcezip` for firefox submission
Update <https://addons.mozilla.org/fr/developers/addon/shikiryu-readlater/versions/submit/>
#### Opera
Update <https://addons.opera.com/developer/package/250537/?tab=versions>
## :sparkles: Features
<dl>
<dt>Write once and deploy to Chrome, Opera & Firefox</dt>
@ -67,56 +106,20 @@ The Chrome Extensions is available [on the Chrome Web Store](https://chrome.goog
You might need to specify different data variables based on your environment. For example, you might want to use a localhost API endpoint during development and a production API endpoint once the extension is submitted to the appstore. You can specify such data in the json files inside `config` directory.
You can also set custom data variables based on the platform (different variable for Chrome, FF, Opera).
</dd>
</dl>
## :hammer_and_wrench: Support
Please [open an issue](https://git.shikiryu.com/ReadLaterByEmail/webextensions/issues/new) for support.
## Installation
1. Clone the repository `git clone https://github.com/EmailThis/extension-boilerplate.git`
2. Run `npm install`
3. Run `npm run build`
## :memo: Contributing
Alternately, if you want to try out the sample extension, here are the download links. After you download it, unzip the file and load it in your browser using the steps mentioned below.
- [**Download Chrome Extension**](https://github.com/EmailThis/extension-boilerplate/releases/download/v1.0/chrome.zip)
- [**Download Opera Extension**](https://github.com/EmailThis/extension-boilerplate/releases/download/v1.0/opera.zip)
- [**Download Firefox Extension**](https://github.com/EmailThis/extension-boilerplate/releases/download/v1.0/firefox.zip)
Please contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://git.shikiryu.com/ReadLaterByEmail/webextensions/compare/master...master).
## :scroll: License
##### Load the extension in Chrome & Opera
1. Open Chrome/Opera browser and navigate to chrome://extensions
2. Select "Developer Mode" and then click "Load unpacked extension..."
3. From the file browser, choose to `extension-boilerplate/build/chrome` or (`extension-boilerplate/build/opera`)
[Creative Commons Attribution NonCommercial (CC-BY-NC)](<https://tldrlegal.com/license/creative-commons-attribution-noncommercial-(cc-nc)>) Β© [Chouchen](https://github.com/Chouchen/)
##### Load the extension in Firefox
1. Open Firefox browser and navigate to about:debugging
2. Click "Load Temporary Add-on" and from the file browser, choose `extension-boilerplate/build/firefox`
## Developing
The following tasks can be used when you want to start developing the extension and want to enable live reload -
- `npm run chrome-watch`
- `npm run opera-watch`
- `npm run firefox-watch`
## Packaging
Run `npm run dist` to create a zipped, production-ready extension for each browser. You can then upload that to the appstore.
## TODO
- [ ] Add support for Safari
- [x] Add Firefox & Opera Promo images
- [x] Add sample screenshot templates
- [ ] Write a guide for using config variables & JS preprocessor
-----------
This project is licensed under the MIT license.
If you have any questions or comments, please create a new issue. I'd be happy to hear your thoughts.
Bharani, [Email This](https://www.emailthis.me)
Based on [Email This](https://www.emailthis.me) which is licensed under the MIT license.

View File

@ -1,6 +1,6 @@
{
"name": "Shikiryu Read Later",
"version": "0.0.2.1",
"name": "Read Later by Email",
"version": "0.0.3",
"manifest_version": 2,
"description": "__MSG_extensionDescription__",
"icons": {
@ -9,26 +9,16 @@
},
"default_locale": "en",
"background": {
"scripts": [
"scripts/background.js"
]
"scripts": ["scripts/background.js"]
},
"permissions": [
"activeTab",
"storage"
],
"permissions": ["activeTab", "storage"],
"options_ui": {
"page": "options.html"
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"scripts/contentscript.js"
],
"matches": ["http://*/*", "https://*/*"],
"js": ["scripts/contentscript.js"],
"run_at": "document_end",
"all_frames": false
}
@ -39,12 +29,12 @@
"32": "icons/favicon-32x32.png",
"96": "icons/favicon-96x96.png"
},
"default_title": "Shikiryu Bookmarklet",
"default_title": "Read Later by Email",
"default_popup": "popup.html"
},
"applications": {
"gecko": {
"id": "bookmarklet@shikiryu.com"
"id": "bookmarklet@shikiryu.com"
}
}
}

View File

@ -47,8 +47,16 @@
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.5.4",
"gulp-zip": "^2.0.3",
"husky": "^2.2.0",
"preprocessify": "^1.0.1",
"prettier": "^1.17.0",
"pretty-quick": "^1.10.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
}

27
privacy_policy.md Executable file
View File

@ -0,0 +1,27 @@
#English
This extension collect the instance URL you'll be sending your page to and the token used to identify yourself on this instance.
This will be saved on your browser local storage.
The following elements are sent to the instance:
- title
- description
- image
They are automatically generated with the current tab content. With your current token, you can also send a comment which will reach the instance.
---
# French
Cette extension collecte l'URL de l'instance vers laquelle vous allez envoyer les informations and le jeton vous permettant de vous identifier sur cette instance.
Ces deux donnΓ©es sont enregistrΓ©es localement dans le local storage de votre navigateur.
Les Γ©lΓ©ments suivant seront envoyΓ©s Γ  l'instance :
- titre
- description
- image
Ils seront gΓ©nΓ©rΓ©s automatiquement Γ  partir des mΓͺmes informations utilisΓ©es sur l'onglet actuellement ouvert.
Avec votre jeton en cours, vous pourrez aussi envoyer un commentaire de cet onglet vers l'instance.

View File

@ -1,6 +1,6 @@
{
"extensionName": {
"message": "Shikiryu Read Later",
"message": "Read Later by Email",
"description": "The name of the extension."
},
"extensionDescription": {
@ -23,6 +23,10 @@
"message": "Token:",
"description": "Token label"
},
"optionsExtract": {
"message": "Send page content into the email:",
"description": "Extract label"
},
"URLChanged": {
"message": "URL changed!",
"description": "Message when URL is changed."
@ -31,6 +35,10 @@
"message": "Token saved!",
"description": "Message when token is changed."
},
"optionSaved": {
"message": "Option saved!",
"description": "Message when option is changed."
},
"cantExtractTitle": {
"message": "Sorry, could not extract this page's title and URL",
"description": "Message when we could not extract the page's title and URL"
@ -46,5 +54,9 @@
"defaultURL": {
"message": "https://app.readlater.shikiryu.com",
"description": "Default URL"
},
"excerpt": {
"message": "Add content",
"description": "Option to add the webpage content into the email"
}
}

View File

@ -1,6 +1,6 @@
{
"extensionName": {
"message": "Shikiryu Read Later",
"message": "Read Later by Email",
"description": "The name of the extension."
},
"extensionDescription": {
@ -23,14 +23,22 @@
"message": "Jeton :",
"description": "Token label"
},
"optionsExtract": {
"message": "Envoyer le contenu de la page dans le mail:",
"description": "Extract label"
},
"URLChanged": {
"message": "URL changed!",
"message": "URL enregistrΓ©e !",
"description": "Message when URL is changed."
},
"tokenSaved": {
"message": "Token saved!",
"message": "Jeton enregistrΓ© !",
"description": "Message when token is changed."
},
"optionSaved": {
"message": "Option enregistrΓ©e !",
"description": "Message when option is changed."
},
"cantExtractTitle": {
"message": "Sorry, could not extract this page's title and URL",
"description": "Message when we could not extract the page's title and URL"
@ -46,5 +54,9 @@
"defaultURL": {
"message": "https://app.readlater.shikiryu.com",
"description": "Default URL"
},
"excerpt": {
"message": "Ajouter le contenu",
"description": "Option to add the webpage content into the email"
}
}

View File

@ -1,57 +1,63 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="styles/options.css" rel="stylesheet">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title data-message="optionsAndSettings"></title>
</head>
<body class="wrap">
<div class="grid">
<div class="unit whole center-on-mobiles">
<div class="heading">
<h1 data-message="extensionName"></h1>
<p class="lead" data-message="optionsPageSubtitle"></p>
</div>
</div>
</div>
<section>
<div class="grid">
<div class="unit whole center-on-mobiles">
<div id="msg"></div>
</div>
</div>
</section>
<section class="content">
<head>
<meta charset="utf-8" />
<link href="styles/options.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title data-message="optionsAndSettings"></title>
</head>
<body class="wrap">
<div class="grid">
<div class="unit whole center-on-mobiles">
<div class="option">
<h5 data-message="optionsURL"></h5>
<input type="text" name="url" value="https://app.readlater.shikiryu.com" />
<div class="heading">
<h1 data-message="extensionName"></h1>
<p class="lead" data-message="optionsPageSubtitle"></p>
</div>
</div>
</div>
<div class="option">
<section>
<div class="grid">
<div class="unit whole center-on-mobiles">
<div id="msg"></div>
</div>
</div>
</section>
<section class="content">
<div class="grid">
<div class="unit whole center-on-mobiles">
<div class="option">
<h5 data-message="optionsURL"></h5>
<input
type="text"
name="url"
value="https://app.readlater.shikiryu.com"
/>
</div>
<div class="option">
<h5 data-message="optionsToken"></h5>
<input type="text" name="token" value="" />
</div>
<div class="option">
<h5 data-message="optionsExtract"></h5>
<input type="checkbox" name="extract" value="1" />
</div>
</div>
</div>
</div>
</section>
</section>
<footer class="main-footer">
<div class="grid">
<div class="unit whole center-on-mobiles">
<p class="text-center text-muted">
&copy; <a href="https://readlater.shikiryu.com">Shikiryu</a>
</p>
<footer class="main-footer">
<div class="grid">
<div class="unit whole center-on-mobiles">
<p class="text-center text-muted">
&copy; <a href="https://readlater.shikiryu.com">ReadLaterByEmail</a>
</p>
</div>
</div>
</div>
</footer>
<script src="scripts/options.js"></script>
</body>
</footer>
<script src="scripts/options.js"></script>
</body>
</html>

View File

@ -1,27 +1,44 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="styles/popup.css" rel="stylesheet">
<meta charset="utf-8" />
<link href="styles/popup.css" rel="stylesheet" />
</head>
<body>
<div id="app" class="popup-content">
<h1 data-message="extensionName"></h1>
<div id="display-container"></div>
<div id="display-container">
<div class="site-description">
<h3 class="title" data-template="title"></h3>
<p class="description" data-template="description"></p>
<p class="image" data-template="image"></p>
<div>
<label for="comment">Comment:</label>
<textarea id="comment" name="comment"></textarea>
</div>
<a href="" target="_blank" class="url" data-template="url"></a>
</div>
<div class="action-container">
<label for="save-content" data-message="excerpt"></label>
<input type="checkbox" id="save-content" name="save-content" />
<button id="save-btn" class="btn btn-primary">Save</button>
</div>
</div>
<footer class="main-footer">
<div class="grid">
<div class="unit whole center-on-mobiles">
<p class="text-center text-muted">
&copy; <a href="https://readlater.shikiryu.com">Shikiryu</a>
&copy;
<a href="https://readlater.shikiryu.com">ReadLaterByEmail</a>
</p>
<p class="js-options" data-message="optionsAndSettings"></p>
</div>
</div>
</footer>
</div>
<script src="scripts/popup.js"></script>
</body>
</html>

View File

@ -1,44 +1,50 @@
import ext from "./utils/ext";
import storage from "./utils/storage";
ext.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if(request.action === "perform-save") {
var data = request.data;
var url;
var token;
storage.get(['url', 'token'], function(resp) {
url = resp.url;
token = resp.token;
var params = {
v: 1,
u: encodeURIComponent(data.url),
t: encodeURIComponent(data.title),
d: encodeURIComponent(data.description),
api_token: encodeURIComponent(token),
i: encodeURIComponent(data.image),
c: encodeURIComponent(data.comment),
};
var queryString = Object.keys(params).map((key) => {
return key + '=' + params[key];
}).join('&');
fetch(url + "/api/links", {
method: 'POST',
headers: {
'Accept': 'application/json'
},
body: new URLSearchParams(queryString)
ext.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.action === "perform-save") {
var data = request.data;
var url;
var token;
storage.get(["url", "token"], function(resp) {
url = resp.url;
token = resp.token;
var params = {
v: 1,
u: encodeURIComponent(data.url),
t: encodeURIComponent(data.title),
d: encodeURIComponent(data.description),
api_token: encodeURIComponent(token),
i: encodeURIComponent(data.image),
c: encodeURIComponent(data.comment)
};
if (data.extract) {
params["e"] = true;
}
var queryString = Object.keys(params)
.map(key => {
return key + "=" + params[key];
})
.then(function(response) {
if (200 === response.status) {
sendResponse({action: "saved"});
} else {
sendResponse({action: "error", status: response.status, error: response.statusText});
}
});
.join("&");
fetch(url + "/api/links", {
method: "POST",
headers: {
Accept: "application/json"
},
body: new URLSearchParams(queryString)
}).then(function(response) {
if (200 === response.status) {
sendResponse({ action: "saved" });
} else {
sendResponse({
action: "error",
status: response.status,
error: response.statusText
});
}
});
});
return true; // https://stackoverflow.com/a/20077854
}
return true; // https://stackoverflow.com/a/20077854
}
);
});

View File

@ -16,34 +16,40 @@ var extractTags = () => {
};
var ogTitle = document.querySelector("meta[property='og:title']");
if(ogTitle) {
if (ogTitle) {
data.title = ogTitle.getAttribute("content");
} else {
data.title = document.title;
}
var descriptionTag = document.querySelector("meta[property='og:description']") || document.querySelector("meta[name='description']");
if(descriptionTag) {
data.description = descriptionTag.getAttribute("content")
var descriptionTag =
document.querySelector("meta[property='og:description']") ||
document.querySelector("meta[name='description']");
if (descriptionTag) {
data.description = descriptionTag.getAttribute("content");
}
var imgTag = document.querySelector("meta[property='og:image']") || document.querySelector("meta[property='twitter-image']");
if(imgTag) {
data.image = imgTag.getAttribute("content")
} else {
imgTag = document.querySelector("link[rel=icon]") || document.querySelector("link[rel=apple-touch-icon]");
if (imgTag) {
data.image = imgTag.getAttribute("href");
}
var imgTag =
document.querySelector("meta[property='og:image']") ||
document.querySelector("meta[property='twitter-image']");
if (imgTag) {
data.image = imgTag.getAttribute("content");
} else {
imgTag =
document.querySelector("link[rel=icon]") ||
document.querySelector("link[rel=apple-touch-icon]");
if (imgTag) {
data.image = imgTag.getAttribute("href");
}
}
return data;
};
function onRequest(request, sender, sendResponse) {
if (request.action === 'process-page') {
sendResponse(extractTags())
if (request.action === "process-page") {
sendResponse(extractTags());
}
}
ext.runtime.onMessage.addListener(onRequest);
ext.runtime.onMessage.addListener(onRequest);

View File

@ -1,20 +1,22 @@
'use strict';
"use strict";
import ext from "./utils/ext";
var LIVERELOAD_HOST = 'localhost:';
var LIVERELOAD_HOST = "localhost:";
var LIVERELOAD_PORT = 35729;
var connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload');
var connection = new WebSocket(
"ws://" + LIVERELOAD_HOST + LIVERELOAD_PORT + "/livereload"
);
connection.onerror = function (error) {
console.log('reload connection got error:', error);
connection.onerror = function(error) {
console.log("reload connection got error:", error);
};
connection.onmessage = function (e) {
connection.onmessage = function(e) {
if (e.data) {
var data = JSON.parse(e.data);
if (data && data.command === 'reload') {
if (data && data.command === "reload") {
ext.runtime.reload();
}
}
};
};

View File

@ -3,30 +3,45 @@ import storage from "./utils/storage";
var urlInput = document.querySelector("[name=url]");
var tokenInput = document.querySelector("[name=token]");
var extractInput = document.querySelector("[name=extract]");
var message = document.getElementById("msg");
storage.get('url', function(resp) {
urlInput.value = resp.url || "https://app.readlater.shikiryu.com";
storage.get("url", function(resp) {
urlInput.value = resp.url || "https://app.readlater.shikiryu.com";
});
storage.get('token', function(resp) {
tokenInput.value = resp.token;
storage.get("token", function(resp) {
tokenInput.value = resp.token;
});
storage.get("extract", function(resp) {
extractInput.value = resp.extract;
});
urlInput.addEventListener("blur", function(e) {
var value = this.value;
storage.set({ url: value }, function() {
message.innerHTML = ext.i18n.getMessage("URLChanged");
});
if (this.value.endsWith("/")) {
this.value = this.value.substring(0, this.value.length - 1);
}
var value = this.value;
storage.set({ url: value }, function() {
message.textContent = ext.i18n.getMessage("URLChanged");
});
});
tokenInput.addEventListener("blur", function(e) {
var value = this.value;
storage.set({ token: value }, function() {
message.innerHTML = ext.i18n.getMessage("tokenSaved");
});
var value = this.value;
storage.set({ token: value }, function() {
message.textContent = ext.i18n.getMessage("tokenSaved");
});
});
extractInput.addEventListener("change", function(e) {
var value = this.value;
storage.set({ extract: value }, function() {
message.textContent = ext.i18n.getMessage("optionSaved");
});
});
document.querySelectorAll("[data-message]").forEach(function(elt) {
elt.innerHTML = ext.i18n.getMessage(elt.dataset.message);
elt.textContent = ext.i18n.getMessage(elt.dataset.message);
});

View File

@ -2,80 +2,83 @@ import ext from "./utils/ext";
import storage from "./utils/storage";
var page_data = {
title: "",
description: "",
image: "",
comment: "",
url: document.location.href
title: "",
description: "",
image: "",
comment: "",
url: document.location.href
};
var popup = document.getElementById("app");
storage.get('color', function(resp) {
var color = resp.color;
if(color) {
popup.style.backgroundColor = color
storage.get("extract", function(resp) {
var extract = resp.extract;
if (extract) {
document.getElementById("save-content").checked = extract
? "checked"
: false;
}
});
var template = (data) => {
return (`
<div class="site-description">
<h3 class="title">${data.title}</h3>
<p class="description">${data.description}</p>
<p class="image"><img src="${data.image}"></p>
<div>
<label for="comment">Comment:</label>
<textarea id="comment" name="comment"></textarea>
</div>
<a href="${data.url}" target="_blank" class="url">${data.url}</a>
</div>
<div class="action-container">
<button id="save-btn" class="btn btn-primary">Save</button>
</div>
`);
};
var renderMessage = (message) => {
var renderMessage = message => {
var displayContainer = document.getElementById("display-container");
displayContainer.innerHTML = `<p class='message'>${message}</p>`;
displayContainer.textContent = message;
};
var renderBookmark = (data) => {
var displayContainer = document.getElementById("display-container");
if(data) {
page_data = data;
displayContainer.innerHTML = template(data);
var renderBookmark = data => {
if (data) {
page_data = data;
document.querySelector("[data-template=title]").textContent =
page_data.title;
document.querySelector("[data-template=description]").textContent =
page_data.description;
if ("" !== img) {
var img = document.createElement("image");
img.src = page_data.image;
document.querySelector("[data-template=image]").appendChild(img);
}
document.querySelector("[data-template=url]").textContent = page_data.url;
document
.querySelector("[data-template=url]")
.setAttribute("href", page_data.url);
} else {
renderMessage(ext.i18n.getMessage("cantExtractTitle"));
}
};
ext.tabs.query({active: true, currentWindow: true}, function(tabs) {
ext.tabs.query({ active: true, currentWindow: true }, function(tabs) {
var activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, { action: 'process-page' }, renderBookmark);
ext.tabs.sendMessage(
activeTab.id,
{ action: "process-page" },
renderBookmark
);
});
popup.addEventListener("click", function(e) {
if(e.target && e.target.matches("#save-btn")) {
e.preventDefault();
page_data.comment = document.getElementById("comment").value;
ext.runtime.sendMessage({action: "perform-save", data: page_data}, function (response) {
if (response && response.action === "saved") {
renderMessage(ext.i18n.getMessage("savedSuccessfully"));
} else {
renderMessage(response.error + " ("+response.status+")");
}
});
if (e.target && e.target.matches("#save-btn")) {
e.preventDefault();
page_data.comment = document.getElementById("comment").value;
page_data.extract = document.getElementById("save-content").checked;
ext.runtime.sendMessage(
{ action: "perform-save", data: page_data },
function(response) {
if (response && response.action === "saved") {
renderMessage(ext.i18n.getMessage("savedSuccessfully"));
} else {
renderMessage(response.error + " (" + response.status + ")");
}
}
);
}
});
var dataMessages = document.querySelectorAll("[data-message]");
[].forEach.call(dataMessages, function(elt) {
console.log(elt.dataset.message);
elt.innerHTML = ext.i18n.getMessage(elt.dataset.message);
elt.textContent = ext.i18n.getMessage(elt.dataset.message);
});
var optionsLink = document.querySelector(".js-options");
optionsLink.addEventListener("click", function(e) {
e.preventDefault();
ext.tabs.create({'url': ext.extension.getURL('options.html')});
ext.tabs.create({ url: ext.extension.getURL("options.html") });
});

View File

@ -1,68 +1,66 @@
const apis = [
'alarms',
'bookmarks',
'browserAction',
'commands',
'contextMenus',
'cookies',
'downloads',
'events',
'extension',
'extensionTypes',
'history',
'i18n',
'idle',
'notifications',
'pageAction',
'runtime',
'storage',
'tabs',
'webNavigation',
'webRequest',
'windows',
]
"alarms",
"bookmarks",
"browserAction",
"commands",
"contextMenus",
"cookies",
"downloads",
"events",
"extension",
"extensionTypes",
"history",
"i18n",
"idle",
"notifications",
"pageAction",
"runtime",
"storage",
"tabs",
"webNavigation",
"webRequest",
"windows"
];
function Extension () {
const _this = this
function Extension() {
const _this = this;
apis.forEach(function (api) {
_this[api] = null
apis.forEach(function(api) {
_this[api] = null;
try {
if (chrome[api]) {
_this[api] = chrome[api]
_this[api] = chrome[api];
}
} catch (e) {}
try {
if (window[api]) {
_this[api] = window[api]
_this[api] = window[api];
}
} catch (e) {}
try {
if (browser[api]) {
_this[api] = browser[api]
_this[api] = browser[api];
}
} catch (e) {}
try {
_this.api = browser.extension[api]
_this.api = browser.extension[api];
} catch (e) {}
})
});
try {
if (browser && browser.runtime) {
this.runtime = browser.runtime
this.runtime = browser.runtime;
}
} catch (e) {}
try {
if (browser && browser.browserAction) {
this.browserAction = browser.browserAction
this.browserAction = browser.browserAction;
}
} catch (e) {}
}
module.exports = new Extension();
module.exports = new Extension();

View File

@ -1,3 +1,3 @@
import ext from "./ext";
module.exports = (ext.storage.sync ? ext.storage.sync : ext.storage.local);
module.exports = ext.storage.sync ? ext.storage.sync : ext.storage.local;

6156
yarn.lock Normal file

File diff suppressed because it is too large Load Diff