# SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2025-2026 Woj. Kosior AWK ?= awk INKSCAPE ?= inkscape JQ ?= jq SED ?= sed TR ?= tr ZIP ?= zip default: simple-extension.zip .PHONY: default ICON_SIZES = 128 64 48 32 16 PNG_ICONS = $(addsuffix .png, $(addprefix icons/extension-, $(ICON_SIZES))) $(PNG_ICONS): icons/extension.svg command -v $(INKSCAPE) for SIZE in $(ICON_SIZES); do \ $(INKSCAPE) -o icons/extension-$$SIZE.png -w $$SIZE -h $$SIZE \ icons/extension.svg; \ done icomment = CONTENT_SCRIPTS = $(addprefix content/, \ $(icomment The following are shared utilities.) \ pow-solver.js \ appended-number-counting-schemes.js \ $(icomment The following are the actual fixes.) \ anubis-bot-blocker.js \ amso-shop.js \ botland-shop.js \ go-away-bot-blocker.js \ janessa-garrow-home-site.js \ linkedin-pulse.js \ stephanskirche-cathedral-site.js \ the-chosen-main-site.js \ the-chosen-videos.js \ vatican-news-main-page.js \ vatican-news-site.js \ varnish-pow-bot-blocker.js \ ) BG_SCRIPTS = $(addprefix background/, \ background.js \ google-drive-folders.js \ ) manifest.json: manifest.json.in get-code-block.awk $(CONTENT_SCRIPTS) \ GNUmakefile command -v $(AWK) command -v $(JQ) command -v $(SED) command -v $(TR) CONTENT_SCRIPT_SPECS="$$( \ for SCRIPT in $(CONTENT_SCRIPTS); do \ JQ_CODE="$$( \ $(AWK) --assign block_type=manifest-jq \ -f get-code-block.awk $$SCRIPT \ )" && \ printf %s ' \ { \ "run_at": "document_end", \ "matches": [], \ "all_frames": true, \ "js": [ "'$$SCRIPT'" ] \ } \ ' | \ $(JQ) --compact-output "$$JQ_CODE"; \ done | \ $(TR) '\n' , | \ $(SED) 's/,$$//' \ )" && \ BG_SCRIPT_NAMES="$$( \ printf '"%s",' $(BG_SCRIPTS) | \ $(SED) 's/,$$//' \ )" && \ $(JQ) --indent 4 \ ".content_scripts = [$$CONTENT_SCRIPT_SPECS] | \ .background.scripts = [$$BG_SCRIPT_NAMES]" \ $< >$@.tmp mv $@.tmp $@ background/background.js: background/background.js.in get-code-block.awk \ $(CONTENT_SCRIPTS) command -v $(AWK) command -v $(SED) BG_CODE="$$( \ $(AWK) --assign block_type=background-js \ -f get-code-block.awk $(CONTENT_SCRIPTS) | \ $(SED) 's/\([-\]\)/\\\1/g; s/.*/\0\\n/' | \ tr --delete '\n' \ )" && \ $(SED) "s-[\$$]contentScriptsBgCode[\$$]-$$BG_CODE-g" $< > $@ simple-extension.zip: manifest.json $(CONTENT_SCRIPTS) $(BG_SCRIPTS) \ $(PNG_ICONS) command -v $(ZIP) rm -rf $@ && $(ZIP) --quiet $@ $^ clean: rm -rf simple-extension.zip manifest.json background/background.js .PHONY: clean