Compare commits

..

No commits in common. "master" and "0.0.2.2" have entirely different histories.

16 changed files with 297 additions and 6558 deletions

127
README.md
View File

@ -1,67 +1,28 @@
# ReadLater WebExtension ![language](https://img.shields.io/badge/language-webextension-blue.svg)
<div align="center">
<h1>
Extension Boilerplate
</h1>
> ReadLaterByEmail webextension generator
<p>
<strong>A foundation for creating browser extensions for Chrome, Opera & Firefox.</strong>
</p>
</div>
## :books: Table of Contents
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.
- [Installation](#package-installation)
- [Usage](#rocket-usage)
- [Features](#sparkles-features)
- [Support](#hammer_and_wrench-support)
- [Contributing](#memo-contributing)
- [License](#scroll-license)
<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>
## :package: Installation
I have extracted this from the browser extensions that I built for my side-project, [Email This](https://www.emailthis.me).
### First check if you have composer installed
> 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).
Before installing this, you need to check if you have `NPM` installed on your computer.
### 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
## Features
<dl>
<dt>Write once and deploy to Chrome, Opera & Firefox</dt>
@ -106,20 +67,56 @@ Update <https://addons.opera.com/developer/package/250537/?tab=versions>
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.
## :memo: Contributing
## Installation
1. Clone the repository `git clone https://github.com/EmailThis/extension-boilerplate.git`
2. Run `npm install`
3. Run `npm run build`
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).
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)
## :scroll: License
[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 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`)
Based on [Email This](https://www.emailthis.me) which is licensed under the MIT license.
##### 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)

View File

@ -1,6 +1,6 @@
{
"name": "Read Later by Email",
"version": "0.0.3",
"name": "Shikiryu Read Later",
"version": "0.0.2.1",
"manifest_version": 2,
"description": "__MSG_extensionDescription__",
"icons": {
@ -9,16 +9,26 @@
},
"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
}
@ -29,12 +39,12 @@
"32": "icons/favicon-32x32.png",
"96": "icons/favicon-96x96.png"
},
"default_title": "Read Later by Email",
"default_title": "Shikiryu Bookmarklet",
"default_popup": "popup.html"
},
"applications": {
"gecko": {
"id": "bookmarklet@shikiryu.com"
"id": "bookmarklet@shikiryu.com"
}
}
}

View File

@ -47,16 +47,8 @@
"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"
}
}
}

View File

@ -1,27 +0,0 @@
#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": "Read Later by Email",
"message": "Shikiryu Read Later",
"description": "The name of the extension."
},
"extensionDescription": {
@ -23,10 +23,6 @@
"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."
@ -35,10 +31,6 @@
"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"
@ -54,9 +46,5 @@
"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": "Read Later by Email",
"message": "Shikiryu Read Later",
"description": "The name of the extension."
},
"extensionDescription": {
@ -23,22 +23,14 @@
"message": "Jeton :",
"description": "Token label"
},
"optionsExtract": {
"message": "Envoyer le contenu de la page dans le mail:",
"description": "Extract label"
},
"URLChanged": {
"message": "URL enregistrée !",
"message": "URL changed!",
"description": "Message when URL is changed."
},
"tokenSaved": {
"message": "Jeton enregistré !",
"message": "Token saved!",
"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"
@ -54,9 +46,5 @@
"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,63 +1,57 @@
<!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">
<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">
<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 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>
</div>
</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>
</div>
</div>
<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>
</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">ReadLaterByEmail</a>
</p>
</div>
</div>
</footer>
<script src="scripts/options.js"></script>
</body>
</footer>
<script src="scripts/options.js"></script>
</body>
</html>

View File

@ -1,44 +1,27 @@
<!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 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>
<div id="display-container"></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">ReadLaterByEmail</a>
&copy; <a href="https://readlater.shikiryu.com">Shikiryu</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,50 +1,44 @@
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)
};
if (data.extract) {
params["e"] = true;
}
var queryString = Object.keys(params)
.map(key => {
return key + "=" + params[key];
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)
})
.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
});
}
.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,40 +16,34 @@ 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,22 +1,20 @@
"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,45 +3,30 @@ 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("extract", function(resp) {
extractInput.value = resp.extract;
storage.get('token', function(resp) {
tokenInput.value = resp.token;
});
urlInput.addEventListener("blur", function(e) {
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");
});
var value = this.value;
storage.set({ url: value }, function() {
message.innerHTML = ext.i18n.getMessage("URLChanged");
});
});
tokenInput.addEventListener("blur", function(e) {
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");
});
var value = this.value;
storage.set({ token: value }, function() {
message.innerHTML = ext.i18n.getMessage("tokenSaved");
});
});
document.querySelectorAll("[data-message]").forEach(function(elt) {
elt.textContent = ext.i18n.getMessage(elt.dataset.message);
elt.innerHTML = ext.i18n.getMessage(elt.dataset.message);
});

View File

@ -2,83 +2,80 @@ 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("extract", function(resp) {
var extract = resp.extract;
if (extract) {
document.getElementById("save-content").checked = extract
? "checked"
: false;
storage.get('color', function(resp) {
var color = resp.color;
if(color) {
popup.style.backgroundColor = color
}
});
var renderMessage = message => {
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 displayContainer = document.getElementById("display-container");
displayContainer.textContent = message;
displayContainer.innerHTML = `<p class='message'>${message}</p>`;
};
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);
var renderBookmark = (data) => {
var displayContainer = document.getElementById("display-container");
if(data) {
page_data = data;
displayContainer.innerHTML = template(data);
} 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];
ext.tabs.sendMessage(
activeTab.id,
{ action: "process-page" },
renderBookmark
);
chrome.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;
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 + ")");
}
}
);
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+")");
}
});
}
});
var dataMessages = document.querySelectorAll("[data-message]");
[].forEach.call(dataMessages, function(elt) {
elt.textContent = ext.i18n.getMessage(elt.dataset.message);
console.log(elt.dataset.message);
elt.innerHTML = 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,66 +1,68 @@
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

File diff suppressed because it is too large Load Diff