aboutsummaryrefslogtreecommitdiff
path: root/yomichan/makefile
blob: c4bd45e0de7ecc5b426bc8dd3b4046c8d248ca4e (plain)
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
all: sentence-export.min.js

.PHONY: clean patch

include ../common.mk

yomichan/js/user.js: yomichan sentence-export.min.js
	ln -sf ../../sentence-export.min.js $@

yomichan-chrome.zip:
	curl https://github.com/FooSoft/yomichan/releases/latest/download/$@ -Lso- > $@

yomichan: yomichan-chrome.zip
	unzip -qo yomichan-chrome.zip -d yomichan

yomichan/manifest.json.bak:
	cp yomichan/manifest.json $@

yomichan/search.html.bak:
	cp yomichan/search.html $@

yomichan/manifest-patched.json: yomichan/manifest.json.bak
	jq '.content_scripts[0].js[.content_scripts[0].js | length] |= .+ "js/user.js"' $< > $@

yomichan/search-patched.html: yomichan/search.html.bak
	sed 's#</body>#<script defer src="/js/user.js"></script>\n</body>#' $< > $@

yomichan/images/%.svg: %.svg
	ln -sf ../../copy.svg $@

yomichan/css/%.css: %.css
	ln -sf ../../$< $@

patch: yomichan
patch: yomichan/search-patched.html
patch: yomichan/manifest-patched.json
patch: yomichan/js/user.js
patch: yomichan/images/copy.svg
patch: yomichan/css/sentence-export.css
patch:
	ln -sf search-patched.html yomichan/search.html
	ln -sf manifest-patched.json yomichan/manifest.json

yomichan-chrome-patched.zip: yomichan patch
	zip -qr $@ $<

clean:
	$(RM) -r sentence-export.min.js yomichan yomichan-chrome.zip yomichan-chrome-patched.zip