Add hideOther config option

Allows the User to hide the total amount of domains and their addresses, always only displaying the first one of the array
main
ClaraCrazy 2024-10-21 02:21:03 +02:00
parent 2026a360bf
commit 5040b06264
No known key found for this signature in database
GPG Key ID: EBBC896ACB497011
4 changed files with 25 additions and 6 deletions

View File

@ -60,7 +60,12 @@
"value": ["48hr.email", "Crazyco", "https://crazyco.xyz"] "value": ["48hr.email", "Crazyco", "https://crazyco.xyz"]
}, },
"HTTP_DISPLAY_SORT": { "HTTP_DISPLAY_SORT": {
"description": "Sort the emails for use" "description": "Sort the emails for use",
"value": 0
},
"HTTP_HIDE_OTHER": {
"description": "Hide other emails from the list besides the first",
"value": false
} }
} }
} }

View File

@ -28,6 +28,7 @@ const config = {
// 1 sorts alphabetically, // 1 sorts alphabetically,
// 2 sorts alphabetically and only shuffles the first item, // 2 sorts alphabetically and only shuffles the first item,
// 3 shuffles all // 3 shuffles all
hideOther: process.env.HTTP_HIDE_OTHER || false, // Hide other emails in the list and only show first (true) or show all (false)
}, },
} }

View File

@ -115,6 +115,19 @@ class Helper {
return array return array
} }
/**
* Hide other emails in the list and only show first (true) or show all (false)
* @param {Array} array
* @returns {Array}
*/
hideOther(array) {
if (config.http.hideOther) {
return array[0]
} else {
return array
}
}
/** /**
* Get a domain list from config for use * Get a domain list from config for use
* @returns {Array} * @returns {Array}
@ -123,13 +136,13 @@ class Helper {
getDomains() { getDomains() {
switch (config.http.displaySort) { switch (config.http.displaySort) {
case 0: case 0:
return config.email.domains // No modification return this.hideOther(config.email.domains) // No modification
case 1: case 1:
return config.email.domains.sort() // Sort alphabetically return this.hideOther(config.email.domains.sort()) // Sort alphabetically
case 2: case 2:
return this.shuffleFirstItem(config.email.domains.sort()) // Sort alphabetically and shuffle first item return this.hideOther(this.shuffleFirstItem(config.email.domains.sort())) // Sort alphabetically and shuffle first item
case 3: case 3:
return this.shuffleArray(config.email.domains) // Shuffle all return this.hideOther(this.shuffleArray(config.email.domains)) // Shuffle all
} }
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "48hr.email", "name": "48hr.email",
"version": "1.6.0", "version": "1.6.1",
"private": false, "private": false,
"scripts": { "scripts": {
"start": "node --trace-warnings ./app.js", "start": "node --trace-warnings ./app.js",