Skip to content

Commit

Permalink
Mv3 (#19)
Browse files Browse the repository at this point in the history
* mv3: changed background to specify a service_worker
* mv3: browserAction → action
* package scripts now create 2 release files, supporting manifest 2 (for firefox) & 3 (for chrome)
  • Loading branch information
codemonkey-uk authored Jan 9, 2022
1 parent 270b675 commit 58649de
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 19 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Localise Timezones

## Single purpose

Show times from anywhere in the world in the users local time.

## Description

This add on put you in control. You decide how times from around the world appear on any website. This add on converts the time from any web site's text to your local time zone automatically. You have have it add the converted time in parenthesis after the original text, or show a pop when you select text. Either way you always see what was originally written, and can easily understand when events are going to happen.
Expand Down Expand Up @@ -37,11 +41,21 @@ https://addons.mozilla.org/en-US/firefox/addon/localise-timezones/

https://chrome.google.com/webstore/detail/localise-timezones/opjfchgghhechkchondagenjpobfjooe

## Privacy
## Privacy

Localise Timezones does not collect, transmit, or store any data. It only changes the content of websites in the browser as you view them.

## Copyright
## Build Scripts

Local Time release zips are created with zipnote.

The default zipnote on OS X zipnote is out of date. To install a newer version of zipnote use brew:
> brew install zip
And put it first on your path:
> export PATH="/usr/local/opt/zip/bin:$PATH"
## Copyright
Mozilla Public License Version 2.0

Icon by [Freepik](http://www.freepik.com/ "Freepik") from [www.flaticon.com](https://www.flaticon.com/ "Flaticon")
9 changes: 9 additions & 0 deletions background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script type="module" src="background.js"></script>
</body>
</html>
16 changes: 11 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// background.js
import './browser-polyfill.js';

// chrome / firefox compatibility
if (typeof browser.action === "undefined")
browser.action = browser.browserAction;


// this is just so we can trigger a full pass from the browser button
// depends on polyfill for cross-browser compatibility
Expand Down Expand Up @@ -30,10 +36,10 @@ function statusIcon(status)
function onError(error)
{
console.log("Error: "+JSON.stringify(error));
browser.browserAction.setTitle(
browser.action.setTitle(
{title :"Localise: Unresponsive, try reloading."}
);
browser.browserAction.setIcon(
browser.action.setIcon(
{path: statusIcon(0)}
).catch(
()=>{console.log("Error setting error icon");}
Expand All @@ -46,16 +52,16 @@ function messageContentScript(tab_id, message)
tab_id,
{greeting: message}
).then(response => {
browser.browserAction.setTitle(
browser.action.setTitle(
{title :"Localise: " + statusString(response.response)}
);
browser.browserAction.setIcon(
browser.action.setIcon(
{tabId: tab_id, path: statusIcon(response.response)}
).catch(onError);
}).catch(onError);
}

browser.browserAction.onClicked.addListener((tab) => {
browser.action.onClicked.addListener((tab) => {
messageContentScript(tab.id, "toggle");
});

Expand Down
2 changes: 1 addition & 1 deletion browser-polyfill.js

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

29 changes: 22 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
NAME = local_time
VERSION = 0_5_1
VERSION = 0_5_3
BUILD_DIR = release
BUILD_FILE = $(BUILD_DIR)/$(NAME)_$(VERSION).zip
FILES = browser-polyfill.js core.js content.js background.js manifest.json LICENSE icon-512.png icon-128.png options.js options.html popup.css button*.png
MASTER_FILE = $(BUILD_DIR)/$(NAME)_$(VERSION).zip
FIREFOX_FILE = $(BUILD_DIR)/$(NAME)_FF_$(VERSION).zip
CHROME_FILE = $(BUILD_DIR)/$(NAME)_CHROME_$(VERSION).zip
SRC = browser-polyfill.js core.js content.js background.js background.html options.js options.html popup.css
ICONS = icon-512.png icon-128.png button*.png
FILES = $(SRC) $(ICONS) manifest_v2.json manifest_v3.json LICENSE

.DEFAULT_GOAL := build

.PHONY : clean
clean:
rm -rf $(BUILD_FILE)
@echo "Release zip deleted - " $(BUILD_FILE)
rm -rf $(BUILD_DIR)/*.*

$(BUILD_FILE) : $(FILES)
$(MASTER_FILE) : $(FILES)
@mkdir -p $(@D)
zip -r9T $@ $(FILES)

$(FIREFOX_FILE) : $(MASTER_FILE)
cp $(MASTER_FILE) $(FIREFOX_FILE)
printf "@ manifest_v2.json\n@=manifest.json\n" | zipnote -w $(FIREFOX_FILE)

$(CHROME_FILE) : $(MASTER_FILE)
cp $(MASTER_FILE) $(CHROME_FILE)
printf "@ manifest_v3.json\n@=manifest.json\n" | zipnote -w $(CHROME_FILE)

chrome: $(CHROME_FILE)

firefox: $(FIREFOX_FILE)

.PHONY : build
build: $(BUILD_FILE)
build: chrome firefox
6 changes: 2 additions & 4 deletions manifest.json → manifest_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Localise Timezones",
"description": "Converts times to your local time zone",
"version": "0.5.1",
"version": "0.5.3",
"icons": {
"128": "icon-128.png",
"512": "icon-512.png"
Expand All @@ -21,9 +21,7 @@
"storage"
],
"background": {
"scripts": [
"browser-polyfill.js", "background.js"
]
"page": "background.html"
},
"content_scripts": [
{
Expand Down
39 changes: 39 additions & 0 deletions manifest_v3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"manifest_version": 3,
"name": "Localise Timezones",
"description": "Converts times to your local time zone",
"version": "0.5.3",
"icons": {
"128": "icon-128.png",
"512": "icon-512.png"
},
"action": {
"default_title": "Localise Timezones",
"default_icon": {
"128": "button.png"
}
},
"options_ui": {
"page": "options.html"

},
"permissions": [
"storage"
],
"background": {
"service_worker": "background.js", "type": "module"
},
"content_scripts": [
{
"matches": [
"*://*/*"
],
"js": [
"browser-polyfill.js", "core.js", "content.js"
],
"all_frames": true,
"run_at": "document_idle",
"css": ["popup.css"]
}
]
}

0 comments on commit 58649de

Please sign in to comment.