-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmakefile
56 lines (47 loc) · 2.45 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Note: this makefile expects you to have run `npm install` and `npm run build`
# first before using it.
export PATH = $(shell echo "$${PATH}:./node_modules/node-jq/bin")
_ := $(shell rm -rf build && npm run build)
VERSION := $(shell cat build/manifest.json | jq .version)
PKG_VERSION := $(shell jq .version package.json)
ifneq ($(VERSION), $(PKG_VERSION))
$(error Extension version mismatch. manifest: $(VERSION), package.json: $(PKG_VERSION))
endif
.PHONY: version
version:
@echo ${VERSION}
.PHONY: firefox
firefox:
# ifneq (,$(wildcard blue-blocker-firefox-$(VERSION).zip))
# rm "blue-blocker-firefox-${VERSION}.zip"
# endif
# create temp copy of chrome manifest
cp build/manifest.json firefox-manifest.json
# change version to 2
jq '.manifest_version = 2' firefox-manifest.json >tmp.json && mv tmp.json firefox-manifest.json
# change background object to use script instead of service worker
jq '.background = {"scripts": ["service-worker-loader.js"],"type": "module"}' firefox-manifest.json >tmp.json && mv tmp.json firefox-manifest.json
# make web_accessible_resources an array of strings
jq '.web_accessible_resources = [.web_accessible_resources[].resources[]]' firefox-manifest.json >tmp.json && mv tmp.json firefox-manifest.json
# move action to browser_action
jq '.["browser_action"] = .action | del(.action)' firefox-manifest.json >tmp.json && mv tmp.json firefox-manifest.json
# remove static content script
jq '.content_scripts = []' firefox-manifest.json >tmp.json && mv tmp.json firefox-manifest.json
# add host permissions
jq '.permissions += ["*://*.twitter.com/*", "*://twitter.com/*", "*://*.x.com/*", "*://x.com/*"]' firefox-manifest.json >tmp.json && mv tmp.json firefox-manifest.json
# replace chrome manifest with firefox manifest
jq '.browser_specific_settings = {"gecko": {"id": "{119be3f3-597c-4f6a-9caf-627ee431d374}"}}' firefox-manifest.json >tmp.json && mv tmp.json firefox-manifest.json
mv firefox-manifest.json build/manifest.json
cp LICENSE build/LICENSE
cp readme.md build/readme.md
cd build; zip "blue-blocker-firefox-${VERSION}.zip" -r *
mv "build/blue-blocker-firefox-${VERSION}.zip" "blue-blocker-firefox-${VERSION}.zip"
.PHONY: chrome
chrome:
# ifneq (,$(wildcard blue-blocker-chrome-$(VERSION).zip))
# rm "blue-blocker-chrome-${VERSION}.zip"
# endif
cp LICENSE build/LICENSE
cp readme.md build/readme.md
cd build; zip "blue-blocker-chrome-${VERSION}.zip" -r *
mv "build/blue-blocker-chrome-${VERSION}.zip" "blue-blocker-chrome-${VERSION}.zip"