From a251acec86b14bfd4941e8103e12da1ce0931c48 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Tue, 30 Mar 2021 16:01:30 +0300 Subject: [PATCH] Some fixes --- .gitignore | 2 ++ Makefile | 6 ++++++ manifest.json | 4 ++-- options.js | 16 ++++++++-------- postify.js | 3 ++- readme.md | 15 +++++++++++++++ storage.js | 6 +++--- 7 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf9a6ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +./.idea +*.xpi diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dc325e9 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +build-xpi: + rm -f postify.xpi + zip -r -FS ./postify.xpi * \ + --exclude '*.git*' \ + --exclude '*.php' \ + --exclude '*.xpi' diff --git a/manifest.json b/manifest.json index 1eb8a9c..5804262 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Postify", - "version": "1.0", + "version": "1.0.6", "description": "Post current url to external web-server.", "icons": { "48": "icons/postify-48.png" @@ -17,7 +17,7 @@ "notifications", "storage", "webRequest", - "" + "*://localhost/*" ], "background": { "scripts": ["storage.js", "postify.js"] diff --git a/options.js b/options.js index 6d2f3a1..9dc2f7b 100644 --- a/options.js +++ b/options.js @@ -18,9 +18,9 @@ function setPatterns(patterns) { console.log('PATTERNS', patterns); - var reducer = (acc, item) => acc + PATTERN_ROW(item.server, item.pattern); + const reducer = (acc, item) => acc + PATTERN_ROW(item.server, item.pattern); - var html = patterns.reduce(reducer, ''); + const html = patterns.reduce(reducer, ''); document.querySelector(".js-pattern-rows").innerHTML = html; } @@ -35,8 +35,8 @@ function restoreOptions() { } function parseForm() { - var formData = []; - var rows = document.querySelectorAll(".js-pattern-rows tr"); + const formData = []; + const rows = document.querySelectorAll(".js-pattern-rows tr"); rows.forEach(row => { var server = row.querySelector('[name="server"]').value; var pattern = row.querySelector('[name="pattern"]').value; @@ -47,15 +47,15 @@ function parseForm() { function saveOptions(evt) { evt.preventDefault(); - var formData = parseForm(); - var filter = item => item.server; - var patterns = formData.filter(filter); + const formData = parseForm(); + const filter = item => item.server; + const patterns = formData.filter(filter); PatternStorage.set(patterns); } function addRow(evt) { evt.preventDefault(); - var el = document.querySelector(".js-pattern-rows"); + const el = document.querySelector(".js-pattern-rows"); el.innerHTML += PATTERN_ROW('', ''); } diff --git a/postify.js b/postify.js index 5790460..09bf612 100644 --- a/postify.js +++ b/postify.js @@ -1,6 +1,7 @@ const APP_NAME = 'Postify'; function sendUrlToServer(url, addr) { + console.log('Send url to server', url, addr); return fetch(addr, { method: 'POST', headers: { @@ -34,7 +35,7 @@ function showNotification(url, addr) { function sendUrlToServers(url, patterns) { patterns.forEach(item => { - var regex = new RegExp(item.pattern || '.*', 'i'); + const regex = new RegExp(item.pattern || '.*', 'i'); if (regex.test(url) && item.server) { sendUrlToServer(url, item.server).then( () => showNotification(url, item.server), diff --git a/readme.md b/readme.md index f707181..a93624c 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,21 @@ Post current url to external http server. +## Install + +First, build xpi file + +```shell +make build-xpi +``` + +Next, change firefox extension signature preferences + +* open `about:config` +* change `xpinstall.signatures.required` to `false` + +Finally, install extension via "Install Add-on from a file". + ## See also * https://github.com/ibizaman/jsondispatch diff --git a/storage.js b/storage.js index 7529bbf..3be8ea8 100644 --- a/storage.js +++ b/storage.js @@ -1,6 +1,6 @@ function PropertyStorage(name) { - parse = function (data) { - var propertyData = data[name]; + const parse = function (data) { + const propertyData = data[name]; if (!propertyData) { return null; } @@ -12,7 +12,7 @@ function PropertyStorage(name) { }; this.get = function () { - var getting = browser.storage.local.get(name); + const getting = browser.storage.local.get(name); return getting.then(parse); };