Last active
February 5, 2022 19:02
-
-
Save BharatKalluri/a117542eb3aba1950325e2962b13a9b3 to your computer and use it in GitHub Desktop.
Snippets on medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .profile | |
# Mute spotify on ad | |
while sleep 1; do mute_ad_spotify; done & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mute_ad_spotify() { | |
MEDIA_TITLE=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata 2>/dev/null | sed -n '/title/{n;p}' | cut -d '"' -f 2) | |
if [[ $MEDIA_TITLE = "Advertisement" ]]; then | |
amixer -q -D pulse sset Master mute | |
else | |
amixer -q -D pulse sset Master unmute | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mutes audio if spotify ad is playing | |
mute_ad_spotify() { | |
SPOTIFY_SINK_ID=$(pacmd list-sink-inputs | tr '\n' '\r' | perl -pe 's/ *index: ([0-9]+).+?application\.name = "([^\r]+)"\r.+?(?=index:|$)/\2:\1\r/g' | tr '\r' '\n' | grep spotify | cut -d ":" -f 2) | |
if [ ! -z "$SPOTIFY_SINK_ID" ]; then | |
MEDIA_TITLE=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata 2>/dev/null | sed -n '/title/{n;p}' | cut -d '"' -f 2) | |
IS_SPOTIFY_AD=0 | |
[[ $MEDIA_TITLE == *Advertisement* ]] && IS_SPOTIFY_AD=1 | |
if [[ $IS_SPOTIFY_AD == 1 ]]; then | |
pactl set-sink-input-mute ${SPOTIFY_SINK_ID} 1 | |
elif [[ $IS_SPOTIFY_AD == 0 ]]; then | |
pactl set-sink-input-mute ${SPOTIFY_SINK_ID} 0 | |
fi | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mutes audio if spotify ad is playing | |
mute_ad_spotify() { | |
MEDIA_TITLE=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata 2>/dev/null | sed -n '/title/{n;p}' | cut -d '"' -f 2) | |
IS_MUTE=0 | |
[[ $(amixer get Master | sed "5q;d") == *off* ]] && IS_MUTE=1 | |
IS_SPOTIFY_AD=0 | |
[[ $MEDIA_TITLE == *Advertisement* ]] && IS_SPOTIFY_AD=1 | |
if [ ! -z "$MEDIA_TITLE" ]; then | |
if [[ $IS_MUTE == 0 ]] && [[ $IS_SPOTIFY_AD == 1 ]]; then | |
amixer -q -D pulse sset Master mute | |
elif [[ $IS_MUTE == 1 ]] && [[ $IS_SPOTIFY_AD == 0 ]]; then | |
# unmutes if mixer is muted and no ad is playing, this ensures that after ad the music will continue | |
# But also this means that when spotify is playing, I cannot mute audio! | |
amixer -q -D pulse sset Master unmute | |
fi | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unSubBtnList = document.querySelectorAll("[aria-label^='Unsubscribe from']"); | |
for (let i = 0; i < unSubBtnList.length; i++) { | |
setTimeout(() => { | |
unSubBtnList[i].click(); | |
}, 1000); | |
setTimeout(() => { | |
document.querySelector('[aria-label="Unsubscribe"]').click(); | |
}, 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment