diff options
author | terminaldweller <thabogre@gmail.com> | 2022-12-02 17:52:42 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-12-02 17:52:42 +0000 |
commit | 674f40d027ece13daa78ef2a7d69c79f4198368a (patch) | |
tree | 2bcc0e41e5064b62d18bb376a5ecf0d760b6f13d /bin | |
parent | update (diff) | |
download | scripts-674f40d027ece13daa78ef2a7d69c79f4198368a.tar.gz scripts-674f40d027ece13daa78ef2a7d69c79f4198368a.zip |
update
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/get_random_ua.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/bin/get_random_ua.sh b/bin/get_random_ua.sh new file mode 100755 index 0000000..3737a89 --- /dev/null +++ b/bin/get_random_ua.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env sh + +USER_AGENT_PATH=/home/devi/devi/List-of-user-agents +ANDY_FILE="Android+Webkit+Browser.txt" +OPERA_FILE="Opera.txt" +FFOX_FILE="Firefox.txt" +IE_FILE="Internet+Explorer.txt" +CHROME_FILE="Chrome.txt" +EDGE_FILE="Edge.txt" +SAFARI_FILE="Safari.txt" + +get_ua() { + if [ "$1" = "andy" ]; then + UA_FILE="${USER_AGENT_PATH}"/"${ANDY_FILE}" + elif [ "$1" = "opera" ]; then + UA_FILE="${USER_AGENT_PATH}"/"${OPERA_FILE}" + elif [ "$1" = "ffox" ]; then + UA_FILE="${USER_AGENT_PATH}"/"${FFOX_FILE}" + elif [ "$1" = "ie" ]; then + UA_FILE="${USER_AGENT_PATH}"/"${IE_FILE}" + elif [ "$1" = "chrome" ]; then + UA_FILE="${USER_AGENT_PATH}"/"${CHROME_FILE}" + elif [ "$1" = "edge" ]; then + UA_FILE="${USER_AGENT_PATH}"/"${EDGE_FILE}" + elif [ "$1" = "safari" ]; then + UA_FILE="${USER_AGENT_PATH}"/"${SAFARI_FILE}" + elif [ "$1" = "all" ]; then + cat ${USER_AGENT_PATH}/${ANDY_FILE} \ + ${USER_AGENT_PATH}/${OPERA_FILE} \ + ${USER_AGENT_PATH}/${FFOX_FILE} \ + ${USER_AGENT_PATH}/${IE_FILE} \ + ${USER_AGENT_PATH}/${CHROME_FILE} \ + ${USER_AGENT_PATH}/${EDGE_FILE} \ + ${USER_AGENT_PATH}/${SAFARI_FILE} \ + > /tmp/random_uas_concat + UA_FILE="/tmp/random_uas_concat" + else + echo "error: unknown kind. must be one of andy,opera,ffox,ie,chrome,edge,safari,all" + exit 1 + fi + + shuf -n 1 "${UA_FILE}" +} + +if [ "$1" = "--help" ]; then + echo "prints a random user agent string." + echo "you can specify a --kind to get a random user agent of a specific browser." + echo "currently the valid values are: andy,opera,ffox,ie,chrome,edge,safari,all" +elif [ "$1" = "--kind" ]; then + get_ua "$2" +else + get_ua all +fi |