-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
insert-filter-remove-class.sh
55 lines (41 loc) · 1.39 KB
/
insert-filter-remove-class.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
read -p "Enter the domain that you want to add: " domain
declare blocklist="./blocklist.txt"
declare domain=$(echo $domain | sed -E 's/^\s*.*:\/\///g') # remove any https:// or http://.
declare domain=$(echo $domain | sed 's:/*$::') # remove any trailing slash.
declare domain=$(echo $domain | sed 's/www.//g') # remove www. if present.
read -p "Enter the class that you want to remove: " class
read -p "Enter the element the class should be removed from: " elm
declare blocklistRule="${domain}##+js(rc, ${class}, ${elm}, stay)"
if [ "$domain" == "" ]; then
echo "No domain provided."
exit
fi
if [ "$domain" == "v" ]; then
echo "Wrong paste command."
exit
fi
if [ "$domain" == "[A[A" ]; then
echo "syntax error [A[A."
exit
fi
if [ "$class" == "" ]; then
echo "No class provided"
exit
fi
if [ "$elm" == "" ]; then
echo "No element provided"
exit
fi
if grep -q "$blocklistRule" "$blocklist"; then
echo "Rule already present"
else
echo "checking for updates..."
git pull origin master && git pull github master
if grep -q "$blocklistRule" "$blocklist"; then
echo "This rule has already been added before you"
else
printf "$blocklistRule\n" >> "$blocklist"
git commit -am "block class ${class} on ${elm} for $domain" && git push origin master && git push github master
fi
fi