Please see the full repo on this link
Special thanks Gieljnssns for his repo
It’s something like this (In Gieljnssns repo):
So, you can easily to enable/ disable access to Facebook by switching on/ off the Facebook button created as the below example.
input_boolean:
allowfacebook:
name: Allow Facebook
# initial: on
icon: mdi:facebook
automation:
- id: enable_facebook
alias: Enable Facebook
hide_entity: true
initial_state: 'on'
trigger:
platform: state
entity_id: input_boolean.allowfacebook
to: 'on'
action:
- service: adguard.remove_url
data:
url: https://raw.githubusercontent.com/gieljnssns/Block_facebook_dns/master/adguard-facebook.txt
- id: disable_facebook
alias: Disable Facebook
hide_entity: true
initial_state: 'on'
trigger:
platform: state
entity_id: input_boolean.allowfacebook
to: 'off'
action:
- service: adguard.add_url
data:
url: https://raw.githubusercontent.com/gieljnssns/Block_facebook_dns/master/adguard-facebook.txt