From 8e91b93d298f0bfcd8b3ace9cd35ab0565109491 Mon Sep 17 00:00:00 2001
From: mrfry <mrfry@airmail.cc>
Date: Tue, 11 Apr 2023 11:18:13 +0200
Subject: [PATCH] DOMAIN env var functionality improvements

---
 devel/readme.md      | 51 --------------------------------------------
 devel/testWrapper.js | 41 -----------------------------------
 make.sh              |  4 ++--
 3 files changed, 2 insertions(+), 94 deletions(-)
 delete mode 100644 devel/readme.md
 delete mode 100644 devel/testWrapper.js

diff --git a/devel/readme.md b/devel/readme.md
deleted file mode 100644
index 7ec065e..0000000
--- a/devel/readme.md
+++ /dev/null
@@ -1,51 +0,0 @@
-# Setup
-
-A `stable.user.js`-ben a következő sorokat módosítsd a helyi szerver használatához:
-
-## 0
-
-Tampermonkey-ban tiltsd le az eddig használt scriptet, hogy ne akadjanak össze
-
-## 1
-
-**Ezt csak akkor csináld, ha a scripthez tartozó szervert futtatod!** Ha nem indítasz hozzá
-szervert, akkor az alapértelmezettet fogja használni.
-
-Scripthez szerver: https://gitlab.com/MrFry/mrfrys-node-server/-/tree/master/devel
-
-```javascript
-setVal('ISDEVEL', false)
-// only one of these should be true for testing
-const forceTestPage = false
-const forceResultPage = false
-const forceDefaultPage = false
-```
-
-Itt a `setVal('ISDEVEL', false)`-t írd át `setVal('ISDEVEL, true)`-ra
-
-## 2
-
-Nyisd meg a tampermonkey bővítményt, majd hozz létre egy új scriptet
-
-A megnyíló ablakban tölrölj mindent a szerkesztőben, és a `devel/testWrapper.js` fájl tartalmát
-másold be úgy ahogy van.
-
-## 3
-
-A bemásolt tartalomban keresd meg a következő részt:
-```
-// @require      file:///{ELÉRÉSI ÚT IDE}
-```
-Ide írd be a `stable.user.js` elérési útvonalát. Ezt legkönyebben úgy teheted meg, hogy fájl
-böngészőből behúzod az URL bárba a `stable.user.js`-t magát. Ekkor felugorhat a tampermonkey hogy
-telepíteni akarja, de azt zárd be és egy üres ablakban ott kellene lennie az URL bárban a teljes
-elérési útnak. Ezt úgy hogy a `file:///` legyen az eleje másold be a a `@require` tag-hez
-
-## 4
-
-Ha minden jól ment, akkor a moddle oldalán már a helyi változatnak kellene futnia, és minden
-`stable.user.js` módosítás azonnal látható a böngésző frissítése után. Minden változás után
-frissítsd az oldalt, hogy lásd a módosításaid!
-
-Weboldalak, ahol fut a script: a script headerben található (`stable.user.js` elején) találhatóak
-`// @match` tagek. Azok közül minden oldalon megy a script.
diff --git a/devel/testWrapper.js b/devel/testWrapper.js
deleted file mode 100644
index 06eb4ca..0000000
--- a/devel/testWrapper.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ----------------------------------------------------------------------------
-
- Online Moodle/Elearning/KMOOC test help
- https://greasyfork.org/en/scripts/38999-moodle-elearning-kmooc-test-help
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-
- ------------------------------------------------------------------------- */
-
-// ==UserScript==
-// @name         Moodle/Elearning/KMOOC test help
-// @version      DEVEL
-// @description  Online Moodle/Elearning/KMOOC test help
-// @author       You
-// @match        https://elearning.uni-obuda.hu/*
-// @match        https://qmining.frylabs.net/*
-// @match        file:///*
-// @grant        GM_getResourceText
-// @grant        GM_info
-// @grant        GM_getValue
-// @grant        GM_deleteValue
-// @grant        GM_setValue
-// @grant        GM_xmlhttpRequest
-// @grant        GM_openInTab
-// @require      file:///{ELÉRÉSI ÚT IDE}
-// ==/UserScript==
-
-;(function () {
-  console.log('done')
-})()
diff --git a/make.sh b/make.sh
index 5e2c1df..c44c566 100755
--- a/make.sh
+++ b/make.sh
@@ -6,12 +6,12 @@ resultUserscriptPath="./stable.user.js"
 
 domain="${DOMAIN}"
 
-if [ -f "${domainPath}" ]; then
+if [ -z "${domain}" ] && [ -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"
+    echo -e "\033[0;41mDOMAIN is not set, and ${domainPath} does not exist!\033[0m"
     exit 1
 fi