Skip to content

Commit

Permalink
Push to version 1.1
Browse files Browse the repository at this point in the history
Fixes manifest.

Comments out logs.

Fixes readme
  • Loading branch information
Sebastian committed Jun 26, 2017
1 parent 4ac97b1 commit b766ffd
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Written in pure Javascript/HTML/CSS without external dependencies (But uses Mozi

Does not send any data anywhere, as far as I know (except to pinboard, of course).

Current version: 1.0

### Download / Install
* [Mozilla Addons](https://addons.mozilla.org/en-US/firefox/addon/yet-another-pinboard-extension/)
* [Github Release](https://github.com/seeba8/yet-another-pinboard-extension/releases/latest) (Signed by AMO, can be installed in regular Firefox)
Expand All @@ -23,14 +21,15 @@ Thanks to [lostsnow](https://github.com/lostsnow/pinboard-firefox) for the cool

### Plans for the future
* Enable deleting of bookmarks
* Enable deleting the API key
* Enable force-updating the locally stored pins
* ~Enable deleting the API key~ Done!
* ~Enable force-updating the locally stored pins~ Done!
* Probably a lot of bugfixes
* Add field for the longer link description
* Add private / public flag
* ~Adapt it for Google Chrome, maybe?~ Done!
* Re-add page action button for Firefox, maybe? (Chrome [doesn't support](https://developer.chrome.com/extensions/manifest) using both Browser and Page Action)
* Keyboard shortcut to open the popup?
* Cache saved pins locally in case connection does not work
* ...

### Changelog (incomplete)
Expand Down
39 changes: 27 additions & 12 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function handleAddonInstalled() {
"lastsync": "",
"lastupdate": ""
});
return options;
}
// Update the pins on startup of the browser
function handleStartup() {
Expand All @@ -61,9 +62,11 @@ function handleStartup() {
function loadOptions() {
browser.storage.local.get("options").then((res) => {
if(!res.options) {
handleAddonInstalled();
options = handleAddonInstalled();
}
else {
options = res.options;
}
options = res.options;
if (!!options.changeActionbarIcon) {
browser.browserAction.setIcon({
path: {
Expand Down Expand Up @@ -119,27 +122,32 @@ function updatePinData(forceUpdate) {
let headers = new Headers({ "Accept": "application/json" });
let init = { method: 'GET', headers };
browser.storage.local.get(["lastupdate", "lastsync", "pins"]).then((token) => {
if (apikey == "" || (!!token.lastsync && new Date(token.lastsync) > Date.now() - 1000 * 60 * 5)) {
if (apikey == "" || (!forceUpdate && !!token.lastsync && new Date(token.lastsync) > Date.now() - 1000 * 60 * 5)) {
//console.log("Not syncing, either no API key or last sync less than 5 minutes ago.");
updatePinVariable();
return;
}
let lastUpdate = "";
let request = new Request("https://api.pinboard.in/v1/posts/update?auth_token=" + apikey + "&format=json", init);
fetch(request)
.then((response) => { return response.json(); })
.then((response) => {
if(response.status == 200 && response.ok) {
return response.json();
}
else {
return null;
}
})
.then((json) => {
lastUpdate = Date(json.update_time);
//console.log(lastUpdate);
if (!lastUpdate) {
if(json == null){
//console.log("firstException");
setTimeout(updatePinData, nextErrorTimeout, false);
nextErrorTimeout *= 2;
return;
}
else {
nextErrorTimeout = MIN_ERR_TIMEOUT;
}
nextErrorTimeout = MIN_ERR_TIMEOUT;
lastUpdate = Date(json.update_time);
//console.log(lastUpdate);
//pins.length, because we are in the token, where the pins are stored as Array, not Map
if (!forceUpdate && !!token.pins && token.pins.length > 0 && !!token.lastupdate && new Date(token.lastupdate) == lastUpdate) {
//console.log("Not syncing, no update available");
Expand Down Expand Up @@ -237,11 +245,18 @@ function handleMessage(request, sender, sendResponse) {
});
}
else if (request.callFunction == "saveBookmark") {
sendResponse(saveBookmark(request.pin, request.isNewPin));
if(typeof sendResponse == "function") {
sendResponse(saveBookmark(request.pin, request.isNewPin));
}
else {
saveBookmark(request.pin, request.isNewPin);
}
}
else if (request.callFunction == "forceUpdatePins") {
updatePinData(true);
sendResponse("OK");
if(typeof sendResponse == "function") {
sendResponse("OK");
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"name": "Yet Another Pinboard Extension",
"description" : "To use omnibox search, type 'pin ' plus a search term into the url bar.",
"homepage_url": "https://github.com/seeba8/yet-another-pinboard-extension",
"author": {
"name": "seeba8",
"url": "https://github.com/seeba8/"
},
"author": "seeba8",
"version": "1.1.0",
"background": {
"scripts": [
Expand Down
3 changes: 2 additions & 1 deletion options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ browser.storage.local.get(["options", "apikey"]).then((token) => {
});

function forcePinReload() {
browser.runtime.sendMessage({"callFunction": "forceUpdatePins"}).then((response) => {});;
//console.log("forcereload");
browser.runtime.sendMessage({"callFunction": "forceUpdatePins"}).then((response) => {return;});
}

function toggleAPIKeyInputs() {
Expand Down
1 change: 1 addition & 0 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function handleSubmit(e) {
if (pin === undefined) {
pin = Object();
pin.href = document.getElementById("url").value;
newPin = true;
}
pin.description = document.getElementById("description").value;
pin.time = new Date().toISOString();
Expand Down
2 changes: 1 addition & 1 deletion webextension-polyfill/browser-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b766ffd

Please sign in to comment.