#!/bin/bash scriptPath=$(dirname -- "${0}") domainPath="${scriptPath}/../../data/domain" userscriptPath="./user.js" resultUserscriptPath="./stable.user.js" domain="${DOMAIN}" if [ -f "${domainPath}" ]; then domain=$(cat "${domainPath}") fi if [ -z "${domain}" ]; then echo -e "\033[0;41m${domainPath} does not exist, and DOMAIN is not set!\033[0m" exit 1 fi if [ ! -f "${userscriptPath}" ]; then echo -e "\033[0;41m${userscriptPath} does not exist!\033[0m" exit 1 fi userscript=$(cat "${userscriptPath}") toReplace="[DOMAIN]" result="${userscript//"$toReplace"/"$domain"}" echo "$result" > "${resultUserscriptPath}" echo "Exported with domain: '${domain}' to '${resultUserscriptPath}'"